Repository navigation
feat(protocol): port upstream f_name_cmp byte-wise name comparator (#2252) - #4256
Merged
Merged
Conversation
…2252) Adds a foundational `f_name_cmp` that compares two `FileEntry` values by `(dirname, basename)` in unsigned byte order, mirroring upstream rsync's `flist.c:f_name_cmp()`. Bytes with the high bit set sort after ASCII; no locale awareness, no case folding, no protocol-29 file-vs-directory disambiguation (that logic stays in `sort.rs`). This is the sort key the parallel-deterministic-delete pipeline needs to merge candidate lists with byte-identical ordering to upstream's pre-sort scan. Wiring callers over to this comparator is left to follow-up tasks. Includes a `name_cmp_eq` helper that tolerates a single trailing `/` on the basename to mirror upstream's implicit directory-slash equivalence, and a components-only `f_name_cmp_components` helper for callers and fuzzers that already hold dirname/basename byte slices. Unit tests cover ASCII ordering, same-basename/different-dirname, high-byte unsigned order (>= 0x80), dot/double-dot, hidden dotfiles, embedded slashes, deep nesting, and the file-vs-dir byte-only fold. Proptest covers reflexivity, antisymmetry, transitivity, and agreement with the components helper. Upstream references: - flist.c:3197 enum fnc_state - flist.c:3198 enum fnc_type - flist.c:3217-3334 f_name_cmp() - flist.c:3331 (int)*c1++ - (int)*c2++ (unsigned byte compare)
4 tasks
oferchen
added a commit
that referenced
this pull request
May 17, 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
…2252) (#4256) Adds a foundational `f_name_cmp` that compares two `FileEntry` values by `(dirname, basename)` in unsigned byte order, mirroring upstream rsync's `flist.c:f_name_cmp()`. Bytes with the high bit set sort after ASCII; no locale awareness, no case folding, no protocol-29 file-vs-directory disambiguation (that logic stays in `sort.rs`). This is the sort key the parallel-deterministic-delete pipeline needs to merge candidate lists with byte-identical ordering to upstream's pre-sort scan. Wiring callers over to this comparator is left to follow-up tasks. Includes a `name_cmp_eq` helper that tolerates a single trailing `/` on the basename to mirror upstream's implicit directory-slash equivalence, and a components-only `f_name_cmp_components` helper for callers and fuzzers that already hold dirname/basename byte slices. Unit tests cover ASCII ordering, same-basename/different-dirname, high-byte unsigned order (>= 0x80), dot/double-dot, hidden dotfiles, embedded slashes, deep nesting, and the file-vs-dir byte-only fold. Proptest covers reflexivity, antisymmetry, transitivity, and agreement with the components helper. Upstream references: - flist.c:3197 enum fnc_state - flist.c:3198 enum fnc_type - flist.c:3217-3334 f_name_cmp() - flist.c:3331 (int)*c1++ - (int)*c2++ (unsigned byte compare)
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
…2252) (#4256) Adds a foundational `f_name_cmp` that compares two `FileEntry` values by `(dirname, basename)` in unsigned byte order, mirroring upstream rsync's `flist.c:f_name_cmp()`. Bytes with the high bit set sort after ASCII; no locale awareness, no case folding, no protocol-29 file-vs-directory disambiguation (that logic stays in `sort.rs`). This is the sort key the parallel-deterministic-delete pipeline needs to merge candidate lists with byte-identical ordering to upstream's pre-sort scan. Wiring callers over to this comparator is left to follow-up tasks. Includes a `name_cmp_eq` helper that tolerates a single trailing `/` on the basename to mirror upstream's implicit directory-slash equivalence, and a components-only `f_name_cmp_components` helper for callers and fuzzers that already hold dirname/basename byte slices. Unit tests cover ASCII ordering, same-basename/different-dirname, high-byte unsigned order (>= 0x80), dot/double-dot, hidden dotfiles, embedded slashes, deep nesting, and the file-vs-dir byte-only fold. Proptest covers reflexivity, antisymmetry, transitivity, and agreement with the components helper. Upstream references: - flist.c:3197 enum fnc_state - flist.c:3198 enum fnc_type - flist.c:3217-3334 f_name_cmp() - flist.c:3331 (int)*c1++ - (int)*c2++ (unsigned byte compare)
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
…2252) (#4256) Adds a foundational `f_name_cmp` that compares two `FileEntry` values by `(dirname, basename)` in unsigned byte order, mirroring upstream rsync's `flist.c:f_name_cmp()`. Bytes with the high bit set sort after ASCII; no locale awareness, no case folding, no protocol-29 file-vs-directory disambiguation (that logic stays in `sort.rs`). This is the sort key the parallel-deterministic-delete pipeline needs to merge candidate lists with byte-identical ordering to upstream's pre-sort scan. Wiring callers over to this comparator is left to follow-up tasks. Includes a `name_cmp_eq` helper that tolerates a single trailing `/` on the basename to mirror upstream's implicit directory-slash equivalence, and a components-only `f_name_cmp_components` helper for callers and fuzzers that already hold dirname/basename byte slices. Unit tests cover ASCII ordering, same-basename/different-dirname, high-byte unsigned order (>= 0x80), dot/double-dot, hidden dotfiles, embedded slashes, deep nesting, and the file-vs-dir byte-only fold. Proptest covers reflexivity, antisymmetry, transitivity, and agreement with the components helper. Upstream references: - flist.c:3197 enum fnc_state - flist.c:3198 enum fnc_type - flist.c:3217-3334 f_name_cmp() - flist.c:3331 (int)*c1++ - (int)*c2++ (unsigned byte compare)
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
f_name_cmp(&FileEntry, &FileEntry) -> Orderingincrates/protocol/src/flist/name_cmp.rs, mirroring upstreamflist.c:f_name_cmp()(flist.c:3217-3334). Comparison is(dirname, basename)in unsigned byte order - no locale, no case folding, no protocol-29 file-vs-dir disambiguation (that stays insort.rs).name_cmp_eq(folds a trailing/on basenames to mirror upstream's implicit directory-slash equivalence, flist.c:3206-3211) and af_name_cmp_componentscomponents-only helper for fuzzers/callers that already hold the dirname/basename byte pair.Upstream lines cited
enum fnc_state { s_DIR, s_SLASH, s_BASE, s_TRAILING }enum fnc_type { t_PATH, t_ITEM }f_name_cmp()(int)*c1++ - (int)*c2++- the unsigned byte compare/equivalence on directoriesTest plan