[9.4] [ML] Fix concurrent LFU cache count invariant under lock timeouts (#3090)#3101
Merged
Conversation
) The concurrent cache only incremented m_NumberLookups inside the read-guard lambda, which does not run when the read lock times out. The subsequent miss path can still add a count (insert/increment) or record a lost update, so under contention the surviving counts could exceed the number of accounted lookups and intermittently trip checkInvariants() (observed as a flaky failure of testConcurrentReadsAndWrites on loaded debug CI agents). Count every lookup exactly once, before taking the read lock. Also relax the count invariant for the timeout-capable cache to a one-sided bound: counts can legitimately be lost under concurrency (an item hit under the read lock may be evicted before its count is incremented, one insert can evict several items, and write updates can time out) but must never be fabricated. The exact equality is retained for the single-threaded cache, which has no timeouts. Add a regression test that drives lock timeouts via a zero maximum wait under heavy contention; it fails reliably against the previous code. --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> (cherry picked from commit 1beb813)
3 tasks
Contributor
|
buildkite build |
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.
Backport
This will backport the following commits from
mainto9.4:Questions ?
Please refer to the Backport tool documentation