-
Notifications
You must be signed in to change notification settings - Fork 728
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
mcs: support batch allocating ids #9092
Conversation
Skipping CI for Draft Pull Request. |
d49c123
to
6ec9efc
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9092 +/- ##
==========================================
+ Coverage 76.22% 76.35% +0.13%
==========================================
Files 468 468
Lines 71696 71708 +12
==========================================
+ Hits 54648 54751 +103
+ Misses 13629 13532 -97
- Partials 3419 3425 +6
Flags with carried forward coverage won't be shown. Click here to find out more. |
/cc @ystaticy |
@rleungx: GitHub didn't allow me to request PR reviews from the following users: ystaticy. Note that only tikv members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
cb10a68
to
a7a6d9c
Compare
/retest |
1 similar comment
/retest |
@ystaticy: adding LGTM is restricted to approvers and reviewers in OWNERS files. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/hold |
return 0, err | ||
for range count { | ||
if alloc.base == alloc.end { | ||
if err := alloc.rebaseLocked(true); err != nil { |
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.
It may generate many etcd requests.
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.
Only when alloc.base == alloc.end
, it will rebase.
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.
What about just calculating if the rebase is necessary rather than passively waiting for the loop to do it?
|
||
return alloc.base, nil | ||
return alloc.base, count, nil |
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.
the result of count can be skipped
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.
The Alloc needs the count
as the return value due to the interface limitation in the current implementation. We do have another way that does not add count in the response but I prefer to leave it.
@@ -839,15 +839,15 @@ func newRegionInfoIDRandom(idAllocator id.Allocator) *RegionInfo { | |||
// Randomly select a peer as the leader. | |||
leaderIdx := mrand.Intn(peerNum) | |||
for i := range peerNum { | |||
id, _ := idAllocator.Alloc() | |||
id, _, _ := idAllocator.Alloc(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.
A lot of places are using idAllocator.Alloc(1)
, what about providing a function named AllocOne()
?
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.
Then we need to add one more interface.
return 0, err | ||
for range count { | ||
if alloc.base == alloc.end { | ||
if err := alloc.rebaseLocked(true); err != nil { |
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.
What about just calculating if the rebase is necessary rather than passively waiting for the loop to do it?
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bufferflies, JmPotato, ystaticy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
Signed-off-by: Ryan Leung <[email protected]>
/retest |
1 similar comment
/retest |
/unhold |
/retest |
2 similar comments
/retest |
/retest |
/retest |
What problem does this PR solve?
Issue Number: Close #9085.
What is changed and how does it work?
kvproto PR: pingcap/kvproto#1296
Check List
Tests
Release note