Repository navigation
feat(cache): compress remote cache values - #957
Merged
wan9chi merged 1 commit intoNov 7, 2026
Merged
Conversation
fspy benchmarklinuxmacoswindows |
wan9chi
force-pushed
the
remote-cache-compress-values
branch
from
November 7, 2026 10:18
5085dc4 to
a5aff18
Compare
Remote cache values are now zstd(wincode(CacheEntryValue)) instead of plain wincode. A fetch returns several entries per key, so uncompressed values (median about 111 KB, up to 3 MB) make responses too big; zstd at its default level shrinks them about 7x. - A fetched value decompresses through a reader capped at 32 MiB, so a broken or hostile server can't exhaust memory with a zstd bomb. A value that isn't valid zstd, is too large, or doesn't decode is still a "remote cache value is corrupt" miss. - A value larger than that cap isn't uploaded, since no client would read it back. - Both keys' header now carries a remote value format version, so clients that encode values differently never share entries or push out each other's. The local cache's schema version stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wan9chi
changed the base branch from
remote-cache-e2e-entries
to
remote-cache-entries-per-key
November 7, 2026 10:41
wan9chi
force-pushed
the
remote-cache-compress-values
branch
from
November 7, 2026 10:41
a5aff18 to
8bd6a40
Compare
wan9chi
marked this pull request as ready for review
November 7, 2026 11:00
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.
Motivation
An exact fetch now returns up to
entries_per_keyentries, 8 by default and at most 16, and the Worker caps each value at 4 MiB. Uncompressed, values are large: in a replay of five public repositories' CI, the median was 111 KB, the p90 1.66 MB and the largest 3.10 MB. Eight of those make every fetch heavy, and large repositories exceed the cap. RFC 0003 of Vite+'s Cloudflare remote cache asksvp runto compress values with zstd. They're opaque bytes to the server, so this changes only the client.Changes
zstd(wincode(CacheEntryValue)), at zstd's default level, the same as output archives. On 42 real values from local task caches (18.9 MB), level 3 compressed to 2.59 MB in milliseconds. Level 9 was about 22% smaller but about 5 times slower, and a value is compressed as its task finishes.remote cache value is corrupt.cache entry is larger than 32 MiB), since no client would read it back.None of the snapshots change.
Stacked on #955.
🤖 Generated with Claude Code
Note
Medium Risk
Changes remote cache wire format and key matching; old uncompressed entries become misses for new clients, with safeguards for bombs and oversized uploads.
Overview
Remote cache values are now
zstdover the existing wincode payload on upload, and decompressed with a 32 MiB cap on fetch so oversized or malformed frames are treated as corrupt misses instead of exhausting memory.Uploads reject uncompressed values above that limit; new
UploadErrorvariants cover compression failure and too large. Reads route decode failures throughDecodeValueError(decompress, too large, or wincode decode).Cache keys gain a
remote_value_formatfield in the header (version 1) so clients using different value encodings do not share or evict each other's entries in the same remote namespace.Tests cover round-trip encoding, non-zstd/truncated payloads, size limits, and mismatched format versions in fallback keys.
Reviewed by Cursor Bugbot for commit 8bd6a40. Bugbot is set up for automated code reviews on this repo. Configure here.