Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(p2p/connection): Lower wasted re-allocations in sendRoutine (bac… #97

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

ValarDragon
Copy link
Member

…kport cometbft#2986) (cometbft#2995)

This PR makes sending packet messages re-use the protowriter for writing to the channel, rather than remaking it in writePacketMsgTo.

In a 1 hour sync benchmark, this saves 10% of the time spent in the sendRoutine (6s), and saves 13GB of heap allocation.

This is a simple fix, so I think its worth doing. Later on, I think we should move this proto-marshalling to mConnection.Send, but that change will require more robust testing, as it would be a tradeoff of increasing the CPU time of gossipVotesRoutine and
gossipBlockPartRoutine. (I personally think it will be worth it / were anyways lowering the CPU time of these routines in total) Will be writing this later direction idea into an issue.


PR checklist



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

…kport cometbft#2986) (cometbft#2995)

This PR makes sending packet messages re-use the protowriter for writing
to the channel, rather than remaking it in `writePacketMsgTo`.

In a 1 hour sync benchmark, this saves 10% of the time spent in the
`sendRoutine` (6s), and saves 13GB of heap allocation.

This is a simple fix, so I think its worth doing. Later on, I think we
should move this proto-marshalling to `mConnection.Send`, but that
change will require more robust testing, as it would be a tradeoff of
increasing the CPU time of gossipVotesRoutine and
gossipBlockPartRoutine. (I personally think it will be worth it / were
anyways lowering the CPU time of these routines in total) Will be
writing this later direction idea into an issue.

---

#### PR checklist

- [x] Tests written/updated - should be covered by existing tests
- [ ] 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 - I actually this is simpler/dont see anything to update
- [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#2986 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>
@ValarDragon ValarDragon added the S:backport/v25 backport to the osmo-v25/v0.37.4 branch label Jun 3, 2024
@ValarDragon ValarDragon merged commit 62f2334 into osmo/v0.37.4 Jun 3, 2024
17 of 18 checks passed
ValarDragon added a commit that referenced this pull request Jun 4, 2024
…pr-97

perf(p2p/connection): Lower wasted re-allocations in sendRoutine (bac… (backport #97)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S:backport/v25 backport to the osmo-v25/v0.37.4 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant