Repository navigation
checksum: send keepalives during file-list hashing - #1031
Conversation
…t#839) With --checksum the sender hashes every regular file while it builds the file list (flist.c calls file_checksum() from make_file()), and nothing is sent to the peer for as long as that takes. On a large file the far end therefore sees a silent link and aborts once --timeout elapses: rsync -a --checksum --timeout=3 rsync://host/mod/ dst/ [Receiver] io timeout after 4 seconds -- exiting rsync error: timeout in data send/receive (code 30) A single 2 GiB file reproduces it here (~4.3s to hash). The same transfer without --checksum, or with a --timeout longer than the hash, is fine, so it is purely the unbroken silence while hashing. Note it is driven by the time to hash one file, not by how many there are: 500,000 small files take 4.6s to hash in total and do *not* trip it, because list entries keep streaming out and the link never goes quiet. rsync already has the right primitive for this. maybe_send_keepalive() sends a MSG_NOOP and self-throttles on allowed_lull, which set_io_timeout() computes as half of --timeout -- exactly the "send something every half the threshold" interval this needs, at whatever timeout the user picked. The generator, sender and receiver already call it during their long stretches; the file-list hashing path simply never did. Tick it as we hash. file_checksum() had six copies of the same chunk loop (one per digest), so rather than add the call six times -- and leave a seventh digest free to forget it -- the loop is now a single CHECKSUM_FEED() macro carrying the tick. It takes the update as an expression because the digests have differing signatures; a function-pointer iterator would need a wrapper per digest and could not express the pre-27 MD4 tail, so each caller keeps its own trailing partial chunk handling unchanged. The tick is throttled by bytes hashed rather than fired per piece: the MD4 loop runs in CSUM_CHUNK (64) byte pieces, so a per-piece tick would consult the clock 16.7 million times per GiB -- 512x more often than the other digests. That measured +2.6% on an MD4 pass here (1.95s -> 2.00s for 1 GiB, matching the 2.9ns vDSO time() call), and would be far worse where time() is a real syscall. Consulting it once per CHUNK_SIZE of hashing puts every digest on the same footing and the cost back in the noise (1.94s). Verified digest-identical to the unpatched build in both directions (master sender vs patched receiver and vice versa) over files at the chunk boundaries -- 0, 1, 63, 64, 65, 32767, 32768, 32769, 65537 and multi-chunk sizes -- for every checksum-choice this build offers, with a flipped byte as a positive control. generate_and_send_sums() was checked for the same pattern and does not need it: it writes each block sum as it computes, so that link never goes quiet.
192c461 to
123576e
Compare
|
Follow-up: the keep-alive tick is now throttled by bytes hashed rather than fired once per piece. The first version called it from every loop iteration, which was fine for the digests that work in Measured on a 1 GiB file with
That +2.6% matches the arithmetic exactly —
Re-verified after the change: digest-identical to master in both directions across the chunk-boundary sizes, still fixes the hang at |
Refs #839
Summary
Send keepalives during file-list hashing on multiplexed streams. Client uploads using protocols below 30 are unchanged.