Repository navigation
feat(engine): add BarrierState + SlotData types per DG-2.a spec (DG-3.a) - #4826
Merged
Merged
Conversation
oferchen
force-pushed
the
feat/dg-3a-barrierstate-slotdata-types
branch
3 times, most recently
from
May 24, 2026 01:26
0e40324 to
0e6b317
Compare
Introduces the Option-B types specified in `docs/design/dg-2a-option-b-spec.md` (BarrierState, SlotData, SlotEntry, and the post-split SlotHandle) alongside the existing SlotBarrier. This is the type-definition-only first step of DG-3; no call site is migrated. DG-3.b will swap the DashMap value type, DG-3.c will retype DecrementGuard and the mod-level SlotHandle, and DG-3.d will collapse the finish_file spin loop. Each new type carries a smoke test that exercises its single obvious operation.
oferchen
force-pushed
the
feat/dg-3a-barrierstate-slotdata-types
branch
from
May 24, 2026 01:27
0e6b317 to
df8be7b
Compare
This was referenced May 24, 2026
oferchen
added a commit
that referenced
this pull request
May 24, 2026
Routes the per-slot decrement-guard Arc through the bookkeeping
allocation (`BarrierState`) instead of the transitional `SlotBarrier`
adapter. After DG-3.b moved the canonical per-file state into
`SlotEntry { data: Arc<SlotData>, barrier: Arc<BarrierState> }`, the
worker's lingering `DecrementGuard` clone still rode on the adapter
Arc, which - because the adapter clones both inner Arcs on every
`slot_for` call - kept the payload Arc's strong count above 1 across
the flusher's `Arc::try_unwrap` window. DG-3.c retypes
`DecrementGuard.barrier` to `Arc<BarrierState>` so the guard's clone
lives on a strong-count graph disjoint from `Arc<SlotData>`, closing
the cross-Arc release race that the DG-2.a Option-B spec
(`docs/design/dg-2a-option-b-spec.md` section 2) was designed to
eliminate.
`SlotHandle::new` now sources the bookkeeping clone via a new
`SlotBarrier::barrier()` accessor and hands it to the guard; the
handle itself keeps its `Arc<SlotBarrier>` field for the lock path so
the `SlotHandle` retype can sequence independently in a follow-on
DG-3.x task. The now-dead forwarding `SlotBarrier::decrement_inflight`
is removed - the guard talks to `BarrierState::decrement_inflight`
directly. Public API and wire behaviour unchanged.
Related: DG-3.a (#4826), DG-3.b (#4841), DG-2.a spec.
oferchen
added a commit
that referenced
this pull request
May 24, 2026
) Routes the per-slot decrement-guard Arc through the bookkeeping allocation (`BarrierState`) instead of the transitional `SlotBarrier` adapter. After DG-3.b moved the canonical per-file state into `SlotEntry { data: Arc<SlotData>, barrier: Arc<BarrierState> }`, the worker's lingering `DecrementGuard` clone still rode on the adapter Arc, which - because the adapter clones both inner Arcs on every `slot_for` call - kept the payload Arc's strong count above 1 across the flusher's `Arc::try_unwrap` window. DG-3.c retypes `DecrementGuard.barrier` to `Arc<BarrierState>` so the guard's clone lives on a strong-count graph disjoint from `Arc<SlotData>`, closing the cross-Arc release race that the DG-2.a Option-B spec (`docs/design/dg-2a-option-b-spec.md` section 2) was designed to eliminate. `SlotHandle::new` now sources the bookkeeping clone via a new `SlotBarrier::barrier()` accessor and hands it to the guard; the handle itself keeps its `Arc<SlotBarrier>` field for the lock path so the `SlotHandle` retype can sequence independently in a follow-on DG-3.x task. The now-dead forwarding `SlotBarrier::decrement_inflight` is removed - the guard talks to `BarrierState::decrement_inflight` directly. Public API and wire behaviour unchanged. Related: DG-3.a (#4826), DG-3.b (#4841), DG-2.a spec.
This was referenced May 25, 2026
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
….a) (#4826) Introduces the Option-B types specified in `docs/design/dg-2a-option-b-spec.md` (BarrierState, SlotData, SlotEntry, and the post-split SlotHandle) alongside the existing SlotBarrier. This is the type-definition-only first step of DG-3; no call site is migrated. DG-3.b will swap the DashMap value type, DG-3.c will retype DecrementGuard and the mod-level SlotHandle, and DG-3.d will collapse the finish_file spin loop. Each new type carries a smoke test that exercises its single obvious operation.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
) Routes the per-slot decrement-guard Arc through the bookkeeping allocation (`BarrierState`) instead of the transitional `SlotBarrier` adapter. After DG-3.b moved the canonical per-file state into `SlotEntry { data: Arc<SlotData>, barrier: Arc<BarrierState> }`, the worker's lingering `DecrementGuard` clone still rode on the adapter Arc, which - because the adapter clones both inner Arcs on every `slot_for` call - kept the payload Arc's strong count above 1 across the flusher's `Arc::try_unwrap` window. DG-3.c retypes `DecrementGuard.barrier` to `Arc<BarrierState>` so the guard's clone lives on a strong-count graph disjoint from `Arc<SlotData>`, closing the cross-Arc release race that the DG-2.a Option-B spec (`docs/design/dg-2a-option-b-spec.md` section 2) was designed to eliminate. `SlotHandle::new` now sources the bookkeeping clone via a new `SlotBarrier::barrier()` accessor and hands it to the guard; the handle itself keeps its `Arc<SlotBarrier>` field for the lock path so the `SlotHandle` retype can sequence independently in a follow-on DG-3.x task. The now-dead forwarding `SlotBarrier::decrement_inflight` is removed - the guard talks to `BarrierState::decrement_inflight` directly. Public API and wire behaviour unchanged. Related: DG-3.a (#4826), DG-3.b (#4841), DG-2.a spec.
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.
Summary
First step of DG-3: introduce the Option-B types specified in
docs/design/dg-2a-option-b-spec.mdalongside the existing
SlotBarrier. Purely additive; no call site istouched.
The DG-1 audit
(
docs/design/decrementguard-audit.md)traced the
finish_filerelease race incrates/engine/src/concurrent_delta/parallel_apply.rsto a singleArc<SlotBarrier>graph carrying two unrelated ownership obligations(unwrap the payload + decrement the counter). DG-2.a's Option B splits
those obligations across two Arcs whose strong-count trajectories are
independent. DG-2.b sequences the migration; DG-2.c chose the
single-PR atomic strategy. This PR delivers DG-3.a from that plan:
type definitions only.
New types in
crates/engine/src/concurrent_delta/parallel_apply/slot_barrier.rs:BarrierState- in-flight counter + Condvar (the notify-bearing half).SlotData- per-file payload behind its own mutex (the unwrap-bearing half).SlotEntry- DashMap value carrying both Arcs.SlotHandle(parallel to the mod-levelSlotHandle) - the post-splithandle DG-3.c will rename into the mod-level slot once
DecrementGuardis retyped. The spec's
_decrement: DecrementGuardfield is intentionallydeferred to DG-3.c because the existing
DecrementGuardstill holdsArc<SlotBarrier>; attaching it now would defeat the split.All four types are
pub(super), gated with#[allow(dead_code)]so theproduction build does not warn while DG-3.b/c/d wire the callers. Each
type has a
#[cfg(test)]smoke test that exercises its single obviousoperation (
BarrierState::wait_until_idleunblocks afterdecrement_inflight,SlotData::lock_slot+into_slotround-trip,SlotHandle::newbumpsthe entry's counter and exposes
lock_slot).The existing
SlotBarrier,DecrementGuard, and mod-levelSlotHandleremain unchanged. The spin-then-yield workaround at
finish_fileisuntouched (DG-4 removes it once DG-3.d lands).
Subsequent steps:
Arc<SlotBarrier>toSlotEntryand updatesregister_file,slot_for,flush_workers.DecrementGuard.barriertoArc<BarrierState>andfolds the post-split
SlotHandleinto the mod-level slot, attachingthe
_decrementfield.finish_filetoArc::try_unwrap(entry.data)and removes the spin loop.
Test plan
macOS, Windows) with the new types present but uncalled.
dg_3a_testsin the nextestjob (
barrier_state_wait_until_idle_returns_after_decrement,slot_data_lock_then_into_slot,slot_handle_constructor_increments_inflight).new doc comments or
#[allow(dead_code)]placement.