fix(cache): add exponential backoff for failed cache flush attempts#588
Merged
Conversation
Implement rate limiting for cache recycler flush operations to prevent performance degradation when cache limits are reached and memory cannot be freed. When flush attempts fail to release sufficient memory (less than 10% of target flush size), the system now applies exponential backoff starting at 1 microsecond and doubling up to a maximum of 1 second between retry attempts. This prevents the cache recycler from hammering the system with continuous flush attempts that cannot succeed. Key changes: - Add m_next_flush_time timestamp to track next allowed flush moment - Add m_current_flush_delay for exponential backoff tracking - Flush attempts only execute if current time >= m_next_flush_time - Success threshold: flushed size > 10% of target flush size - On success: reset delay to zero for immediate future flushes - On failure: double delay (1μs → 2μs → 4μs → ... → 1s max) Fixes #539
wskozlowski
reviewed
Dec 6, 2025
| updateSize(lock, m_capacity - flush_size); | ||
| flushed = true; | ||
| flush_result = m_current_size[priority] <= (m_capacity - flush_size); | ||
| auto now = std::chrono::high_resolution_clock::now(); |
Collaborator
There was a problem hiding this comment.
can we move this to a separate function ? this one is getting big and overly complex
…thod Extracted cache eviction and backoff logic from CacheRecycler::update() into a new private _flush() helper method to improve code maintainability and reduce method complexity.
wskozlowski
approved these changes
Dec 7, 2025
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.
Implement rate limiting for cache recycler flush operations to prevent performance degradation when cache limits are reached and memory cannot be freed.
When flush attempts fail to release sufficient memory (less than 10% of target flush size), the system now applies exponential backoff starting at 1 microsecond and doubling up to a maximum of 1 second between retry attempts. This prevents the cache recycler from hammering the system with continuous flush attempts that cannot succeed.
Key changes:
Fixes #539