Repository navigation
perf: resume cache_skip_pinned where the last scan from the same object stopped - #386
Merged
Merged
Conversation
Owner
|
What is this about? |
1a1a11a
requested review from
1a1a11a and
SeverinaZheng
and
a balanced review from Copilot
November 10, 2026 05:02
Collaborator
Author
This is a comment that optimize the performance for pinning. @haochengxia mentioned in in cacheMon/PrefixSim#4:
This speeds up cache_skip_pinned, which only PrefixSim uses. Do you want to remove all pinning from libCacheSim? |
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.
What does this PR do?
cache_skip_pinnedwalks from a queue's victim end past the pinned objects. PrefixSim pins the blocks of the request it is serving, then callsevictonce for each block it has to free. Each of those calls walks the same pinned run again from the tail, which costs O(pinned × needed) per request. On the FreeInference trace at 16k blocks, LRU takes 1,031 s with pins and 79 s without, with the same results.This PR makes the scan resume where the last scan from the same starting object stopped.
remove_obj_from_list,move_obj_to_head,move_obj_to_tailandcache_remove_obj_base.cache_set_pin_predicateclears the whole memo.cache_set_pin_predicatedoc now says so.Every algorithm that calls
cache_skip_pinnedgets the speedup without changes. With no predicate installed, the list helpers pay one thread-local NULL check.Suggested by @haochengxia in cacheMon/PrefixSim#4.
Type of change
How was it tested?
ctest --test-dir _build --output-on-failurepasses, also with-fsanitize=leakBuild is warning-free (CI uses
-Wall -Wextra -Werror)New
testPinScan. A randomized differential test: 5 seeds of 500k operations each, on 3 lists.PrefixSim, built against
developand against this branch. Every RESULT line is identical across 217 runs:The full FreeInference trace gives identical results at all 11 points in the table below.
cachesimwith no pin predicate, ontwitter_cluster52_10mwith LRU, S3-FIFO, Sieve and Clock at 2 sizes. Miss ratios are identical, and there is no measurable time difference (medians of 5 runs on a dedicated core):Results
These are PrefixSim runs on the full FreeInference trace, each on a dedicated core:
Results are identical to
developat every point.Checklist
clang-format(or the pre-commit hook fromscripts/setup_hooks.sh)