Skip to content

remote: use deques for the RPC call queues, fixes #10450 - #10457

Merged
ThomasWaldmann merged 1 commit into
borgbackup:1.2-maintfrom
ThomasWaldmann:remote-deque-10450-1.2
Sep 28, 2026
Merged

ThomasWaldmann merged 1 commit into
borgbackup:1.2-maintfrom
ThomasWaldmann:remote-deque-10450-1.2

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

Backport of #10454 to 1.2-maint, fixes #10450.

RemoteRepository.call_many took the next call from the front of a list (calls.pop(0), self.preload_ids.pop(0)), which moves all remaining entries each time. For a single item with millions of chunks, extract from a remote repository was therefore quadratic in its chunk count. This PR uses collections.deque with popleft() for calls, waiting_for and preload_ids.

The change is the same as in #10454. It was applied by hand because call_many is indented differently on 1.2-maint.

Measurements

Measured on a Ryzen 5 8500GE (Zen 4), Python 3.13. The repo was created with borg 1.2 (repokey-blake2, lz4) and holds one stdin item of 1 M unique 4 KiB chunks (fixed,4096). The command is borg extract --stdout ::a big, from ssh://__testsuite__/... for the remote case.

1 M chunks wall
local 10.0 s
remote, this PR 15.4 s
remote, 1.2-maint 112.7 s

See #10454 for the full scaling series on 1.4-maint (same code, same behaviour).

Tests

pytest src/borg/testsuite/remote.py src/borg/testsuite/archiver.py -k "Remote or remote": 226 passed, 22 skipped.

🤖 Generated with Claude Code

RemoteRepository.call_many took the next call from the front of a list
(calls.pop(0), self.preload_ids.pop(0)), which moves all the remaining
entries each time. For a single item with millions of chunks (preload +
get_many over all of its chunk ids), that made extract from a remote
repository quadratic in the chunk count of the item.

Use collections.deque with popleft() for calls, waiting_for and
preload_ids.

Backport of borgbackup#10454.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ThomasWaldmann
ThomasWaldmann merged commit 5694ae8 into borgbackup:1.2-maint Sep 28, 2026
9 of 10 checks passed
@ThomasWaldmann
ThomasWaldmann deleted the remote-deque-10450-1.2 branch September 28, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant