Repository navigation
legacy remote: use deques for the RPC call queues, fixes #10450 - #10456
Merged
ThomasWaldmann merged 1 commit intoSep 28, 2026
Merged
Conversation
…0450 LegacyRemoteRepository.call_many took the next call from the front of a list (calls.pop(0)), which moves all the remaining entries each time. get_many() passes all ids at once, so borg transfer --from-borg1 --chunker-params (which fetches all chunks of an item via fetch_many) from a remote borg 1.x repository was quadratic in the chunk count of the item. Use collections.deque with popleft() for calls and waiting_for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10456 +/- ##
==========================================
- Coverage 88.73% 88.72% -0.02%
==========================================
Files 103 103
Lines 19387 19388 +1
Branches 3023 3023
==========================================
- Hits 17204 17202 -2
- Misses 1514 1518 +4
+ Partials 669 668 -1 ☔ View full report in Codecov by Harness. |
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.
Fixes #10450 for master. #10454 is the 1.4-maint PR.
On master, borg2's own repository access has no such lists. The quadratic
calls.pop(0)only survives inLegacyRemoteRepository.call_many(src/borg/legacy/remote.py).get_many()passes all ids of afetch_many()at once, soborg transfer --from-borg1 --chunker-paramsfrom a remote (ssh://) borg 1.x repository was quadratic in the chunk count of an item. Plainborg transfer --from-borg1(without--chunker-params) fetches chunks one by one viaget(), so it is not affected.This PR uses
collections.dequewithpopleft()forcallsandwaiting_for.Measurements
Measured on a Ryzen 5 8500GE (Zen 4), Python 3.13. The source is a borg 1.4 repo (
repokey-blake2, lz4) with one stdin item of N unique 4 KiB chunks (fixed,4096). The data compresses to almost nothing. The command isborg transfer --other-repo SRC --from-borg1 --chunker-params fixed,4096 --compression lz4into a freshaes256-ocb/blake3repo. For remote runs, SRC isssh://__testsuite__//...(borg serveover pipes).The time master spends beyond this PR grows 3.3×, 3.9×, 4.4× and 9.7× per doubling (quadratic, worse once the list no longer fits in L3; the 4 M master run partly overlapped an unrelated build on the same box, so it may be a bit high). With this PR, remote transfer is linear at about 48 µs per chunk. The borg 1.4 client version in #10454 had a second front-popped list (
preload_ids) and was affected much more (1M chunks: 115 s vs 15.6 s).Tests
pytest src/borg/testsuite/legacyrepository_test.py src/borg/testsuite/repository_test.py src/borg/testsuite/archiver/transfer_cmd_test.py src/borg/testsuite/archiver/serve_cmd_test.py: 334 passed, 7 skipped.🤖 Generated with Claude Code