Skip to content

perf(consensus): Use TrySend for hasVote/HasBlockPart messages (backport #3407)#3466

Merged
melekes merged 3 commits intov1.xfrom
mergify/bp/v1.x/pr-3407
Jul 10, 2024
Merged

perf(consensus): Use TrySend for hasVote/HasBlockPart messages (backport #3407)#3466
melekes merged 3 commits intov1.xfrom
mergify/bp/v1.x/pr-3407

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Jul 10, 2024

Closes #3151

The broadcast routine in its entirely is the source of ~75% of all created channels in the system, all coming from the NewTimer call in Send. (and 75% of all NewTimer) Furthermore, the NewTimer call from Broadcast is 2% of all CPU time across the system. However I think this is actually more impact, due to the following.

We spend 11% of all CPU time in the scheduler, and 4% of all CPU time is CheckTimers in the scheduler logic. I'd expect reducing most of the Timer calls reduces this. We also reduce total mallocgc time here by 5% by removing NewTimer, which should hopefully reduce GC load as well.


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments
  • Title follows the Conventional Commits spec

This is an automatic backport of pull request #3407 done by [Mergify](https://mergify.com).

Closes #3151

The broadcast routine in its entirely is the source of ~75% of all
created channels in the system, all coming from the `NewTimer` call in
Send. (and 75% of all NewTimer) Furthermore, the NewTimer call from
Broadcast is 2% of all CPU time across the system. However I think this
is actually more impact, due to the following.

We spend 11% of all CPU time in the scheduler, and 4% of all CPU time is
`CheckTimers` in the scheduler logic. I'd expect reducing most of the
Timer calls reduces this. We also reduce total `mallocgc` time here by
5% by removing NewTimer, which should hopefully reduce GC load as well.

---

#### PR checklist

- [x] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [x] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Daniel <daniel.cason@informal.systems>
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
(cherry picked from commit 55493e0)

# Conflicts:
#	internal/consensus/reactor.go
#	p2p/switch.go
#	p2p/switch_test.go
@mergify mergify bot requested a review from a team as a code owner July 10, 2024 06:36
@mergify mergify bot added the conflicts label Jul 10, 2024
@mergify mergify bot requested a review from a team July 10, 2024 06:36
@mergify

This comment was marked as resolved.

@melekes melekes merged commit 5d438a2 into v1.x Jul 10, 2024
@melekes melekes deleted the mergify/bp/v1.x/pr-3407 branch July 10, 2024 07:08
ValarDragon added a commit to osmosis-labs/cometbft that referenced this pull request Aug 19, 2024
…ort cometbft#3407) (cometbft#3466)

Closes cometbft#3151

The broadcast routine in its entirely is the source of ~75% of all
created channels in the system, all coming from the `NewTimer` call in
Send. (and 75% of all NewTimer) Furthermore, the NewTimer call from
Broadcast is 2% of all CPU time across the system. However I think this
is actually more impact, due to the following.

We spend 11% of all CPU time in the scheduler, and 4% of all CPU time is
`CheckTimers` in the scheduler logic. I'd expect reducing most of the
Timer calls reduces this. We also reduce total `mallocgc` time here by
5% by removing NewTimer, which should hopefully reduce GC load as well.

---

- [x] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [x] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
<hr>This is an automatic backport of pull request cometbft#3407 done by
[Mergify](https://mergify.com).

---------

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants