Repository navigation
cacheserver: bound the number of entries and keys - #215
Merged
Merged
Conversation
The byte caps let a write-scoped job finalize any number of empty entries, each kept in the index, rewritten with it under the lock and scanned on every lookup, and a lookup could name any number of restore keys, each costing two scans of every entry under the lock. Requests now keep to @actions/cache's own limits: ten keys in all, each at most 512 characters. A repository holds at most --max-repo-entries (default 2000), and past it a new reservation evicts that repository's own least-recently-used entry, so one repository cannot flush the others; the host holds at most --max-entries (default 20000). A job may hold at most 64 unfinished uploads, since reservations are never evicted. Eviction sorts once, so trimming a large index is not quadratic, and runs after a stale reservation is reclaimed, so a create for an existing key evicts nothing. Signed-off-by: Yi-Ru Lin <deduce@gmail.com>
linyiru
enabled auto-merge
November 8, 2026 04:32
linyiru
added a commit
that referenced
this pull request
Nov 8, 2026
…y IDs The cache-protocol test's identity records had no repository_id, so every request was denied once Validate required one, and the entry-cap test from #215 compared entries against the bare name, which no longer is the scope. Signed-off-by: Yi-Ru Lin <deduce@gmail.com>
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.
The byte caps alone left two costs unbounded:
Changes:
@actions/cache's own limits: ten keys in all, each at most 512 characters, counted in characters. A request past them gets400.--max-repo-entriesentries (default 2000). Past it, a new reservation evicts that repository's own least-recently-used entry, so one repository cannot flush the others.--max-entriesentries (default 20000).ok:false. The toolkit turns that into a warning, not a failed job.Tests are in
internal/cacheserver/entrylimit_test.go.scripts/mutate.shconfirmed that each of these is caught by a test: the repository filter, the job reservation cap, the LRU order, the reservations-only refusal, the key count and the character count.Review: a fresh reviewer agent reviewed the first version. Its main finding was that a host-wide count alone let one job evict every repository's cache and then block all saves. That led to the per-repository and per-job caps here. Its other should-fixes are fixed too: the quadratic eviction, the check running before the reclaim, and keys counted in bytes. Left for later: saving the whole index on every lookup hit.