Skip to content

[10.2.x] Backport #13234: Fix LRU RAM cache seen filter never engaging below 100% full#13317

Open
phongn wants to merge 1 commit into
apache:10.2.xfrom
phongn:fix-clfus-cache-value-int-division-10.2.x-backport
Open

[10.2.x] Backport #13234: Fix LRU RAM cache seen filter never engaging below 100% full#13317
phongn wants to merge 1 commit into
apache:10.2.xfrom
phongn:fix-clfus-cache-value-int-division-10.2.x-backport

Conversation

@phongn

@phongn phongn commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

This is a cherry-pick backport of the fix resolving the issue where the LRU RAM cache seen filter never engaged below 100% full, originally in #13234 (see that PR for details).

…13234)

proxy.config.cache.ram_cache.use_seen_filter values above 1 are
documented to turn on the seen filter once the cache is (N-1)/N full
(2 = 50%, 3 = 67%, ... 9 = 90%). The threshold was written as
bytes >= max_bytes * (1 - (1 / N)) with N an int, so 1 / N is integer
division and evaluates to 0 for every N > 1; the test became
bytes >= max_bytes and the filter only engaged when completely full.
A scan could therefore pollute a half-full cache.

Rewrite the comparison as bytes * N >= max_bytes * (N - 1), which is
exact in integer arithmetic and overflow-safe at realistic cache
sizes. Add ram_cache_lru_seen_filter, which fails on the old form
(20/20 unseen keys admitted at 60% full) and passes on the fix (0/20).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@phongn phongn requested a review from moonchen June 23, 2026 22:59
@moonchen

Copy link
Copy Markdown
Contributor

[approve ci autest 2]

@moonchen moonchen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean cherry-pick of #13234 onto 10.2.x — diff is identical to the merged original (+76/-3, same two files). CI is green apart from a flaky AuTest 2of4 (unrelated to this RAM-cache change), which has been re-triggered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants