8000 Improve the batchEvict logic by maobaolong · Pull Request #432 · kvcache-ai/Mooncake · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve the batchEvict logic #432

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

Merged
merged 2 commits into from
May 31, 2025

Conversation

maobaolong
Copy link
Collaborator
@maobaolong maobaolong commented May 30, 2025

This change can reduce iterate the key of shard as less as possible.

This change has been discussed offline with @ykwd and really appreciate with the help and suggestion!

@maobaolong
Copy link
Collaborator Author

@ykwd Would you like to take a look at this PR? Thanks!

@maobaolong maobaolong requested a review from xiaguan May 30, 2025 12:18
&& !it->second.HasDiffRepStatus(ReplicaStatus::COMPLETE)) {
for (auto it : candidates) {
if (shard_evicted_count >= evict_num) break;
if (it->second.lease_timeout <= target_timeout) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we can position the kv object directly in the candidates vector, there is no need to find out the target_timeout and compare with it. We can simply erase all the kvs between candidates.begin() and candidates.begin() + evict_num - 1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@ykwd
Copy link
Collaborator
ykwd commented May 30, 2025

@ykwd Would you like to take a look at this PR? Thanks!

Great work! I am more than happy to do the review. All things are good except one minor issue, which I commented in the code.

@maobaolong
Copy link
Collaborator Author

@ykwd thanks for your suggestion, indeed, the target_timeout is no longer needed, just did a improvement follow your suggestion, PTAL.

@ykwd
Copy link
Collaborator
ykwd commented May 31, 2025

@ykwd thanks for your suggestion, indeed, the target_timeout is no longer needed, just did a improvement follow your suggestion, PTAL.

Thanks. Looks good to me.

Copy link
Collaborator
@xiaguan xiaguan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@stmatengss stmatengss merged commit 02504e1 into kvcache-ai:main May 31, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0