Skip to content

Conversation

@FGasper
Copy link
Collaborator

@FGasper FGasper commented Nov 14, 2024

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.

@FGasper FGasper requested review from jtcovan and tdq45gj November 14, 2024 15:28
Copy link
Collaborator

@tdq45gj tdq45gj left a 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
Copy link
Collaborator

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?

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

Copy link
Collaborator

@jtcovan jtcovan left a 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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@FGasper FGasper merged commit 063759d into mongodb-labs:main Nov 15, 2024
5 checks passed
@FGasper FGasper deleted the REP-5277-parallelize-recheckqueue-upsert branch November 15, 2024 01:20
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.

3 participants