Repository navigation
perf(agents): store claude-code's workspace archive uncompressed in its gzip stream - #694
Draft
andrewpark-scaleai wants to merge 2 commits into
Draft
andrewpark-scaleai wants to merge 2 commits into
andrewpark-scaleai wants to merge 2 commits into
Conversation
added 2 commits
November 15, 2026 07:53
…ts gzip stream Deflate on one core limited the snapshot save, and it gains nothing on media. Level 0 keeps the gzip container, so every loader still reads it.
This branch has not been deployed
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.
Why
The goal is that every failure of an agent run leaves enough in the logs to debug it, and that code heals what it can. The claude-code agent's snapshot save builds its workspace archive with
tarfilew:gzat the default level 9. Deflate runs on one core, so it limits the whole save, and it gains nothing on large incompressible media in the workspace. A workspace of a few GB of video spends minutes in deflate before the upload starts, and the caller's wait runs out.What changed
_write_workspace_archiveopens the tar withcompresslevel=0. The archive is still a gzip stream, but its blocks are stored, not deflated.r:gz, which opens both stored and deflated gzip streams.Design decisions
r:gzand would reject a plain tar. Level 0 keeps the container, so a snapshot saved by a new agent loads into an old one, and the reverse. No magic-byte sniffing is needed.install.shinstalls the agent into images this repo does not control. A codec the sandbox might lack would make saves fail.Scope
Blast Radius
Every claude-code snapshot save and load. Archives grow to about the workspace's size. Archives saved earlier still load (tested).
Verification
.venv/bin/python -m pytest tst/unit/agents/claude_code -q: 283 passed. Without the source commit,test_the_workspace_archive_stores_bytes_as_they_are_in_a_gzip_stream_older_loaders_readfails: 1.16 MB of repeated text archives to a few KB. The restore test passes for archives at both levels._build_workspace_archiveon a synthetic workspace of 300 MB random bytes plus 22 MB of text in 400 files (337 MB in all), 5 runs each on an 8 vCPU devbox shared with other jobs: old 25.2 to 38.1 s (8.8 to 13.4 MB/s), new 0.78 to 1.46 s (231 to 433 MB/s). The old build was CPU-bound on one core (CPU time 25 to 29 s, equal to wall time on quiet runs). The new build reads files from the page cache, so it measures the CPU cost, not a cold disk.Snapshot saved: ... bytes=Nline shows N close to the workspace's size, and saves of large media workspaces finish in seconds of archive time instead of minutes.