Skip to content

docs(engine): audit DecrementGuard/SlotBarrier release-race surface (DG-1) - #4744

Merged
oferchen merged 1 commit into
masterfrom
docs/dg-1-decrementguard-audit
May 22, 2026
Merged

oferchen merged 1 commit into
masterfrom
docs/dg-1-decrementguard-audit

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

DG-1 audit doc feeding the DG-2 restructure design and DG-3 implementation. Catalogues the Arc<SlotBarrier> + DecrementGuard surface in crates/engine/src/concurrent_delta/parallel_apply.rs and traces the wake-before-Arc-drop race that the spin-then-yield workaround at parallel_apply.rs:729-748 papers over.

Adds docs/design/decrementguard-audit.md (329 lines). No code touched.

The doc covers:

  • 7 Arc<SlotBarrier> clone sites (5 production, 2 test) with file:line, holder, lifetime, release path.
  • The single DecrementGuard construction site at parallel_apply.rs:394 and the single SlotHandle::new site at parallel_apply.rs:847.
  • Condvar notify trace: only production fire site is decrement_inflight at parallel_apply.rs:340, inside DecrementGuard::drop.
  • Race-window walkthrough: why notify_all fires before the implicit field-drop of DecrementGuard.barrier, and why Arc::try_unwrap at parallel_apply.rs:749 observes strong_count = 2 on Windows.
  • Spin-then-yield cite: comment block parallel_apply.rs:720-728, loop at 729-748, origin commit 3e5d83d95dc6 (PR feat(engine): add flush_workers/drain_inflight barrier API to ParallelDeltaApplier (FFB-2) #4665).
  • Platform observability: Windows reliably, macOS intermittently (timing tests, not the unwrap), Linux not yet observed; cross-references to the concurrent_register_and_dispatch_on_overlapping_files flake.
  • Six restructure paths (A-F) with pros, cons, and per-site blast radius so DG-2 can pick.
  • Per-option call-site change table mapped back to the audit so DG-3 can scope the diff.

Recommendation for DG-2: split SlotBarrier into BarrierState + SlotData (Option B) for the smallest contained diff, or move to an Arc-drop wait list (Option D) for cleaner semantics at the cost of touching the diagnostic counter story.

Test plan

  • Doc is 200-400 lines (329).
  • No code paths touched (docs/design/decrementguard-audit.md only).
  • All file:line citations verified against current master HEAD.
  • Restructure options enumerated without picking; DG-2 owns the decision.

…DG-1)

Catalogues the Arc<SlotBarrier> clone sites, the single DecrementGuard
construction site, the Condvar notify ordering, and the 1000-iteration
spin-then-yield workaround in ParallelDeltaApplier::finish_file. Enumerates
six restructure paths with per-site blast radius so DG-2 can pick a clean
fix and DG-3 can scope the diff. Pure documentation; no code touched.
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 22, 2026
@oferchen
oferchen merged commit eaae5c8 into master May 22, 2026
10 checks passed
@oferchen
oferchen deleted the docs/dg-1-decrementguard-audit branch May 28, 2026 03:37
oferchen added a commit that referenced this pull request Aug 24, 2026
…DG-1) (#4744)

Catalogues the Arc<SlotBarrier> clone sites, the single DecrementGuard
construction site, the Condvar notify ordering, and the 1000-iteration
spin-then-yield workaround in ParallelDeltaApplier::finish_file. Enumerates
six restructure paths with per-site blast radius so DG-2 can pick a clean
fix and DG-3 can scope the diff. Pure documentation; no code touched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant