perf(extract): coalesce archive blocks into large writes - #1681
Merged
Conversation
elibosley
marked this pull request as ready for review
August 6, 2026 00:27
tdewey-rpi
approved these changes
Aug 7, 2026
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.
Summary
Multi-file extraction performs one disk write for every small libarchive data block; this coalesces contiguous blocks into 8 MiB writes while preserving exact offsets and error behavior.
Why This Exists
archive_write_data_block()has meaningful per-call overhead, especially on removable media with write caching disabled. In device testing, batching reduced a representative extraction from approximately 26 minutes to 5.5 minutes.Resolution
Add a small, independently tested
BlockBatcherbetween the archive reader andarchive_write_disk. Contiguous blocks are buffered, offset gaps flush immediately to preserve sparse files, and blocks at least as large as the buffer bypass the copy.Reviewer Considerations
archive_write_finish_entry().Behavior Changes
Multi-file images are written using fewer, larger disk operations. Extracted bytes and offsets remain unchanged.
Implementation Summary
Verification
./build/test/block_batcher_test: 122 assertions in 11 test cases passed.downloadextractthread.cppsuccessfully; final universal-app link was blocked by the local arm64-only Homebrew Qt installation.git diff --check: passed.Risk
Low to moderate. The buffering path is isolated and extensively tested; the primary tradeoff is an additional 8 MiB allocation during multi-file extraction.