Repository navigation
fix(restore): bound the blob writes queued at once - #667
Open
stefanwichmann wants to merge 1 commit into
Open
stefanwichmann wants to merge 1 commit into
stefanwichmann wants to merge 1 commit into
Conversation
restore_contents queued a write task for every blob it decoded, and decoding runs far ahead of writing, so a restore held most of its data in memory: about 24 GiB for a 24 GiB file. On macOS 27 that memory pressure made concurrent writes lose the first partial block of a blob written beside its neighbour, zeroing it, while the restore reported success. At most MAX_PENDING_WRITES (20) writes are now queued; beyond that the task that decoded a blob writes it itself, so decoding cannot run ahead and no pool thread waits on another. Measured on a 16 GiB Apple silicon Mac with a 24 GiB file of 8 MiB blobs: unpatched restores zeroed bytes in every run; with this change 3 of 3 were byte-exact, and the restore took 14-17 s instead of 74-78 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: 968888b2-f42d-41c1-8ac4-262142c8a7c4
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.
Closes #666
What and why
restore_contentsspawned a write task for every blob it decoded, and decoding runs far ahead of writing. So a restore held most of its data in memory: about 24 GiB for a 24 GiB file. On macOS 27, that memory pressure made writes that run alongside each other lose the first partial 4 KiB block of a blob, while the restore reported success. #666 has the reproduction and measurements.At most
MAX_PENDING_WRITES(20) writes are now queued. Beyond that, the task that decoded a blob writes it itself. Decoding can no longer run ahead, peak buffer memory is bounded at about 20 blobs, and no pool thread ever blocks waiting for a slot, so the scope cannot deadlock however many packs are in flight.Measured
On a 16 GiB Apple silicon Mac, restoring a 24 GiB file of 8 MiB blobs:
Tests
cargo fmt --checkandcargo clippy --all-targetsare clean.cargo test -p rustic_corepasses, except five insta snapshot tests (backup tar, ls, rewrite, vfs). On macOS those fail on the unmodifiedrustic_core-v0.14.0tag as well.