Repository navigation
gocache/gocached: evict Actions younger than maxAge when over size - #16
Merged
Merged
Conversation
winckler
approved these changes
Nov 9, 2026
winckler
left a comment
There was a problem hiding this comment.
I left one suggestion, which I think doesn't add complexity and improves accuracy. But since the drift is only temporary (10 min per shard), it's fine if you prefer to land as is.
cleanupTick always used the maxAge cutoff when maxAge was set, even when no Actions were over age. Size-only cleanup could then evict only Actions older than maxAge, so the cache could grow past maxSize without limit. cmd/gocached sets maxAge by default, so this affected production. Run the age-cutoff pass only when some Actions are over age. If the cache is over size and the age pass evicts nothing, continue to a size-only pass with no age cutoff. Eviction does not update the ActionsLE histograms that overAge comes from, so overAge can stay true for up to shardStalenessTarget after the last over-age Actions are gone. Without the fall-through, size cleanup stops during that time. Fixes tailscale/corp#51226
tomhjp
force-pushed
the
tomhjp/gocached-size-cleanup-max-age
branch
from
November 9, 2026 16:33
8c0c304 to
96093b5
Compare
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.
cleanupTick always used the maxAge cutoff when maxAge was set, even when no Actions were over age. Size-only cleanup could then evict only Actions older than maxAge, so the cache could grow past maxSize without limit. cmd/gocached sets maxAge by default, so this affected production.
Use the maxAge cutoff only when some Actions are over age. When the cache is over both limits, cleanup removes over-age Actions first and then falls back to size-only cleanup.
Fixes tailscale/corp#51226