forked from cometbft/cometbft
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from osmosis-labs/bp/3003
perf(blockstore): Add LRU caches to blockstore operations used in con…
- Loading branch information
Showing
8 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
.changelog/unreleased/improvements/3003-use-lru-caches-in-blockstore.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- [`blockstore`] Use LRU caches in blockstore, significiantly improving consensus gossip routine performance | ||
([\#3003](https://github.com/cometbft/cometbft/issues/3003) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package store | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cometbft/cometbft/internal/test" | ||
"github.com/cometbft/cometbft/libs/log" | ||
"github.com/cometbft/cometbft/types" | ||
cmttime "github.com/cometbft/cometbft/types/time" | ||
) | ||
|
||
// TestLoadBlockExtendedCommit tests loading the extended commit for a previously | ||
// saved block. The load method should return nil when only a commit was saved and | ||
// return the extended commit otherwise. | ||
func BenchmarkRepeatedLoadSeenCommitSameBlock(b *testing.B) { | ||
state, bs, cleanup := makeStateAndBlockStore(log.NewTMLogger(new(bytes.Buffer))) | ||
defer cleanup() | ||
h := bs.Height() + 1 | ||
block := state.MakeBlock(h, test.MakeNTxs(h, 10), new(types.Commit), nil, state.Validators.GetProposer().Address) | ||
seenCommit := makeTestCommit(block.Header.Height, cmttime.Now()) | ||
ps, err := block.MakePartSet(types.BlockPartSizeBytes) | ||
require.NoError(b, err) | ||
bs.SaveBlock(block, ps, seenCommit) | ||
|
||
// sanity check | ||
res := bs.LoadSeenCommit(block.Height) | ||
require.Equal(b, seenCommit, res) | ||
|
||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
res := bs.LoadSeenCommit(block.Height) | ||
require.NotNil(b, res) | ||
} | ||
} |
This file contains 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
This file contains 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