-
Notifications
You must be signed in to change notification settings - Fork 286
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
Conversation
@ykwd Would you like to take a look at this PR? Thanks! |
&& !it->second.HasDiffRepStatus(ReplicaStatus::COMPLETE)) { | ||
for (auto it : candidates) { | ||
if (shard_evicted_count >= evict_num) break; | ||
if (it->second.lease_timeout <= target_timeout) { |
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.
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.
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.
done.
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. |
@ykwd thanks for your suggestion, indeed, the |
Thanks. Looks good to me. |
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.
LGTM
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!