perf(update): apply same-size format-2 sparse patches in place - #273
Merged
Conversation
Two harness corrections after #255/#267 landed: - #255 makes the update manager refuse to swap an active application without its locally persisted process identity; the bench installed the baseline by raw archive extraction, which never writes the runtime manifest. Write it the way a real install would. - #267 made format 1 the default chunked patch format (safe for pre-v2 readers); the canonical update baseline must pin chunked_patch_format: 2 to stay on the identity-chunk apply path established by the round 7-9 measurements.
Same-size format version 2 patches (identity-chunk bitset) rewrite only the changed chunks at their existing offsets instead of reading the whole source and writing a full temp copy; the target SHA-256 is one full read of the patched file afterwards. Chunk boundaries align 1:1 at equal sizes, so the reconstructed file is byte-identical to the write-to-temp flow; size-changing patches and format 1 patches fall back to the temp-file flow unchanged. The working tree is scratch space for the chain walk (the install swap is a separate atomic step), and the full-read target hash keeps the step fail-closed, so verification semantics are unchanged. Same-session A/B (scale 1.0, seed 42, 48-core shared host): - phase-instrumented 10-step pairs (x3): bspatch phase ~870-1,180 ms -> ~590-650 ms/step, in-place path fired 30/30 - 100-delta wall clock: 147,030/161,507 ms vs 163,096/170,127 ms (-7.4%; new < base in all 4 pairings); install tree byte-identical - unit coverage: in-place round-trip, all-identity no-op, size-change fallback, legacy-format fallback
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.
Purpose
Autoresearch round 10 on the
auto/update/surface (series: #252 → #256 → #265 → #270). Phase measurement showed the per-step bspatch (~0.9–1.2 s at benchmark scale) still reads the whole 1.06 GB source and writes a full temp copy even when one 64 MiB chunk (one 4 KiB page) changed — the format-2 identity bitset already tells the apply side which chunks are unchanged, but it only used them to skip the diff, not the write.Behavior impact
chunked_bspatch_file*public API is unchanged; new additivechunked_bspatch_file_with_progress_and_sha256_in_place+ChunkedBspatchResult. Apply side split intochunked/bspatch.rs(600-line guardrail).chunked_patch_formatto 1 (fleet-safe); the canonical bench now pins2to stay on the identity-chunk path that rounds 7–9 measured.Test evidence
RUSTFLAGS="-D warnings" cargo test --workspace— all green; new unit tests: in-place round-trip (hash + bytes + output-path untouched), all-identity no-op, size-change fallback, legacy-format fallback.