Skip to content

Commit

Permalink
Merge pull request cometbft#103 from osmosis-labs/mergify/bp/osmo-v25…
Browse files Browse the repository at this point in the history
…/v0.37.4/pr-101

 perf(consensus): Run broadcast routines out of process cometbft#3180  (backport cometbft#101)
  • Loading branch information
ValarDragon committed Jun 5, 2024
2 parents 56626cf + 637da58 commit c6c4ecc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [`consensus`] Lower the consensus blocking overhead of broadcasts from `num_peers * process_creation_time` to `process_creation_time`.
([\#3180](https://github.com/cometbft/cometbft/issues/3180)
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* [#93](https://github.com/osmosis-labs/cometbft/pull/93) perf(consensus): Make some consensus reactor messages take RLock's not WLock's (#3159)
* [#95](https://github.com/osmosis-labs/cometbft/pull/95) perf(types) Make a new method `GetByAddressMut` for `ValSet`, which does not copy the returned validator. (#3129)
* [#97](https://github.com/osmosis-labs/cometbft/pull/97) perf(p2p/connection): Lower wasted re-allocations in sendRoutine (#2986)
* [#99](https://github.com/osmosis-labs/cometbft/pull/99) perf(consensus): Reuse an internal buffer for block building (#3162)
* [#97](https://github.com/osmosis-labs/cometbft/pull/101) perf(consensus): Run broadcast routines out of process (speeds up consensus mutex) #3180


## v0.37.4-v25-osmo-5
Expand Down
31 changes: 19 additions & 12 deletions consensus/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,12 @@ func (conR *Reactor) unsubscribeFromBroadcastEvents() {

func (conR *Reactor) broadcastNewRoundStepMessage(rs *cstypes.RoundState) {
nrsMsg := makeRoundStepMessage(rs)
conR.Switch.BroadcastEnvelope(p2p.Envelope{
ChannelID: StateChannel,
Message: nrsMsg,
})
go func() {
conR.Switch.BroadcastEnvelope(p2p.Envelope{
ChannelID: StateChannel,
Message: nrsMsg,
})
}()
}

func (conR *Reactor) broadcastNewValidBlockMessage(rs *cstypes.RoundState) {
Expand All @@ -457,10 +459,12 @@ func (conR *Reactor) broadcastNewValidBlockMessage(rs *cstypes.RoundState) {
BlockParts: rs.ProposalBlockParts.BitArray().ToProto(),
IsCommit: rs.Step == cstypes.RoundStepCommit,
}
conR.Switch.BroadcastEnvelope(p2p.Envelope{
ChannelID: StateChannel,
Message: csMsg,
})
go func() {
conR.Switch.BroadcastEnvelope(p2p.Envelope{
ChannelID: StateChannel,
Message: csMsg,
})
}()
}

// Broadcasts HasVoteMessage to peers that care.
Expand All @@ -471,10 +475,13 @@ func (conR *Reactor) broadcastHasVoteMessage(vote *types.Vote) {
Type: vote.Type,
Index: vote.ValidatorIndex,
}
conR.Switch.BroadcastEnvelope(p2p.Envelope{
ChannelID: StateChannel,
Message: msg,
})

go func() {
conR.Switch.BroadcastEnvelope(p2p.Envelope{
ChannelID: StateChannel,
Message: msg,
})
}()
/*
// TODO: Make this broadcast more selective.
for _, peer := range conR.Switch.Peers().List() {
Expand Down

0 comments on commit c6c4ecc

Please sign in to comment.