Skip to content

Change broadcastHasVote and broadcastHasBlockpart to use TrySend not Send #3151

Closed

Description

@ValarDragon

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.

Activity

  1. added
    enhancement
    needs-triage
    on May 30, 2024
  2. added this to the 2024-Q2 milestone on May 30, 2024
  3. ValarDragon commented on Jun 4, 2024

    @ValarDragon
    ContributorAuthor

    After looking at #3182, I think we should just change Broadcast to use TrySend everywhere, not Send. And adapt all relevant channel buffers accordingly.

  4. removed
    needs-triage
    on Jun 11, 2024
  5. cason commented on Jun 11, 2024

    @cason

    Yes, I partially agree.

    The problem is that TrySend does not guarantee delivery to correct peers. If we me miss the Has* messages, ok, they are there to save redundancy.

    But the NewRoundStepMessage appears to me to be required, I am afraid that dropping them would have unpredictable outputs.

  6. cason commented on Jun 11, 2024

    @cason

    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().

  7. removed this from the 2024-Q2 milestone on Jul 2, 2024
  8. added a commit that references this issue on Jul 10, 2024
    55493e0
  9. moved this from Todo to Done in CometBFTon Jul 10, 2024
  10. added a commit that references this issue on Jul 10, 2024
    40f85bc
  11. added a commit that references this issue on Jul 10, 2024
    5d438a2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    consensusenhancement

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions