Repository navigation
feat(engine): DeletePlan, DeletePlanMap, DirTraversalCursor for parallel deterministic delete (#2253, #2254) - #4259
Merged
Conversation
…2254) Adds the data-structure foundation for the parallel-deterministic-delete pipeline described in docs/design/parallel-deterministic-delete.md (PR #4257). Three new modules under crates/engine/src/delete/: - plan.rs: DeletePlan (sorted, frozen per-directory work item), DeleteEntry, DeleteEntryKind (mirrors DeleteStats buckets), and a HardlinkCohortId newtype. sort_by_name() uses upstream's f_name_cmp (PR #4256) ascending then reverses, matching delete_in_dir's loop at generator.c:320. - plan_map.rs: DeletePlanMap, the publish-once concurrent rendezvous between phase-1 workers and the phase-2 emitter. Backed by Mutex<HashMap> for now; bench-driven choice between Mutex, DashMap, and a sharded map is deferred to task DDP-B4 (see code comment). - traversal.rs: DirTraversalCursor, yields directories in upstream's depth-first f_name_cmp-ascending order. Tree built from observed flist segments via observe_segment(); next_ready() returns the next directory whose parent has been emitted. Pure data structures, no callers; phase-1 and phase-2 wiring lands in later tasks (#2255-#2278). Unit tests cover plan ordering, concurrent inserts and takes from 16 threads, out-of-order segment observation, non-directory filtering, duplicate observations, and high-byte basename ordering on Unix.
…t_ready Splits the frame inspection from the mutation so the mutable borrow of the top frame is released before pushing a new frame or popping the old one. Functionally equivalent.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
…lel deterministic delete (#2253, #2254) (#4259) * feat(engine): DeletePlan, DeletePlanMap, DirTraversalCursor (#2253, #2254) Adds the data-structure foundation for the parallel-deterministic-delete pipeline described in docs/design/parallel-deterministic-delete.md (PR #4257). Three new modules under crates/engine/src/delete/: - plan.rs: DeletePlan (sorted, frozen per-directory work item), DeleteEntry, DeleteEntryKind (mirrors DeleteStats buckets), and a HardlinkCohortId newtype. sort_by_name() uses upstream's f_name_cmp (PR #4256) ascending then reverses, matching delete_in_dir's loop at generator.c:320. - plan_map.rs: DeletePlanMap, the publish-once concurrent rendezvous between phase-1 workers and the phase-2 emitter. Backed by Mutex<HashMap> for now; bench-driven choice between Mutex, DashMap, and a sharded map is deferred to task DDP-B4 (see code comment). - traversal.rs: DirTraversalCursor, yields directories in upstream's depth-first f_name_cmp-ascending order. Tree built from observed flist segments via observe_segment(); next_ready() returns the next directory whose parent has been emitted. Pure data structures, no callers; phase-1 and phase-2 wiring lands in later tasks (#2255-#2278). Unit tests cover plan ordering, concurrent inserts and takes from 16 threads, out-of-order segment observation, non-directory filtering, duplicate observations, and high-byte basename ordering on Unix. * fix(engine): avoid borrow-checker conflict in DirTraversalCursor::next_ready Splits the frame inspection from the mutation so the mutable borrow of the top frame is released before pushing a new frame or popping the old one. Functionally equivalent.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
…lel deterministic delete (#2253, #2254) (#4259) * feat(engine): DeletePlan, DeletePlanMap, DirTraversalCursor (#2253, #2254) Adds the data-structure foundation for the parallel-deterministic-delete pipeline described in docs/design/parallel-deterministic-delete.md (PR #4257). Three new modules under crates/engine/src/delete/: - plan.rs: DeletePlan (sorted, frozen per-directory work item), DeleteEntry, DeleteEntryKind (mirrors DeleteStats buckets), and a HardlinkCohortId newtype. sort_by_name() uses upstream's f_name_cmp (PR #4256) ascending then reverses, matching delete_in_dir's loop at generator.c:320. - plan_map.rs: DeletePlanMap, the publish-once concurrent rendezvous between phase-1 workers and the phase-2 emitter. Backed by Mutex<HashMap> for now; bench-driven choice between Mutex, DashMap, and a sharded map is deferred to task DDP-B4 (see code comment). - traversal.rs: DirTraversalCursor, yields directories in upstream's depth-first f_name_cmp-ascending order. Tree built from observed flist segments via observe_segment(); next_ready() returns the next directory whose parent has been emitted. Pure data structures, no callers; phase-1 and phase-2 wiring lands in later tasks (#2255-#2278). Unit tests cover plan ordering, concurrent inserts and takes from 16 threads, out-of-order segment observation, non-directory filtering, duplicate observations, and high-byte basename ordering on Unix. * fix(engine): avoid borrow-checker conflict in DirTraversalCursor::next_ready Splits the frame inspection from the mutation so the mutable borrow of the top frame is released before pushing a new frame or popping the old one. Functionally equivalent.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…lel deterministic delete (#2253, #2254) (#4259) * feat(engine): DeletePlan, DeletePlanMap, DirTraversalCursor (#2253, #2254) Adds the data-structure foundation for the parallel-deterministic-delete pipeline described in docs/design/parallel-deterministic-delete.md (PR #4257). Three new modules under crates/engine/src/delete/: - plan.rs: DeletePlan (sorted, frozen per-directory work item), DeleteEntry, DeleteEntryKind (mirrors DeleteStats buckets), and a HardlinkCohortId newtype. sort_by_name() uses upstream's f_name_cmp (PR #4256) ascending then reverses, matching delete_in_dir's loop at generator.c:320. - plan_map.rs: DeletePlanMap, the publish-once concurrent rendezvous between phase-1 workers and the phase-2 emitter. Backed by Mutex<HashMap> for now; bench-driven choice between Mutex, DashMap, and a sharded map is deferred to task DDP-B4 (see code comment). - traversal.rs: DirTraversalCursor, yields directories in upstream's depth-first f_name_cmp-ascending order. Tree built from observed flist segments via observe_segment(); next_ready() returns the next directory whose parent has been emitted. Pure data structures, no callers; phase-1 and phase-2 wiring lands in later tasks (#2255-#2278). Unit tests cover plan ordering, concurrent inserts and takes from 16 threads, out-of-order segment observation, non-directory filtering, duplicate observations, and high-byte basename ordering on Unix. * fix(engine): avoid borrow-checker conflict in DirTraversalCursor::next_ready Splits the frame inspection from the mutation so the mutable borrow of the top frame is released before pushing a new frame or popping the old one. Functionally equivalent.
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
Adds the data-structure foundation for the parallel-deterministic-delete
pipeline (DDP-A3, DDP-A4) described in
docs/design/parallel-deterministic-delete.md(PR #4257). Three newmodules under
crates/engine/src/delete/. Pure types; no callers yet(phase-1 and phase-2 wiring lands in #2255-#2278).
plan.rs-DeletePlan(sorted, frozen per-directory work item),DeleteEntry,DeleteEntryKind(mirrorsDeleteStatsbuckets), anda
HardlinkCohortIdnewtype.sort_by_name()uses upstream'sf_name_cmp(PR feat(protocol): port upstream f_name_cmp byte-wise name comparator (#2252) #4256) ascending then reverses in place, matchingdelete_in_dir's decrementing loop (generator.c:320).plan_map.rs-DeletePlanMap, the publish-once concurrentrendezvous between phase-1 workers and the phase-2 emitter. API:
insert,take,is_empty,len,contains.traversal.rs-DirTraversalCursor, yields directories inupstream's depth-first
f_name_cmp-ascending order. Backed by atree built from observed flist segments via
observe_segment();next_ready()returns the next directory whose parent has beenemitted (or the root on the first call).
Concurrent-Map Choice
DeletePlanMapis backed bystd::sync::Mutex<HashMap<PathBuf, DeletePlan>>.This is the simplest correct backing store:
enginecrate. The workspace'sdashmapcrate is already available (
Cargo.toml:203), but pulling it intoengineenlarges compile time and dependency surface for a modulethat has no measured bottleneck yet.
so contention is short-lived with at most rayon-worker-count
concurrent writers and one reader.
The bench-driven choice between
Mutex<HashMap>,dashmap::DashMap,and a sharded
HashMapis deferred to task DDP-B4 with a code-commentpointer. The inner type can be swapped without changing the public
surface.
Modules Added
crates/engine/src/delete/mod.rscrates/engine/src/delete/plan.rscrates/engine/src/delete/plan_map.rscrates/engine/src/delete/traversal.rspub mod delete;wired intocrates/engine/src/lib.rs.Test plan
macOS, Linux musl).
plan.rsunit tests:HardlinkCohortIdroundtrip.DeleteEntryKind::from_file_typecovers everyFileTypevariant.DeleteEntry::newandDeleteEntry::with_cohortset the cohortfield correctly.
DeletePlan::newis empty, unsorted;pushresets the sortedflag.
sort_by_nameproducesf_name_cmpascending then reversed(descending for plain ASCII).
only (no kind-based reordering).
ascending_ordermatchesf_name_cmpforLess,Greater,Equal.from_extrasaccepts a pre-builtVecand remains unsorted.plan_map.rsunit tests:new_map_is_empty,with_capacitypreallocation.insertthentakeroundtrips.takeof a missing key returnsNone.insertdisplaces the previous value and returns it.takeacross 8 threads drains every plan exactly once.traversal.rsunit tests:f_name_cmpascending order.f_name_cmporder for the (root, a/, a/x/, a/y/, b/) tree.unsigned byte order.