Skip to content

fix: order local -vv notices and names as upstream prints them - #8324

Merged
oferchen merged 1 commit into
masterfrom
feat/local-progress-order
Nov 4, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/local-progress-order

Conversation

@oferchen

@oferchen oferchen commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

A local -vv copy now prints its is uptodate and skip notices interleaved with the transferred names the way rsync 3.5.1 does. That holds with and without --progress.

Before this change:

  • Under --progress, oc printed each line as the copy walked: aaa came before bbb is uptodate.
  • Without --progress, oc put every notice before every name.

Upstream does neither. It runs a generator and a sender:

  • The generator prints a notice the moment it checks the entry (generator.c:1154, rsync.c:828).
  • It itemizes every other entry to the sender, and those requests wait in its output buffer.
  • The buffer flushes when the generator blocks waiting for a list the sender has not sent yet (generator.c:2830-2841, io.c:1958 wait_for_receiver()), and at the end.
  • The sender sends sub-lists ahead while fewer than 1000 entries are queued (sender.c:515-547).

So on a large tree the notices and names come out window by window.

How

  • One ordering function, core::client::listing_order(events, inc_recurse).
    • It walks a local copy's lists depth-first. Each directory is itemized at the start of its own list, under the gap NDX (generator.c:2780-2790).
    • Notices print at once. Names wait until the walk reaches a list the lookahead has not sent.
    • Late hard-link aliases still come last (hlink.c:250-251).
  • The lookahead is protocol's planner, not a copy of it. SubListPlan::lookahead_schedule now runs on a new incremental SubListLookahead, which the ordering function also drives one request at a time.
  • Both output paths use it:
    • The post-hoc -v/-vv render, via ClientSummary::listing_order(). It replaces the bucket sort in emit_verbose.
    • The live --progress forwarder. It already runs a dry-run preview of the copy. It now takes the preview's notices in upstream order, releases them just before the first name upstream prints after them, and drops the live duplicates. The live renderer writes held-back entry lines before a notice, so the forwarder's order reaches the terminal unchanged.
  • Classification moved to core. The generator-notice and late-hard-link predicates moved from the CLI renderer to ClientEvent (is_generator_notice, is_deferred_hardlink, is_hardlinked_symlink), so the core function and the CLI share them.
  • One INC_RECURSE resolution. ClientConfig::local_inc_recurse() replaces the inline expression that the summary banner used, and the ordering uses the same call.

Remote transfers are unchanged: their summary keeps the single-list order.

Evidence

Order signatures (names verbatim, runs of notices as [nU]) against the tarball 3.5.1 build, -r -t -vv, both with and without --progress:

tree 3.5.1 oc before oc after
3 flat files, 1 transferred [2U] aaa (10/10) aaa [2U] under --progress [2U] aaa
5 files with a sub-list, 1 transferred [4U] d/ccc (10/10) [3U] d/ccc [1U] under --progress [4U] d/ccc
3 dirs x 500 [996U] x/f001 x/f075 y/f001 y/f075 [498U] z/f001 z/f075 (15/15) [1494U] ... same as 3.5.1
4 dirs x 700 [1396U] a.. b.. [1396U] c.. d.. [2792U] ... same as 3.5.1
10 dirs x 150 [1036U] d01..d06 ... (15/15) [1480U] ... same as 3.5.1
1500 top-level files + 1 dir [1499U] f0002 f1499 sub/s2 (15/15) same same

Tests:

  • crates/cli/tests/local_listing_order.rs
    • Two always-on cells pin the flat, sub-list and 3x500 orders, with and without --progress. Both fail on master.
    • A 3.5.1 oracle cell compares full stdout for three trees under -vv, -vv --progress and -v --progress. Rate and ETA are masked. It drops three kinds of line that differ for other reasons: progress lines (task 579), the sent/total size trailer (task 158), and the sender's expand file_list pointer array debug lines (task 580).
  • core unit tests for listing_order: the flat case, the 3x500 windows, the single-list case, depth-first directory placement, and deletions.
  • cli live-progress test: a notice must not overtake a held-back entry line.
  • Mutations: see below.

Deviations, for a decision

  • Small trees race in upstream. Whether the next sub-list reaches the generator before it finishes the current list is a timing race between upstream's processes. On the 5-file mixed tree, 3.5.1 printed [2U] aaa.txt [1U] d/ddd.txt 20/20 at load 12. An earlier run on a quieter host mostly gave the other order, [3U] aaa.txt d/ddd.txt. oc always takes the second: a list the lookahead has sent counts as arrived. The oracle cells use trees whose order does not depend on this race.
  • --no-inc-recursive large lists. Here upstream interleaves on output-buffer fill, e.g. [198U] x/f001 [398U] .... oc prints every notice first. Modelling the buffer means modelling upstream's byte counts per request, which this change does not do.

Mutations

Each mutation was applied to the branch and the targeted tests run (core listing_order, cli local_listing_order with the 3.5.1 oracle on, cli live-progress, protocol sub-list):

mutation result
never flush mid-walk killed: unit 3x500, e2e window cell, oracle
directory walked in its parent's list killed: unit depth-first cell
notices held like names killed: unit and e2e window cells
forwarder releases no notice before a name killed: e2e flat/sub-list and window cells, oracle
forwarder keeps the live notice too killed: e2e cells, oracle
live renderer lets a notice overtake held-back lines killed: live-progress unit cell
summary listed as one list killed: e2e window cell, oracle
forwarder ordered as one list killed: e2e window cell, oracle
no initial lookahead fill killed: unit and e2e window cells, oracle
list lookup's last-parent cache matches any parent killed: unit depth-first and 3x500 cells, e2e window cell, oracle
byte parent slice always empty (every entry top-level) killed: unit depth-first and 3x500 cells, e2e window cell, oracle
forwarder records a count only while no notice is queued killed: e2e flat/sub-list and window cells, oracle
lookahead drops sent < list survived, equivalent: while sent < list, file_total (sum of sent lists) is below file_old_total (sum through the request's list), so the 1000-entry clause already holds. The clause is the original planner's and stays as documentation of upstream's wait.

Overlaps

push-overlap.sh HEAD a2d8c5d17 reports two file-only overlaps:

Performance

Symbolized release builds (debug = 1, unstripped) of master (a2d8c5d) and this branch. Local copy of 10k small files, half up to date. RAYON_NUM_THREADS=1 so idle-worker spinning does not count. 11 interleaved rounds per binary; perf stat -e instructions:u. Median delta, branch vs master, with an A/A run of the same pair as the noise floor:

flags instructions:u A/B A/A
none +0.00% -0.01%
-vv +0.43% -0.01%
-v --progress +1.08% +0.00%
-vv --progress +1.10% -0.09%

No -v/--progress costs nothing: the ordering pass runs only when names print. What is left, from perf record self samples:

  • -vv: the ordering pass, about 190 instructions per entry (one parent-key hash with a last-parent cache, the depth-first rank, the lookahead window).
  • --progress: the ordering pass plus the forwarder's two preview maps (notice count before each entry, previewed notices). That is one OsString key allocation and one byte-key hash per entry, about 730 instructions per entry in all.

Profiling found and removed two costs. The ordering pass used Path::parent and component-wise Path equality and hashing; it now slices the path's encoded bytes at the last separator (+2.38% to +0.43% on -vv). The forwarder's maps were PathBuf-keyed, grew from empty and recorded entries with no notice queued; they are now byte-keyed, sized up front, and skip those entries (+3.04% to +1.08% on -v --progress).

Conventional commit prefix

fix:

@github-actions github-actions Bot added the bug Something isn't working label Nov 3, 2026
@oferchen
oferchen force-pushed the feat/local-progress-order branch from 4fde45e to 5723eac Compare November 3, 2026 22:23
A local copy now prints its "is uptodate" and skip notices interleaved
with the transferred names the way rsync 3.5.1 does, with and without
--progress. The generator prints a notice as it checks the entry, while
the names it itemizes to the sender wait until it reaches a list the
sender has not sent yet (generator.c:2830-2841, sender.c:515-547).

core::client::listing_order models that walk once: lists depth-first,
each directory itemized at the start of its own list, and the lookahead
driven through protocol's new SubListLookahead, which
SubListPlan::lookahead_schedule now uses too. The post-hoc listing and
the --progress forwarder both take their order from it; the forwarder
releases the dry-run preview's notices ahead of the first name upstream
prints after them.
@oferchen
oferchen force-pushed the feat/local-progress-order branch from 5723eac to 572c22a Compare November 4, 2026 01:01
@oferchen oferchen closed this Nov 4, 2026
@oferchen oferchen reopened this Nov 4, 2026
@oferchen
oferchen merged commit 671da20 into master Nov 4, 2026
73 of 125 checks passed
@oferchen
oferchen deleted the feat/local-progress-order branch November 4, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant