[4/4][MP] L2 Prefetch controller foundation#2658
Conversation
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 lays the foundational groundwork for the L2 prefetch controller within LMCache. It introduces critical building blocks to enable robust and efficient data management between L1 and L2 caches. The changes focus on enhancing atomic operations for cache consistency, establishing a flexible policy system for L2 data distribution, and improving prefetch request tracking. These additions are essential prerequisites for the subsequent implementation of the full L2 prefetch controller, ensuring a stable and extensible architecture for distributed caching. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
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.
Code Review
This pull request introduces the foundational components for the L2 prefetch controller, including an atomic finish_write_and_reserve_read operation in L1Manager, policies for prefetching and storing data (PrefetchPolicy, StorePolicy), and the asynchronous StoreController to manage data transfer from L1 to L2. The changes are well-structured, robust, and thoroughly tested. My review identifies one minor opportunity for a performance optimization.
| for name, cls in _L2_ADAPTER_CONFIG_REGISTRY.items(): | ||
| if type(config) is cls: | ||
| return name | ||
| raise ValueError(f"Unregistered L2 adapter config type: {type(config).__name__}") |
There was a problem hiding this comment.
This reverse lookup iterates through the entire registry on each call, which has O(N) complexity where N is the number of adapter types. While this is acceptable for a small number of adapters, it could become a performance concern if the registry grows.
A more performant approach would be to maintain a reverse mapping from the config class to its type name, allowing for an O(1) lookup. This could be populated when adapters are registered.
Signed-off-by: ApostaC <yihua98@uchicago.edu>
Signed-off-by: ApostaC <yihua98@uchicago.edu>
4612841 to
0a6fd2d
Compare
Signed-off-by: ApostaC <yihua98@uchicago.edu>
|
|
||
| # Reserve write (key is now write-locked) | ||
| write_result = manager.reserve_write([key], [False], basic_layout) | ||
| assert write_result[key][0] == L1Error.SUCCESS |
There was a problem hiding this comment.
Naming-wise L1Error.SUCCESS sounds weird. L1 Error is an error and it should not be with SUCCESS. I'm fine to not change it in this PR tho.
* [add] backbone for prefetch controller Signed-off-by: ApostaC <yihua98@uchicago.edu> * [Add] bitmap operations for better prefetch support Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issue Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu>
* [add] backbone for prefetch controller Signed-off-by: ApostaC <yihua98@uchicago.edu> * [Add] bitmap operations for better prefetch support Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issue Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu> Signed-off-by: Ofer Kiselov Nahman <ofer.kiselovnahman@weka.io>
* [add] backbone for prefetch controller Signed-off-by: ApostaC <yihua98@uchicago.edu> * [Add] bitmap operations for better prefetch support Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issue Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu>
* [add] backbone for prefetch controller Signed-off-by: ApostaC <yihua98@uchicago.edu> * [Add] bitmap operations for better prefetch support Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issue Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu>
* [add] backbone for prefetch controller Signed-off-by: ApostaC <yihua98@uchicago.edu> * [Add] bitmap operations for better prefetch support Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issue Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu> Signed-off-by: shaoxiawjc <wjc2800@163.com>
* [add] backbone for prefetch controller Signed-off-by: ApostaC <yihua98@uchicago.edu> * [Add] bitmap operations for better prefetch support Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issue Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu> Signed-off-by: Aaron Wu <aaron.wu@dell.com>
* [add] backbone for prefetch controller Signed-off-by: ApostaC <yihua98@uchicago.edu> * [Add] bitmap operations for better prefetch support Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issue Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu>
* [add] backbone for prefetch controller Signed-off-by: ApostaC <yihua98@uchicago.edu> * [Add] bitmap operations for better prefetch support Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issue Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu>

What this PR does / why we need it:
Part of #2562
This is the foundation PR for the L2 prefetch controller. It adds the building blocks needed before implementing the full controller (next PR):
L1Manager.finish_write_and_reserve_read()— Atomic transition from write-locked to read-locked state. After loading L2 data into write-reserved L1 buffers, this prevents a race window where eviction could remove the key between separatefinish_write()+reserve_read()calls.PrefetchPolicyABC +DefaultPrefetchPolicy— Policy interface for deciding which L2 adapter loads which key when multiple adapters have the same data. The default policy assigns each key to the lowest-indexed adapter that has it.PrefetchHandleredesign — Extended from a singleprefix_hit_chunksfield to includerequest_id(for async L2 tracking),l1_prefix_hit_count, andtotal_requested_keys.More interfaces in
Bitmap— Expose more interfaces in Bitmap for the prefetch controller to use.Note: This PR needs to be rebased after #2646 is merged. And it requires #2662 to be merged first.
If applicable: