Skip to content

Blocksim Benchmark#3247

Merged
cody-littley merged 8 commits intomainfrom
cjl/blocksim-stand-alone
Apr 22, 2026
Merged

Blocksim Benchmark#3247
cody-littley merged 8 commits intomainfrom
cjl/blocksim-stand-alone

Conversation

@cody-littley
Copy link
Copy Markdown
Contributor

@cody-littley cody-littley commented Apr 14, 2026

Created a benchmarking framework for the block DB. This benchmark currently exercises the write pathway. The read pathway benchmarking will come in a future PR.

@cody-littley cody-littley self-assigned this Apr 14, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 14, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedApr 22, 2026, 4:40 PM

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 11.07872% with 915 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.31%. Comparing base (cf0fb2d) to head (a7e48e1).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sei-db/ledger_db/block/blocksim/blocksim.go 0.00% 230 Missing ⚠️
sei-db/common/metrics/system_metrics.go 0.00% 162 Missing ⚠️
...ei-db/ledger_db/block/blocksim/blocksim_metrics.go 0.00% 120 Missing ⚠️
sei-db/common/utils/format.go 0.00% 101 Missing ⚠️
sei-db/ledger_db/block/blocksim/blocksim_config.go 0.00% 78 Missing ⚠️
...i-db/ledger_db/block/blocksim/cmd/blocksim/main.go 0.00% 63 Missing ⚠️
sei-db/ledger_db/block/blocksim/block_generator.go 0.00% 44 Missing ⚠️
sei-db/common/metrics/setup.go 0.00% 37 Missing ⚠️
sei-db/common/utils/config.go 0.00% 25 Missing ⚠️
...ger_db/block/blocksim/cmd/configure-logger/main.go 0.00% 25 Missing ⚠️
... and 5 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3247      +/-   ##
==========================================
- Coverage   58.55%   58.31%   -0.24%     
==========================================
  Files        2072     2085      +13     
  Lines      207968   208904     +936     
==========================================
+ Hits       121773   121823      +50     
- Misses      77420    78302     +882     
- Partials     8775     8779       +4     
Flag Coverage Δ
sei-chain-pr 23.48% <11.07%> (?)
sei-db 69.36% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-db/common/keys/evm.go 76.78% <66.66%> (ø)
...ei-db/ledger_db/block/mem_block_db/mem_block_db.go 97.91% <97.91%> (ø)
sei-db/common/rand/canned_random.go 54.66% <40.00%> (ø)
sei-db/common/utils/hash64.go 82.35% <82.35%> (ø)
sei-db/common/utils/path.go 65.51% <0.00%> (-34.49%) ⬇️
sei-db/common/utils/config.go 0.00% <0.00%> (ø)
...ger_db/block/blocksim/cmd/configure-logger/main.go 0.00% <0.00%> (ø)
sei-db/common/metrics/setup.go 0.00% <0.00%> (ø)
sei-db/ledger_db/block/blocksim/block_generator.go 0.00% <0.00%> (ø)
...i-db/ledger_db/block/blocksim/cmd/blocksim/main.go 0.00% <0.00%> (ø)
... and 5 more

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cody-littley cody-littley marked this pull request as ready for review April 15, 2026 18:00
Comment thread sei-db/block_db/block_db.go Outdated
@@ -0,0 +1,78 @@
package blockdb
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Recommend move blockDB code to ledger_db/block

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved

Comment on lines +197 to +201
// Periodic prune.
if blk.Height > b.config.UnprunedBlocks {
b.metrics.SetMainThreadPhase("prune")
lowestToKeep := blk.Height - b.config.UnprunedBlocks
if err := b.db.Prune(b.ctx, lowestToKeep); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The comment says periodic prune, but we are pruning for every block here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, fixed. Is now periodic. This was a bug.

Comment thread sei-db/state_db/bench/cryptosim/util.go Outdated

// ResolveAndCreateDir expands ~ to the home directory, resolves the path to
// an absolute path, and creates the directory if it doesn't exist.
func ResolveAndCreateDir(dataDir string) (string, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this dup func?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Yes, this was duplicated when I moved around code in feature branches. Deleted the duplicate.

b.totalBlocksWritten = 0
b.totalTransactionsWritten = 0
b.startTimestamp = time.Now()
fmt.Printf("Benchmark resumed.\n")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also reset b.totalBytesWritten = 0 here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, forgot that field. Fixed.

}

// openBlockDB creates a BlockDB for the given backend name.
func openBlockDB(backend string, dataDir string, unprunedBlocks uint64) (block.BlockDB, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems dataDir and unprunedBlocks params are not used

Copy link
Copy Markdown
Contributor Author

@cody-littley cody-littley Apr 22, 2026

Choose a reason for hiding this comment

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

unprunedBlocks does not belong here (removed). But the dataDir is going to be needed for DB implementations that write their data to disk. In my experimental branch, I've got two such implementations (pebble and littDB), but I didn't include those in this PR to reduce scope.

// The number of blocks to keep in the database after pruning.
UnprunedBlocks uint64

// Iniitate pruning every this many blocks.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typo: Initiate

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment thread sei-db/common/rand/canned_random.go Outdated
"github.com/sei-protocol/sei-chain/sei-db/common/utils"
)

const AddressLen = 20 // EVM address length
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we put this in sei-db/common/keys as it's not random number

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion, change made

@cody-littley cody-littley enabled auto-merge April 22, 2026 16:39
@cody-littley cody-littley added this pull request to the merge queue Apr 22, 2026
Merged via the queue into main with commit 0ddccd5 Apr 22, 2026
39 checks passed
@cody-littley cody-littley deleted the cjl/blocksim-stand-alone branch April 22, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants