Repository navigation
cache: avoid copying serialized entries on L1 reads - #4396
Merged
MustafaSaber merged 2 commits intoNov 3, 2026
Merged
Conversation
Signed-off-by: Perfloop Agent <[email protected]> Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Perfloop Agent <[email protected]> Signed-off-by: Tomás Senart <[email protected]>
perfloop-agent
marked this pull request as ready for review
November 1, 2026 21:21
szuecs
approved these changes
Nov 2, 2026
MustafaSaber
approved these changes
Nov 2, 2026
This was referenced Nov 2, 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.
Warm L1 HTTP cache reads no longer clone the serialized response before decoding it. The decoder reads privately owned bytes after releasing the shard lock.
4 KiB body: B/op 30.5 kB → 24.34 kB (−20.2%), ns/op 39.7 µs → 36.59 µs; medians of 9 paired runs.
64 KiB body: B/op 237.8 kB → 147.4 kB (−38%), ns/op 256.7 µs → 219.1 µs (−15.2%); medians of 11 paired runs.
Per-metric results
B/opns/opB/opns/opChanges
The stored JSON representation, byte-based eviction, freshness windows and response selection are unchanged. Misses and L2 fetches are outside the optimization.
Testing
BenchmarkCacheHit measures complete serial warm-handler GETs with empty, 4 KiB and 64 KiB text bodies. It includes routing, decoding, default tracing, response writing and access-log formatting into a discard sink. Reproduce with
go test ./filters/cache -run '^$' -bench '^BenchmarkCacheHit$' -benchmem.These are in-process warm L1 measurements, not network latency or deployed traffic savings.
TestShardedByteLRU_GetIsolationchecks defensive byte copies.TestLRUStorage_GetIsolationchecks nested mutable results.TestLRUStorage_SnapshotLifetimechecks retained bytes across overwrite, deletion, eviction and expiry;TestLRUStorage_ConcurrentReadsexercises readers and writers under the race detector. Existing cache filter tests cover GET, HEAD, conditional 304 and Vary results.The Docker-backed
filters/cache.TestValkeyStorage_GetSetDeleteandfilters/cache.TestValkeyStorage_FallsBackToL1OnValkeyUnavailablerequire a Docker daemon, which is unavailable here; they remain for target CI.5 recorded checks pass with this change.
Not run locally:
TestValkeyStorage_GetSetDelete,TestValkeyStorage_FallsBackToL1OnValkeyUnavailable. These tests start Valkey using testcontainers and require an unavailable Docker daemon.Related work: #4395 also touches the L1 store for cache metrics.
Case and evidence
Generated by Perfloop. Human sponsor: Tomás Senart.