Skip to content

perf(blockstore)!: Cache more in blockstore, which speedsup the gossip routines#3342

Merged
melekes merged 3 commits intomainfrom
dev/speedup_blockstore
Jun 26, 2024
Merged

perf(blockstore)!: Cache more in blockstore, which speedsup the gossip routines#3342
melekes merged 3 commits intomainfrom
dev/speedup_blockstore

Conversation

@ValarDragon
Copy link
Contributor

@ValarDragon ValarDragon commented Jun 26, 2024

We speedup the gossip routines by using caches for LoadBlockPart, and making LoadBlockCommit no longer call Clone, as the caller does read-only operations to it.

This is a followup to #3003

This results in a net performance improvement, based on a 2hr sync on latest osmosis release, of:

  • 20% less RAM allocated over program lifetime. (76GB no longer allocated, 380 GB alloc total)
  • 50% speedup to gossipDataRoutine
  • ~10% speedup to gossipVotesRoutine
  • 1% less overall system CPU usage. (If GC proportional to bytes allocated, then 5% less)

I have checked that every usage of LoadBlockPart and LoadBlockCommit do not modify the return value, so returning this underlying cache copy is safe for the current codebase

I used an ! in the title, since this is technically API breaking, even though all current usages are safe.


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 done by using caches for LoadBlockPart, and making
LoadBlockCommit no longer call Clone, as the caller does read-only operations
to it.

This results in a net performance improvement, based on a
2hr sync on latest osmosis release, of:
- 20% less RAM allocated over program lifetime. (76GB no longer allocated, 380 GB alloc total)
- 50% speedup to gossipDataRoutine
- ~10% speedup to gossipVotesRoutine
- 1% less overall system CPU usage. (If GC proportional to bytes allocated, then 5% less)
@ValarDragon ValarDragon requested a review from a team as a code owner June 26, 2024 03:55
@ValarDragon ValarDragon requested a review from a team June 26, 2024 03:55
@ValarDragon ValarDragon changed the title perf(consensus): Speedup / reduce overhead of the gossip routines, by caching more in blockstore perf(consensus)!: Speedup / reduce overhead of the gossip routines, by caching more in blockstore Jun 26, 2024
@ValarDragon ValarDragon changed the title perf(consensus)!: Speedup / reduce overhead of the gossip routines, by caching more in blockstore perf(blockstore)!: Cache more in blockstore, which speedsup the gossip routines Jun 26, 2024
Copy link
Collaborator

@melekes melekes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ValarDragon ❤️

@melekes melekes added this pull request to the merge queue Jun 26, 2024
Merged via the queue into main with commit 2c88a26 Jun 26, 2024
@melekes melekes deleted the dev/speedup_blockstore branch June 26, 2024 10:06
ValarDragon added a commit to osmosis-labs/cometbft that referenced this pull request Jun 26, 2024
…p routines cometbft#3342  (#116)

* Speedup / reduce overhead of the gossip routines.

This is done by using caches for LoadBlockPart, and making
LoadBlockCommit no longer call Clone, as the caller does read-only operations
to it.

This results in a net performance improvement, based on a
2hr sync on latest osmosis release, of:
- 20% less RAM allocated over program lifetime. (76GB no longer allocated, 380 GB alloc total)
- 50% speedup to gossipDataRoutine
- ~10% speedup to gossipVotesRoutine
- 1% less overall system CPU usage. (If GC proportional to bytes allocated, then 5% less)

* Add changelog

* Make caches respect pruning

* Add changelog

* Remove concerns

* Use my upstream fixes
@melekes
Copy link
Collaborator

melekes commented Jul 10, 2024

@mergify backport v1.x

@mergify
Copy link
Contributor

mergify bot commented Jul 10, 2024

backport v1.x

✅ Backports have been created

Details

mergify bot pushed a commit that referenced this pull request Jul 10, 2024
…p routines (#3342)

We speedup the gossip routines by using caches for LoadBlockPart, and
making LoadBlockCommit no longer call Clone, as the caller does
read-only operations to it.

This is a followup to #3003

This results in a net performance improvement, based on a 2hr sync on
latest osmosis release, of:
- 20% less RAM allocated over program lifetime. (76GB no longer
allocated, 380 GB alloc total)
- 50% speedup to gossipDataRoutine
- ~10% speedup to gossipVotesRoutine
- 1% less overall system CPU usage. (If GC proportional to bytes
allocated, then 5% less)

I have checked that every usage of `LoadBlockPart` and `LoadBlockCommit`
do not modify the return value, so returning this underlying cache copy
is safe for the current codebase

I used an `!` in the title, since this is technically API breaking, even
though all current usages are safe.

---

#### PR checklist

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

(cherry picked from commit 2c88a26)
melekes pushed a commit that referenced this pull request Jul 10, 2024
…p routines (backport #3342) (#3482)

We speedup the gossip routines by using caches for LoadBlockPart, and
making LoadBlockCommit no longer call Clone, as the caller does
read-only operations to it.

This is a followup to #3003

This results in a net performance improvement, based on a 2hr sync on
latest osmosis release, of:
- 20% less RAM allocated over program lifetime. (76GB no longer
allocated, 380 GB alloc total)
- 50% speedup to gossipDataRoutine
- ~10% speedup to gossipVotesRoutine
- 1% less overall system CPU usage. (If GC proportional to bytes
allocated, then 5% less)

I have checked that every usage of `LoadBlockPart` and `LoadBlockCommit`
do not modify the return value, so returning this underlying cache copy
is safe for the current codebase

I used an `!` in the title, since this is technically API breaking, even
though all current usages are safe.

---

#### PR checklist

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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants