[atomic] Enable the atomic feature by default - #85
Open
williamwutq wants to merge 5 commits into
Open
williamwutq wants to merge 5 commits into
williamwutq wants to merge 5 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description: Enable the
atomicfeature by default. This changes both default Cargo feature (Rust) and default compilation target (C).Important Feature: Yes
Type: Core - Atomic
Feature Flags: atomic -> core
Breaking change: Yes
New Types: None
Rust Only: No
Fuzz: None
Safety Review: None
Original PLANNED.md entry:
Enabling the
atomicfeature by default (0.5.0)Feature flag: N/A — this changes which features are enabled by default, not a new one.
Breaking change: Yes (0.5.0) — a plain
bstack = "0.5"dependency (anything withoutdefault-features = false) now compiles in theatomic-gated API surface:atrunc,splice/splice_into,try_extend/try_extend_zeros/try_extend_sparse/try_extend_sparse_batched,try_discard, andget_batched_gen. The larger set gated onsetandatomictogether —cross_exchange,copy,process_gen,set_batched/inplace_gen,swap/swap_into/cas— only newly compiles in for consumers who also already enableset, sincesetitself stays opt-in (see Design below). Consumers who already pin an explicitfeatures = [...]list withoutatomicare unaffected;default-features = falsestill builds the bare push/pop/get/peek stack with none of it.Motivation
atomic's compound ops use —wip_ptr/wip_auxin the 32-byte header, the splice/exchange/multi-write/copy journal modes documented inlib.rs's format table and implemented byio_core.rs'sjournaled_*helpers — is already unconditional: everybstackfile carries it regardless of which features are compiled in. Enablingatomicby default changes no format byte and persists no new state; it only exposes machinery that is already there.atomiconly adds methods; it changes no existingpush/pop/get/peekbehavior.alloc, by contrast, adds real state — sub-allocator bookkeeping, handle types,BStackSliceprovenance — which is why it stays opt-in even for a caller who only wants compound atomicity.atomiccarries none of that cost.alloc,set, andatomicare gated together acrossguarded's hook-based slices, the external-merge-sort strategy above,BStackInPlaceResizeAllocator, and the public journal primitive planned for 0.5.0 thatbllistdepends on. 7 of the 12 examples already requireatomic. A caller reaching for any of these already hand-adds the flag; defaulting it removes that step.atomicin nearly every example (features = ["atomic"],features = ["set", "atomic"], …) — it's optional in name only.Design
default = ["atomic"]to[features]inCargo.toml.setandallocstay opt-in — both add real new semantics (in-place byte-mutation history, sub-allocation) that a stack-only consumer may not want, unlikeatomic.docs.rsalready builds withall-features = true, so its output is unaffected.atomic— an uncommon but real case (e.g. minimizing compiled surface, or auditing exactly which journal codepaths are reachable) — who now needdefault-features = falseplus an explicitfeatures = [...]list to keep it out.Open questions
atomicentry from examplerequired-featureslists that pair it withset/alloc— cosmetic only, sincerequired-featureschecks additively against whatever is enabled regardless of default status, so leaving them as-is is also fine.