This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Parallelize requesting from peers in
ordersync
#848Parallelize requesting from peers in
ordersync
#848Changes from 6 commits
94dd394
e2d5ba7
407aeae
df422f4
d47e48b
5df8739
3554a10
5f5d789
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
@albrow This shouldn't need to be in the mutex unless we have duplicate peer IDs in the
currentNeighbors
array. My guess is that we don't, but I also wanted to protect us from bugs in libp2p that could cause this assumption to not be true. Let me know if you think it's okay to access this outside of a lock.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 doesn't matter whether there are any duplicate peer IDs. Maps in Go are not goroutine safe. We need to protect reads and writes to the map with a
sync.RWMutex
.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.
Oh I see. I didn't realize that it could crash the program -- I assumed that it was merely a synchronization issue. I'll leave it in the mutex and change that to a
RWMutex
.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.
@albrow I'm not sure that wrapping this in a
RLock
is worth the extra overhead, but it seems more technically correct. Do you have any insight into this?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.
My gut says just move
successfullySyncedPeerLength := len(successfullySyncedPeers)
beforem.Unlock
. Intuitively I would expect that assignment to be faster than acquiring a new mutex but I'm not 100% sure.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.
That's what I figured. I'll change it back.