perf(txindex): search optimization (backport #3458)#3552
Merged
sergio-mena merged 1 commit intov0.38.x-experimentalfrom Jul 25, 2024
Merged
perf(txindex): search optimization (backport #3458)#3552sergio-mena merged 1 commit intov0.38.x-experimentalfrom
sergio-mena merged 1 commit intov0.38.x-experimentalfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Collaborator
|
Blocked on #3555 |
Collaborator
This PR addresses several optimization points for TxIndex.Search:
1. Remove expensive map access from sorting function
2. Replace sort.Slice to sort.Sort with sorter approach
3. Reduce heap allocations from extractEventSeqFromKey
benchstat result:
```
goos: darwin
goarch: amd64
pkg: github.com/cometbft/cometbft/state/txindex/kv
cpu: Intel(R) Core(TM) i9-10910 CPU @ 3.60GHz
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
TxSearchBigResult-20 3236.1m ± 7% 945.9m ± 9% -70.77% (p=0.002 n=6)
│ old.txt │ new.txt │
│ B/op │ B/op vs base │
TxSearchBigResult-20 426.1Mi ± 0% 311.6Mi ± 0% -26.86% (p=0.002 n=6)
│ old.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
TxSearchBigResult-20 4.040M ± 0% 2.040M ± 0% -49.51% (p=0.002 n=6)
```
- [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
---------
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
c5ad22e to
c482b9e
Compare
Collaborator
|
Ready for review |
Collaborator
|
@ValarDragon if you pick up this PR for testing in Osmosis, don't forget you first need to take #3556 (a backport of #2855) to avoid massive conflicts (as explained here) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR addresses several optimization points for TxIndex.Search:
benchstat result:
PR checklist
.changelog(we use unclog to manage our changelog)docs/orspec/) and code commentsThis is an automatic backport of pull request #3458 done by [Mergify](https://mergify.com).