-
Notifications
You must be signed in to change notification settings - Fork 15
REP-5277 Parallelize persistence of rechecks. #41
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
REP-5277 Parallelize persistence of rechecks. #41
Conversation
tdq45gj
left a comment
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 % one suggestion
| // This will split the given slice into *roughly* the given number of chunks. | ||
| // It may end up being more or fewer, but it should be pretty close. | ||
| func splitToChunks[T any, Slice ~[]T](elements Slice, numChunks int) []Slice { | ||
| elsPerChunk := len(elements) / numChunks |
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.
can we check numChunks > 0?
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
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 % question around redefining var. +1 to Jian's suggestion for the assertion
| DataSize: dataSizes[i], | ||
| } | ||
| for _, curThreadIndexes := range indexesPerThread { | ||
| curThreadIndexes := curThreadIndexes |
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.
Why do we redefine the var?
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 linter flagged it as one of those cases where you’re supposed to redefine the var to prevent loop-variable-in-goroutine problems.
We receive events and enqueue rechecks in the same thread. When there are 1,000s of rechecks to enqueue at once, though, we need faster throughput than a single thread will allow.
This changeset fixes that by parallelizing the enqueueing of rechecks.