You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change broadcastHasVote and broadcastHasBlockpart to use TrySend not Send #3151
Currently both BroadcastHasVote and BroadcastHasBlockpart use Broadcast, which does a Send message to every peer.
While its not clear that BroadcastHasVote is needed, it definitely should be using TrySend not Send! TrySend makes it ignore the channel buffering capacity, and depend on time.Sleep's for cancelling. This increases the overhead for the go scheduler, which does actually take a lot of the time for the system. (Just creating the timers takes 30s of CPU time across a 1hour cpu profile, independent of the scheduler overhead)
Theres a number of things worth revisting about this BroadcastHas*, but it seems like we should be using TrySend everytime not Send. The channel capacity for hasVote is sent to 1, so were not really respecting that right now with the correct behavior. Its likely to me this is an accident in implementation, since the Broadcast method already existed, and used Send, with no corresponding trySend method.
Problem Definition
Reduce our CPU and scheduling overheads, and respect the channel capacities, so we don't "overgossip" from Has* channels.
Proposal
For now, just make a BroadcastTrySend method, and switch the consensus gossip routines to using that!
If for some reason we really wanted Send (which doesn't make sense to me) then we should raise the channel capacities.
After looking at #3182, I think we should just change Broadcast to use TrySend everywhere, not Send. And adapt all relevant channel buffers accordingly.
The easiest solution here is to clone Switch.Broadcast() to some method inside the consensus reactor that does the same while using TrySend() instead of Send().
Activity
ValarDragon commentedon Jun 4, 2024
After looking at #3182, I think we should just change Broadcast to use TrySend everywhere, not Send. And adapt all relevant channel buffers accordingly.
perf(p2p): Remove broadcast return channel (#3182)
cason commentedon Jun 11, 2024
Yes, I partially agree.
The problem is that
TrySenddoes not guarantee delivery to correct peers. If we me miss the Has* messages, ok, they are there to save redundancy.But the
NewRoundStepMessageappears to me to be required, I am afraid that dropping them would have unpredictable outputs.cason commentedon Jun 11, 2024
The easiest solution here is to clone
Switch.Broadcast()to some method inside the consensus reactor that does the same while usingTrySend()instead ofSend().perf(consensus): Use TrySend for hasVote/HasBlockPart messages (#3407)
perf(consensus): Use TrySend for hasVote/HasBlockPart messages (#3407)
perf(consensus): Use TrySend for hasVote/HasBlockPart messages (backp…
perf(p2p): Remove broadcast return channel (#3182)
perf(p2p): Remove broadcast return channel (backport #3182) (#3480)
perf(p2p): Remove broadcast return channel (backport cometbft#3182) (c…
perf(p2p): Remove broadcast return channel (backport cometbft#3182) (c…
perf(consensus): Use TrySend for hasVote/HasBlockPart messages (backp…
perf(p2p): Remove broadcast return channel (#3182)
perf(consensus): Use TrySend for hasVote/HasBlockPart messages (#3407)
perf(p2p): Remove broadcast return channel (#3182)
perf(consensus): Use TrySend for hasVote/HasBlockPart messages (#3407)