8000 perf(p2p/connection): Lower wasted re-allocations in sendRoutine (backport #2986) by mergify[bot] · Pull Request #2994 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

perf(p2p/connection): Lower wasted re-allocations in sendRoutine (backport #2986) #2994

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

Merged
merged 2 commits into from
May 3, 2024

Conversation

mergify[bot]
Copy link
Contributor
@mergify mergify bot commented May 3, 2024

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

  • Tests written/updated - should be covered by existing tests
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments - I actually this is simpler/dont see anything to update
  • Title follows the Conventional Commits spec

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

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

(cherry picked from commit ab1c7bc)

# Conflicts:
#	p2p/conn/connection.go
Copy link
Contributor Author
mergify bot commented May 3, 2024

Cherry-pick of ab1c7bc has failed:

On branch mergify/bp/v0.38.x/pr-2986
Your branch is up to date with 'origin/v0.38.x'.

You are currently cherry-picking commit ab1c7bc05.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   .changelog/unreleased/improvements/2986-lower-memory-allocation-in-packet-writing.md

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   p2p/conn/connection.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify bot requested a review from a team as a code owner May 3, 2024 11:09
@mergify mergify bot added the conflicts label May 3, 2024
@melekes melekes merged commit ad18292 into v0.38.x May 3, 2024
21 checks passed
@melekes melekes deleted the mergify/bp/v0.38.x/pr-2986 branch May 3, 2024 11:53
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
0