Skip to content

Commit

Permalink
fullrt: comment to explain why bulk sending splits into groups
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed May 27, 2021
1 parent d046692 commit 1e791eb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fullrt/dht.go
Expand Up @@ -1019,6 +1019,10 @@ func (dht *FullRT) bulkMessageSend(ctx context.Context, keys []peer.ID, fn func(
}
}

// divide the keys into groups so that we can talk to more peers at a time, because the keys are sorted in
// XOR/Kadmelia space consecutive puts will be too the same, or nearly the same, set of peers. Working in parallel
// means less waiting on individual dials to complete and also continuing to make progress even if one segment of
// the network is being slow, or we are maxing out the connection, stream, etc. to those peers.
keyGroups := divideIntoGroups(sortedKeys, dht.bulkSendParallelism)
wg.Add(len(keyGroups))
for _, chunk := range keyGroups {
Expand Down

0 comments on commit 1e791eb

Please sign in to comment.