-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: radix cache memory accounting #10637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @skyzh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses two critical bugs within the radix cache implementation. It refines the prefix matching logic to correctly handle edge cases where keys become empty after page-alignment, preventing potential errors. Additionally, it rectifies the memory accounting mechanism by ensuring that the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly addresses two bugs in the radix cache. First, it adds a check to handle cases where a key becomes empty after page-size alignment, improving robustness. The associated refactoring to create an empty_match_result helper function also enhances code clarity. Second, it fixes a memory accounting inconsistency by using len(key) instead of len(value) for evictable_size_ updates during insertion, aligning it with the deletion logic. The changes are well-implemented and improve the overall quality of the code.
|
fix the lint plz @skyzh |
|
thanks :) lint should work now |
|
@Edenzzzz thanks for the reviews :) there's also: in the same file, which sounds like we are moving something from evictable to protected, should I also use |
|
cc @xiezhq-hermann I feel these two can be used interchangeably? |
| if self.page_size != 1: | ||
| page_aligned_len = len(key) // self.page_size * self.page_size | ||
| key = key[:page_aligned_len] | ||
|
|
||
| if len(key) == 0: | ||
| return empty_match_result() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's good we do a guardrail here, but is this causing a bug? I believe there are protection within _match_prefix_helper as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kind of.. this comes from my experiment to enable deterministic radix cache by simply setting the page_size_ in radix cache to the split size of prefill - it yields several issues. So this might just work fine with the current code.
My other argument is that we are going to return empty anyways, so we can skip a bunch of code here and do a shortcircuit path to directly return empty?
c68487b to
3306486
Compare
Signed-off-by: Alex Chi Z <[email protected]> fix lint Signed-off-by: Alex Chi Z <[email protected]> actually we should use len(value)? Signed-off-by: Alex Chi Z <[email protected]>
3306486 to
f41d2ad
Compare
Signed-off-by: Alex Chi Z <[email protected]>
Signed-off-by: Alex Chi Z <[email protected]>
|
ready for review again :) thanks! cc @xiezhq-hermann |
Signed-off-by: Alex Chi Z <[email protected]>
Signed-off-by: Alex Chi Z <[email protected]>
Signed-off-by: Alex Chi Z <[email protected]>
Motivation
There seems to be two bugs in the radix cache:
self.evictable_size_when adding/removing the leaf should both use value instead of keyModifications
Accuracy Tests
Benchmarking and Profiling
Checklist