fix(hicache): fix prefetch under heavy workload#9643
fix(hicache): fix prefetch under heavy workload#9643xiaguan wants to merge 2 commits intosgl-project:mainfrom
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @xiaguan, 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 critical performance and stability issues in the hicache prefetch mechanism, particularly under heavy workloads. The changes aim to mitigate memory allocation failures and deadlocks caused by rate limiting in high hit ratio scenarios. It introduces a more robust approach to managing prefetch operations by implementing a re-queueing mechanism for rate-limited operations and conditionally disabling prefetch when memory allocation fails due to system pressure.
Highlights
- Improved Prefetch Handling: Implements a re-queueing mechanism for prefetch operations that are rate-limited, preventing them from getting stuck and ensuring eventual processing.
- Memory Pressure Management: Adds a safeguard to skip prefetch operations when the system is under heavy memory load, preventing potential memory allocation failures.
- Optimized Prefetch Queries: Caches storage hit query results for prefetch operations to avoid redundant computations and improve efficiency.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces important fixes for prefetching under heavy workloads, addressing potential memory allocation failures and deadlocks due to rate limiting. The changes are logical and effectively solve the described problems. The addition of caching for storage hit query results is a good optimization. I have a couple of suggestions to improve code clarity and maintainability.
|
I think the prefetch limit is unnecessary. I think the root cause is that prefetch operations in the queue shouldn't consume memory - allocation should only occur when actually needed. |
Thank you for the comment and I do think it is a very valid one. The reason to alloc memory beforehand is to ensure the consistency across TP workers. In the current design, any change made to the radix tree has to happen in the main controller thread to avoid potential state divergence. |
Signed-off-by: Jinyang Su <751080330@qq.com>
8c47935 to
695ebca
Compare
Thank you for the explanation. In that case, I'll refrain from modifying the allocation logic in this PR and simply ensure the current code functions properly under extreme scenarios. |
Motivation
When the system encounters high hit ratio scenarios (such as dozens of long requests with nearly 100% hit ratios during my stress testing), it causes two critical issues:
My current fix involves disabling prefetch operations.
The solution is to implement a brief requeue mechanism.
Here are some potential solutions worth discussing:
Defer memory allocation until just before batch_get operations to prevent excessive memory pinning in short timeframes, which would simultaneously address both issues mentioned above.
Implement backpressure using queue size limitations.
Modifications
Accuracy Tests
Benchmarking and Profiling
Checklist