Skip to content

mpt: benchmark unrolled-nbl-hashes-sha3 for keccak256 speedup#4272

Open
gabrocheleau wants to merge 1 commit into
masterfrom
mpt/keccak-performance
Open

mpt: benchmark unrolled-nbl-hashes-sha3 for keccak256 speedup#4272
gabrocheleau wants to merge 1 commit into
masterfrom
mpt/keccak-performance

Conversation

@gabrocheleau
Copy link
Copy Markdown
Contributor

@gabrocheleau gabrocheleau commented Mar 31, 2026

Summary

  • Adds standalone keccak256 microbenchmark comparing @noble/hashes vs unrolled-nbl-hashes-sha3 (ref VM performance meta-issue #3227)
  • Extends MPT benchmark suite to accept a configurable hash function for side-by-side trie-level comparison
  • Fixes micro-bmark import compatibility (logMemutils.logMem, removes non-exported run)

Benchmark Results

Raw keccak256 throughput

Input Size @noble/hashes unrolled-nbl-hashes-sha3 Speedup
32 bytes 37,738 ops/s 151,653 ops/s 4.0x
100 bytes 36,903 ops/s 201,085 ops/s 5.4x
500 bytes 9,523 ops/s 62,123 ops/s 6.5x
2000 bytes 2,497 ops/s 17,301 ops/s 6.9x

MPT trie-level benchmarks

No measurable difference at trie level — DB I/O and RLP encoding dominate

Evaluate unrolled-nbl-hashes-sha3 as suggested in #3227 to speed up
keccak256 hashing. Adds a standalone microbenchmark and extends the
existing MPT benchmark suite to accept a configurable hash function,
enabling side-by-side comparison of @noble/hashes vs the unrolled variant.

Microbenchmark results show 4-7x raw hash throughput improvement.
Also fixes micro-bmark import compatibility (logMem -> utils.logMem,
run() removed as it is not exported in current version).
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.20%. Comparing base (1bbbf50) to head (a623bab).

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 87.33% <ø> (ø)
blockchain 88.82% <ø> (ø)
common 93.44% <ø> (ø)
evm 61.22% <ø> (ø)
mpt 89.64% <ø> (ø)
statemanager 78.04% <ø> (ø)
static 91.35% <ø> (ø)
tx 88.01% <ø> (ø)
util 80.83% <ø> (ø)
vm 55.45% <ø> (ø)

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

🚀 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.

@github-actions
Copy link
Copy Markdown

📦 Bundle Size Analysis

Package Size (min+gzip) Δ
binarytree 17.5 KB ⚪ ±0%
block 43.7 KB ⚪ ±0%
blockchain 69.8 KB ⚪ ±0%
common 25.4 KB ⚪ ±0%
devp2p 17.7 KB ⚪ ±0%
e2store 87.2 KB ⚪ ±0%
ethash 61.7 KB ⚪ ±0%
evm 62.5 KB ⚪ ±0%
genesis 272.2 KB ⚪ ±0%
mpt 21.9 KB ⚪ ±0%
rlp 1.7 KB ⚪ ±0%
statemanager 41.2 KB ⚪ ±0%
testdata 43.8 KB ⚪ ±0%
tx 20.8 KB ⚪ ±0%
util 13.2 KB ⚪ ±0%
vm 154.6 KB ⚪ ±0%
wallet 15.0 KB ⚪ ±0%

Values are minified+gzipped bundles of each package entry. Workspace deps are bundled; external deps are excluded.

Generated by bundle-size workflow

@paulmillr
Copy link
Copy Markdown
Contributor

https://github.com/paulmillr/awasm-noble went live now. Try it out:

import { keccak256 } from '@awasm/noble'; // wasm
import { keccak256 } from '@awasm/noble/wasm_threads.js'; // +threads
import { keccak256 } from '@awasm/noble/js.js'; // faster JS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants