Skip to content

feat: sender-side INC_RECURSE with optimized partitioning and lazy segment scheduling - #3038

Merged
oferchen merged 3 commits into
masterfrom
feature/sender-inc-recurse
Mar 28, 2026
Merged

oferchen merged 3 commits into
masterfrom
feature/sender-inc-recurse

Conversation

@oferchen

@oferchen oferchen commented Mar 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Implements sender-side INC_RECURSE with a clean 3-component architecture:

  • Partitioner (inc_recurse.rs): Classifies and reorders the file list for incremental recursion. Optimized with 1 HashMap + 2 dense Vecs (down from 4 HashMaps), TaggedIndex for O(1) node_id propagation, and move semantics via Option<T>::take() instead of clone.
  • SegmentScheduler (mod.rs): Cursor-based iterator over pending segments with MIN_FILECNT_LOOKAHEAD throttling, matching upstream sender.c:227,261 cadence.
  • Segment Encoder (protocol_io.rs): Single-segment wire encoding extracted from the previous 80-line god method for SRP compliance.

Key changes

  • Sub-list sending moved from before the transfer loop into the loop body for lazy interleaving (upstream-compatible cadence)
  • wire_to_flat_ndx() fixed to use partition_point (O(log n)) matching flat_to_wire_ndx()
  • Daemon capability string passes allow_inc_recurse=true (safe - daemon mode disables INC_RECURSE via compat negotiation per upstream compat.c:163-178)
  • SSH capability string remains allow_inc_recurse=false (hardlink interop not validated)

Wire compatibility

  • dir_ndx values match upstream receiver's dir_flist growth order exactly
  • Phase 1: initial list dirs (including ".") get indices 0..N in sorted order
  • Phase 2: sub-list dirs get indices N.. in depth-first reception order
  • NDX_FLIST_OFFSET framing and NDX_FLIST_EOF termination match upstream

Test plan

  • CI fmt + clippy passes
  • CI nextest passes (all platforms)
  • CI interop passes (daemon push/pull, all upstream versions)
  • Verify no regression in SSH transfers (INC_RECURSE still disabled)

@github-actions github-actions Bot added the enhancement New feature or request label Mar 28, 2026
@oferchen oferchen changed the title feat: enable sender-side INC_RECURSE for push transfers feat: add MIN_FILECNT_LOOKAHEAD constant for sender INC_RECURSE Mar 28, 2026
@oferchen
oferchen force-pushed the feature/sender-inc-recurse branch 2 times, most recently from 5c361cd to 7f8e5a2 Compare March 28, 2026 20:59
@oferchen oferchen changed the title feat: add MIN_FILECNT_LOOKAHEAD constant for sender INC_RECURSE fix: correct INC_RECURSE dir_ndx alignment with upstream receiver Mar 28, 2026
@github-actions github-actions Bot added the bug Something isn't working label Mar 28, 2026
Enable incremental recursion when our client is the sender (push mode),
both for SSH and daemon transfer paths.

Fix two bugs in the generator's file list partitioner that caused
upstream receiver dirname validation to reject entries:

1. The "." entry was not counted when assigning wire dir_ndx values,
   causing all subsequent indices to be off by one vs the receiver's
   dir_flist growth order.

2. Nested directory dir_ndx values were assigned in sorted file-list
   order rather than depth-first reception order, mismatching the
   receiver's dir_flist append sequence.

The fix uses a two-phase wire dir_ndx assignment that mirrors upstream's
dir_flist construction: Phase 1 assigns indices to initial list dirs
(including "."), Phase 2 assigns indices to nested dirs in depth-first
traversal order as sub-lists are processed.

upstream: flist.c:recv_file_list() line 2643 - dir_flist append order
upstream: flist.c:send_extra_file_list() - sub-list framing protocol
@oferchen
oferchen force-pushed the feature/sender-inc-recurse branch from 7f8e5a2 to 8174742 Compare March 28, 2026 21:10
Extract the monolithic send_extra_file_lists() into three focused
components following the architecture design:

- SegmentScheduler: cursor-based iterator with MIN_FILECNT_LOOKAHEAD
  throttling, matching upstream sender.c:227,261 cadence
- encode_and_send_segment(): single-segment wire encoding extracted
  from the god method (SRP compliance)
- Transfer loop integration: sub-list sending moved from step 6
  (before loop) into the loop body for lazy interleaving

Additional fixes:
- wire_to_flat_ndx() now uses partition_point (O(log n)) matching
  flat_to_wire_ndx(), replacing the linear reverse scan
- Removed dead send_flist_eof_if_inc_recurse() method
- Cleaned up stale doc references to send_extra_file_lists()
@oferchen oferchen changed the title fix: correct INC_RECURSE dir_ndx alignment with upstream receiver feat: sender-side INC_RECURSE with optimized partitioning and lazy segment scheduling Mar 28, 2026
@oferchen
oferchen merged commit b6f4765 into master Mar 28, 2026
40 of 41 checks passed
@oferchen
oferchen deleted the feature/sender-inc-recurse branch March 28, 2026 23:49
oferchen added a commit that referenced this pull request May 1, 2026
…gment scheduling (#3038)

* feat: enable sender-side INC_RECURSE for push transfers

Enable incremental recursion when our client is the sender (push mode),
both for SSH and daemon transfer paths.

Fix two bugs in the generator's file list partitioner that caused
upstream receiver dirname validation to reject entries:

1. The "." entry was not counted when assigning wire dir_ndx values,
   causing all subsequent indices to be off by one vs the receiver's
   dir_flist growth order.

2. Nested directory dir_ndx values were assigned in sorted file-list
   order rather than depth-first reception order, mismatching the
   receiver's dir_flist append sequence.

The fix uses a two-phase wire dir_ndx assignment that mirrors upstream's
dir_flist construction: Phase 1 assigns indices to initial list dirs
(including "."), Phase 2 assigns indices to nested dirs in depth-first
traversal order as sub-lists are processed.

upstream: flist.c:recv_file_list() line 2643 - dir_flist append order
upstream: flist.c:send_extra_file_list() - sub-list framing protocol

* refactor: decompose INC_RECURSE sending into scheduler + encoder

Extract the monolithic send_extra_file_lists() into three focused
components following the architecture design:

- SegmentScheduler: cursor-based iterator with MIN_FILECNT_LOOKAHEAD
  throttling, matching upstream sender.c:227,261 cadence
- encode_and_send_segment(): single-segment wire encoding extracted
  from the god method (SRP compliance)
- Transfer loop integration: sub-list sending moved from step 6
  (before loop) into the loop body for lazy interleaving

Additional fixes:
- wire_to_flat_ndx() now uses partition_point (O(log n)) matching
  flat_to_wire_ndx(), replacing the linear reverse scan
- Removed dead send_flist_eof_if_inc_recurse() method
- Cleaned up stale doc references to send_extra_file_lists()

* style: remove trailing blank line in SegmentScheduler impl
oferchen added a commit that referenced this pull request May 5, 2026
…gment scheduling (#3038)

* feat: enable sender-side INC_RECURSE for push transfers

Enable incremental recursion when our client is the sender (push mode),
both for SSH and daemon transfer paths.

Fix two bugs in the generator's file list partitioner that caused
upstream receiver dirname validation to reject entries:

1. The "." entry was not counted when assigning wire dir_ndx values,
   causing all subsequent indices to be off by one vs the receiver's
   dir_flist growth order.

2. Nested directory dir_ndx values were assigned in sorted file-list
   order rather than depth-first reception order, mismatching the
   receiver's dir_flist append sequence.

The fix uses a two-phase wire dir_ndx assignment that mirrors upstream's
dir_flist construction: Phase 1 assigns indices to initial list dirs
(including "."), Phase 2 assigns indices to nested dirs in depth-first
traversal order as sub-lists are processed.

upstream: flist.c:recv_file_list() line 2643 - dir_flist append order
upstream: flist.c:send_extra_file_list() - sub-list framing protocol

* refactor: decompose INC_RECURSE sending into scheduler + encoder

Extract the monolithic send_extra_file_lists() into three focused
components following the architecture design:

- SegmentScheduler: cursor-based iterator with MIN_FILECNT_LOOKAHEAD
  throttling, matching upstream sender.c:227,261 cadence
- encode_and_send_segment(): single-segment wire encoding extracted
  from the god method (SRP compliance)
- Transfer loop integration: sub-list sending moved from step 6
  (before loop) into the loop body for lazy interleaving

Additional fixes:
- wire_to_flat_ndx() now uses partition_point (O(log n)) matching
  flat_to_wire_ndx(), replacing the linear reverse scan
- Removed dead send_flist_eof_if_inc_recurse() method
- Cleaned up stale doc references to send_extra_file_lists()

* style: remove trailing blank line in SegmentScheduler impl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant