[MP] Add a new argument to specify whether retain_in_l1#2813
[MP] Add a new argument to specify whether retain_in_l1#2813chunxiaozheng merged 2 commits intoLMCache:devfrom
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Summary of ChangesHello, 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 enhances the LMCache's prefetching capabilities by introducing a new configuration option that dictates whether prefetched L2 data should persist in the L1 cache after its initial consumption. This allows for more flexible cache management, enabling users to optimize for either temporary data handling or a more persistent "hot cache" mode where prefetched items are subject to the EvictionController. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new configuration option, prefetch_retain_l1, which allows users to control whether prefetched L2 data is retained in the L1 cache after consumption. By default, this option is False, meaning prefetched data is temporary and deleted from L1. When set to True, the data persists in L1 and is managed by the EvictionController, effectively enabling a 'hot cache' mode for prefetched items. The change includes updating the StorageManagerConfig, adding a command-line argument for this setting, modifying the PrefetchController to utilize this flag when reserving L1 cache space, and documenting the new option.
ApostaC
left a comment
There was a problem hiding this comment.
Can we do it as part of the prefetch policy?
We can introduce a new interface in the prefetch policy, for example
def select_l1_retentions(
self,
keys: list[ObjectKey],
) -> list[bool]
"""
Determine which keys need to be retained/deleted after the prefetched objects are consumed.
Args: ......
Returns: ...... (the number of bools needs to be the same as the number of input keys)
"""Then, we can call it just before the l1_mgr.reserve_write in the prefetch controller
|
@ApostaC Thanks for the previous review, addressed the comment, PTAL. |
| A list of bools with the same length as *keys*. | ||
| ``True`` = retain (permanent), ``False`` = temporary. | ||
| """ | ||
| return [False] * len(keys) |
There was a problem hiding this comment.
@maobaolong Good catch, but I have a little question, all the implementations directly return false, when will it return True?
There was a problem hiding this comment.
Lost a RetainPrefetchPolicy implementation, and now added.
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
53010fb to
8d065cb
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8d065cb. Configure here.
|
@chunxiaozheng Thanks for the remind, PTAL. |
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
* [MP] Add a new argument to specify whether retain_in_l1 Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Remove redundant override method. Signed-off-by: baoloongmao <baoloongmao@tencent.com> --------- Signed-off-by: baoloongmao <baoloongmao@tencent.com>
* [MP] Add a new argument to specify whether retain_in_l1 Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Remove redundant override method. Signed-off-by: baoloongmao <baoloongmao@tencent.com> --------- Signed-off-by: baoloongmao <baoloongmao@tencent.com>
* [MP] Add a new argument to specify whether retain_in_l1 Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Remove redundant override method. Signed-off-by: baoloongmao <baoloongmao@tencent.com> --------- Signed-off-by: baoloongmao <baoloongmao@tencent.com>

What this PR does / why we need it:
Special notes for your reviewers:
If applicable:
Note
Medium Risk
Adds a new prefetch policy that changes L1 lifetime semantics for prefetched data and can increase memory usage if enabled. The default behavior remains temporary prefetch, so impact is limited to users selecting the new policy.
Overview
Adds an L2 prefetch retention mechanism by extending
PrefetchPolicywithselect_l1_retentions()and wiring it intoPrefetchControllersoreserve_write()can mark prefetched entries as temporary vs permanent.Introduces a new
retainprefetch policy (RetainPrefetchPolicy) that keeps all prefetched keys permanently in L1, updates MP docs for the new--l2-prefetch-policy retainoption, and adds unit tests covering both default (temporary) and retain behaviors.Reviewed by Cursor Bugbot for commit 529032c. Bugbot is set up for automated code reviews on this repo. Configure here.