Skip to content

feat(engine): migrate ParallelDeltaApplier files map to SlotEntry (DG-3.b) - #4841

Merged
oferchen merged 2 commits into
masterfrom
feat/dg-3b-files-map-slotentry
May 24, 2026
Merged

oferchen merged 2 commits into
masterfrom
feat/dg-3b-files-map-slotentry

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

DG-3.b of the Option-B migration. Swaps the ParallelDeltaApplier::files
DashMap value type from Arc<SlotBarrier> to SlotEntry (the carrier
type DG-3.a introduced in PR #4826). Keeps DecrementGuard and the
mod-level SlotHandle on their existing Arc<SlotBarrier> field
types so the structural race fix lands as an isolated, bisectable
DG-3.c change.

Sequenced per docs/design/dg-2b-migration-order.md step DG-3.b.

Bridge layer (intentional)

SlotBarrier is reshaped into a thin transitional adapter that wraps
shared Arc<SlotData> + Arc<BarrierState> handles cloned from a
SlotEntry. slot_for mints a fresh Arc<SlotBarrier> adapter per
call via SlotBarrier::from_entry; every adapter for the same file
shares the same underlying counter, Condvar, and per-file mutex, so
the FFB-1 in-flight bookkeeping and FFB-2 barrier semantics are
unchanged.

The adapter exists only so DecrementGuard.barrier: Arc<SlotBarrier>
and SlotHandle.barrier: Arc<SlotBarrier> keep their field types
intact this PR. DG-3.c retypes those fields to the inner Arcs
directly and deletes the adapter.

Call-site retargets

  • register_file: builds SlotEntry::new(...) (no outer Arc::new).
  • slot_for: clones the entry, builds the adapter Arc, returns
    SlotHandle::new(barrier) with the existing signature.
  • flush_workers: clones entry.barrier (Arc<BarrierState>) and
    calls wait_until_idle on it directly.
  • finish_file: retargets the spin-then-yield loop and
    Arc::try_unwrap onto entry.data (Arc<SlotData>); the spin loop
    body is preserved verbatim per the DG-2.b plan. entry.barrier is
    dropped explicitly before the spin so only DecrementGuard clones
    keep the bookkeeping Arc alive.
  • flush_workers_survives_spurious_wakeup test: snapshots
    entry.barrier instead of the previous combined Arc; the manual
    notify_all() call now resolves to BarrierState::notify.

Tests

The concurrent_register_and_dispatch_on_overlapping_files stress
test (PR #4667's SSC-1 regression guard) and every other
parallel_apply::tests::* case exercise the public surface only and
are unaffected by the bridge. The flush_workers_survives_spurious_wakeup
test was updated to use the new entry-access path.

Linked work

  • DG-3.a (feat(engine): add BarrierState + SlotData types per DG-2.a spec (DG-3.a) #4826): added BarrierState, SlotData, SlotEntry,
    post-split SlotHandle alongside SlotBarrier.
  • DG-3.c (next): retype DecrementGuard.barrier and SlotHandle to
    hold Arc<BarrierState> / Arc<SlotData> directly; delete the
    transitional adapter. This is the structural race fix step.
  • DG-4: delete the finish_file spin loop once DG-3.e confirms the
    race window is closed.

Test plan

  • CI green on fmt + clippy
  • CI green on nextest (stable) covering
    parallel_apply::tests::* and
    parallel_apply_concurrent::*
  • CI green on Windows / macOS / Linux musl matrices

@github-actions github-actions Bot added the enhancement New feature or request label May 24, 2026
oferchen added 2 commits May 24, 2026 10:35
…-3.b)

Swap the per-file DashMap value type in `ParallelDeltaApplier` from
`Arc<SlotBarrier>` to the DG-3.a `SlotEntry` (carrying `Arc<SlotData>`
+ `Arc<BarrierState>`). Keep `DecrementGuard` and the mod-level
`SlotHandle` on their existing `Arc<SlotBarrier>` field types so the
race-fix step (DG-3.c) lands as an isolated, bisectable change.

`SlotBarrier` is reshaped into a thin transitional adapter that wraps
shared `Arc<SlotData>` + `Arc<BarrierState>` handles cloned from a
`SlotEntry`. Adapters are minted on demand by `slot_for` via
`SlotBarrier::from_entry`; every adapter for the same file shares the
same underlying counter, Condvar, and per-file mutex, so the FFB-1
in-flight bookkeeping and FFB-2 barrier semantics are unchanged.

`finish_file` retargets the spin-then-yield loop and `Arc::try_unwrap`
from the (now-removed) combined Arc onto the entry's payload Arc
(`entry.data`). The spin loop stays verbatim per the DG-2.b phasing
plan; DG-3.c retires the adapter and DG-4 deletes the spin once
DG-3.e's stress test confirms the race window is closed structurally.

`flush_workers` reads `entry.barrier` (`Arc<BarrierState>`) directly,
and the `flush_workers_survives_spurious_wakeup` test pokes the
shared Condvar through the same path. The `concurrent_register_and_dispatch`
stress test exercises the public surface and is unaffected.

Sequenced per `docs/design/dg-2b-migration-order.md` step DG-3.b.
@oferchen
oferchen force-pushed the feat/dg-3b-files-map-slotentry branch from 4651473 to 2576198 Compare May 24, 2026 07:35
@oferchen
oferchen merged commit 4a4769f into master 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.
@oferchen
oferchen deleted the feat/dg-3b-files-map-slotentry branch May 28, 2026 03:37
oferchen added a commit that referenced this pull request Aug 24, 2026
…-3.b) (#4841)

* feat(engine): migrate ParallelDeltaApplier files map to SlotEntry (DG-3.b)

Swap the per-file DashMap value type in `ParallelDeltaApplier` from
`Arc<SlotBarrier>` to the DG-3.a `SlotEntry` (carrying `Arc<SlotData>`
+ `Arc<BarrierState>`). Keep `DecrementGuard` and the mod-level
`SlotHandle` on their existing `Arc<SlotBarrier>` field types so the
race-fix step (DG-3.c) lands as an isolated, bisectable change.

`SlotBarrier` is reshaped into a thin transitional adapter that wraps
shared `Arc<SlotData>` + `Arc<BarrierState>` handles cloned from a
`SlotEntry`. Adapters are minted on demand by `slot_for` via
`SlotBarrier::from_entry`; every adapter for the same file shares the
same underlying counter, Condvar, and per-file mutex, so the FFB-1
in-flight bookkeeping and FFB-2 barrier semantics are unchanged.

`finish_file` retargets the spin-then-yield loop and `Arc::try_unwrap`
from the (now-removed) combined Arc onto the entry's payload Arc
(`entry.data`). The spin loop stays verbatim per the DG-2.b phasing
plan; DG-3.c retires the adapter and DG-4 deletes the spin once
DG-3.e's stress test confirms the race window is closed structurally.

`flush_workers` reads `entry.barrier` (`Arc<BarrierState>`) directly,
and the `flush_workers_survives_spurious_wakeup` test pokes the
shared Condvar through the same path. The `concurrent_register_and_dispatch`
stress test exercises the public surface and is unaffected.

Sequenced per `docs/design/dg-2b-migration-order.md` step DG-3.b.

* fix(engine): drop unused SlotBarrier::wait_until_idle adapter (DG-3.b)
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant