[IDX-7032] Move to ticket-based eviction system when cache is full#40
Open
dalloriam wants to merge 5 commits into
Open
[IDX-7032] Move to ticket-based eviction system when cache is full#40dalloriam wants to merge 5 commits into
dalloriam wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors cache eviction/constraint handling to a ticket-based flow: eviction policies now pop_victim() to produce a rollbackable ticket, and constraint policies return tickets (prepare_insert / prepare_replace) that become satisfied as evictions are registered. This lets the cache collect evictions without copying the whole constraint policy and supports aborting an insert by rolling back policy state.
Changes:
- Replace eviction-policy victim iteration APIs with
pop_victim()+rollback(ticket)(LRU / SLRU / GDSF) and update tests accordingly. - Introduce constraint “prepare” tickets for count/memory constraints and update cache insert/replace eviction collection logic to use them.
- Fix cache-hit event dispatch so hits are delivered once per policy, and add a regression test.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/src/policy/eviction_segmented_lru_tests.cpp | Updates SLRU tests to use pop_victim() + rollback-based victim enumeration. |
| tests/src/policy/eviction_lru_tests.cpp | Updates LRU tests to use ticket-based victim popping/rollback. |
| tests/src/policy/eviction_gdsf_tests.cpp | Updates GDSF tests to use pop_victim() + rollback and validates victim ordering. |
| tests/src/policy/constraint_memory_tests.cpp | Updates memory-constraint tests to use prepare_insert/prepare_replace tickets. |
| tests/src/policy/constraint_count_tests.cpp | Updates count-constraint tests to use prepare_insert/prepare_replace tickets. |
| tests/src/memory_cache_tests.cpp | Adds regression test for replacement flow where the original key can be evicted mid-operation. |
| tests/src/event_dispatch_tests.cpp | Adds regression test ensuring cache-hit events are delivered once per policy. |
| tests/CMakeLists.txt | Adds the new event dispatch test file to the test target. |
| include/cachemere/policy/eviction_segmented_lru.h | Replaces victim iterators with eviction tickets and rollback. |
| include/cachemere/policy/eviction_lru.h | Replaces victim iterators with eviction tickets and rollback. |
| include/cachemere/policy/eviction_gdsf.h | Replaces victim iterators with eviction tickets and rollback for GDSF. |
| include/cachemere/policy/constraint_memory.h | Replaces can_add/can_replace with prepare tickets that accumulate freed memory via registered evictions. |
| include/cachemere/policy/constraint_count.h | Adds prepare tickets (but leaves can_add declared). |
| include/cachemere/cache.h | Implements ticket-based eviction collection, adds remove_popped_victim, and fixes cache-hit dispatch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dalloriam
marked this pull request as ready for review
May 21, 2026 15:27
dalloriam
force-pushed
the
feature/IDX-7025-performance-improvements
branch
from
May 26, 2026 17:28
91649b0 to
f0d0931
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.
Changes
on_cache_hitwas called twice on the eviction policy (src)