perf: remove duplicated rootkey fetch inpruning (9% pruning speedup on osmosis) (backport #1026) #1027
+27
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently delete version duplicatedly fetches rootkeys. This rootkey fetch does not go through the normal caching logic (as the rootkey fetch call does a direct call to the underlying database. Its not routed through the standard GetNode cache wrappers)
I did a 2 hour long block sync on osmosis, which got through 66000 blocks.
We should cache this root setting logic. Right now root key fetching is ~37% of the block pruning time during my latest sync. And block pruning is 40% of the overall sync time.
This PR does a quick cache to reduce from 4 calls to 3 calls. (TraverseOrphans has 2 calls as well) Ideally we can setup a second cache later on to ensure none of these DB calls get repeated, but for now wanted to keep it simple/uncontroversial with this PR, getting an 9% speedup to pruning's sync time component. (and ~4% to overall block sync)
Summary by CodeRabbit
New Features
Bug Fixes
This is an automatic backport of pull request #1026 done by [Mergify](https://mergify.com).