Skip to content

perf(consensus): Reuse an internal buffer for block building (#3162)#99

Merged
ValarDragon merged 1 commit intoosmo/v0.37.4from
bp/3162
Jun 4, 2024
Merged

perf(consensus): Reuse an internal buffer for block building (#3162)#99
ValarDragon merged 1 commit intoosmo/v0.37.4from
bp/3162

Conversation

@ValarDragon
Copy link
Member

Makes an internal buffer that we can re-use when building blocks. This seems to save on average 75 microseconds per block for osmosis blocks. (Ranging between 1-2 block parts in the relevant time range) This should be scaling roughly linear with block size.

This lets us remove one allocation cost per complete block coming in. We only need to re-allocate on the next "biggest ever seen" block we see.


  • 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

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

…t#3162)

<!--

Please add a reference to the issue that this PR addresses and indicate
which
files are most critical to review. If it fully addresses a particular
issue,
please include "Closes #XXX" (where "XXX" is the issue number).

If this PR is non-trivial/large/complex, please ensure that you have
either
created an issue that the team's had a chance to respond to, or had some
discussion with the team prior to submitting substantial pull requests.
The team
can be reached via GitHub Discussions or the Cosmos Network Discord
server in
the #cometbft channel. GitHub Discussions is preferred over Discord as
it
allows us to keep track of conversations topically.
https://github.com/cometbft/cometbft/discussions

If the work in this PR is not aligned with the team's current
priorities, please
be advised that it may take some time before it is merged - especially
if it has
not yet been discussed with the team.

See the project board for the team's current priorities:
https://github.com/orgs/cometbft/projects/1

-->

Makes an internal buffer that we can re-use when building blocks. This
seems to save on average 75 microseconds per block for osmosis blocks.
(Ranging between 1-2 block parts in the relevant time range) This should
be scaling roughly linear with block size.

This lets us remove one allocation cost per complete block coming in. We
only need to re-allocate on the next "biggest ever seen" block we see.

---

- [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
@ValarDragon ValarDragon added the S:backport/v25 backport to the osmo-v25/v0.37.4 branch label Jun 4, 2024
@ValarDragon ValarDragon merged commit d9fedb5 into osmo/v0.37.4 Jun 4, 2024
ValarDragon added a commit that referenced this pull request Jun 4, 2024
…/pr-99

perf(consensus): Reuse an internal buffer for block building (cometbft#3162) (backport #99)
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