Skip to content

perf: Micro optimization to save one allocation per packet (backport … (backport #75)#80

Merged
PaddyMc merged 3 commits intoosmo-v25/v0.37.4from
mergify/bp/osmo-v25/v0.37.4/pr-75
May 28, 2024
Merged

perf: Micro optimization to save one allocation per packet (backport … (backport #75)#80
PaddyMc merged 3 commits intoosmo-v25/v0.37.4from
mergify/bp/osmo-v25/v0.37.4/pr-75

Conversation

@mergify
Copy link

@mergify mergify bot commented May 28, 2024

cometbft#3018) (cometbft#3023)

This PR is a slight optimization to save one allocation per packet. We have much more worthwhile performance improvements to pursue, just driveby noticed it as I was reading through the code. (Though I am surprised this did add up to 1 second in total -- 4% of the processing time)

This re-uses the byte reader's allocation across all ReadMsg's. There is no concurrenct access possible under safe usage (also implied by the reader)

This is the cause of the 1s time on the far right:

image


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

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

mergify bot and others added 2 commits May 28, 2024 09:50
…ometbft#3018) (cometbft#3023)

This PR is a slight optimization to save one allocation per packet. We
have much more worthwhile performance improvements to pursue, just
driveby noticed it as I was reading through the code. (Though I am
surprised this did add up to 1 second in total -- 4% of the processing
time)

This re-uses the byte reader's allocation across all ReadMsg's. There is
no concurrenct access possible under safe usage (also implied by the
reader)

This is the cause of the 1s time on the far right:

![image](https://github.com/cometbft/cometbft/assets/6440154/d6c6bfaa-d287-4355-b094-9bdcbc6379c8)

---

#### PR checklist

- [x] Tests written/updated - covered by existing tests
- [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#3018 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>
(cherry picked from commit ad8f851)
(cherry picked from commit dd19cb0)

# Conflicts:
#	CHANGELOG.md
@mergify
Copy link
Author

mergify bot commented May 28, 2024

Cherry-pick of dd19cb0 has failed:

On branch mergify/bp/osmo-v25/v0.37.4/pr-75
Your branch is ahead of 'origin/osmo-v25/v0.37.4' by 1 commit.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit dd19cb06a.
  (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)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   CHANGELOG.md

no changes added to commit (use "git add" and/or "git commit -a")

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

@PaddyMc PaddyMc merged commit 610d5cb into osmo-v25/v0.37.4 May 28, 2024
@mergify mergify bot deleted the mergify/bp/osmo-v25/v0.37.4/pr-75 branch May 28, 2024 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants