-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
raft/tracker: visit Progress in stable order #11004
Conversation
Codecov Report
@@ Coverage Diff @@
## master #11004 +/- ##
=========================================
- Coverage 63.9% 63.8% -0.1%
=========================================
Files 401 401
Lines 37558 37572 +14
=========================================
- Hits 24001 23973 -28
- Misses 11926 11970 +44
+ Partials 1631 1629 -2
Continue to review full report at Codecov.
|
@@ -166,10 +166,34 @@ func (p *ProgressTracker) Committed() uint64 { | |||
return uint64(p.Voters.CommittedIndex(matchAckIndexer(p.Progress))) | |||
} | |||
|
|||
// Visit invokes the supplied closure for all tracked progresses. | |||
func insertionSort(sl []uint64) { |
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.
move this to a common util pkg? no need for two insertionSort.
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.
+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.
I intentionally didn't do that (https://www.youtube.com/watch?v=PAAkCSZUG1c&t=9m28s). Just to double check, are you suggesting I make an insertionsortutil
package that only includes this method? Because it won't be able to include much more than that because quorum's dependency tree is quite small and that's a good thing (plus, lots of our existing util-like code actually depends on raft).
lgtm |
// We need to sort the IDs and don't want to allocate since this is hot code. | ||
// The optimization here mirrors that in `(MajorityConfig).CommittedIndex`, | ||
// see there for details. | ||
var sl [7]uint64 |
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.
I'd say to avoid the double slice, but you're moving this code from somewhere else, so feel free to keep as is.
var ids []uint64
var sl [7]uint64
if n <= len(sl) {
ids = sl[:n]
} else {
ids = make([]uint64, n)
}
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.
Fixed both up (the one here was even wrong!)
@@ -166,10 +166,34 @@ func (p *ProgressTracker) Committed() uint64 { | |||
return uint64(p.Voters.CommittedIndex(matchAckIndexer(p.Progress))) | |||
} | |||
|
|||
// Visit invokes the supplied closure for all tracked progresses. | |||
func insertionSort(sl []uint64) { |
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.
+1
This is helpful for upcoming testing work which allows datadriven testing of the interaction of multiple nodes. This testing requires determinism to work correctly.
5feebe1
to
1b3e082
Compare
Thanks for the reviews! |
This is helpful for upcoming testing work which allows datadriven testing
of the interaction of multiple nodes. This testing requires determinism to
work correctly.