Description
Feature Request
Summary
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.