Skip to content

mpt: awasm noble keccak | Benchmark comparison#4278

Open
gabrocheleau wants to merge 2 commits into
masterfrom
perf/awasm-noble-keccak
Open

mpt: awasm noble keccak | Benchmark comparison#4278
gabrocheleau wants to merge 2 commits into
masterfrom
perf/awasm-noble-keccak

Conversation

@gabrocheleau
Copy link
Copy Markdown
Contributor

This PR adds some awasm noble keccak benchmarking as suggested by @paulmillr in #3227
Here are the benchmarks results on my machine (temporarily from an old macbook pro so your mileage may vary)

size @noble/hashes wasm js.js wasm_threads
32 B 8.5 kH/s 128.7 kH/s (15.1×) 32.7 kH/s (3.8×) 174.9 kH/s (20.6×)
256 B 5.0 kH/s 48.5 kH/s (9.6×) 18.4 kH/s (3.7×) 35.7 kH/s (7.1×)
1 KiB 1.1 kH/s 15.7 kH/s (14.8×) 4.7 kH/s (4.5×) 17.3 kH/s (16.3×)
4 KiB 234 H/s 5.8 kH/s (25.0×) 1.7 kH/s (7.3×) 5.6 kH/s (23.8×)
64 KiB 26 H/s 269 H/s (10.2×) 32 H/s (1.2×) 440 H/s (16.7×)

Admin added 2 commits April 23, 2026 12:21
Adds a dedicated keccak256 throughput benchmark comparing
@noble/hashes (current baseline) against the three variants
shipped by @awasm/noble: wasm, faster-JS, and wasm_threads.

Run with: npx tsx benchmarks/keccak.ts
Single-process measurement made the @noble/hashes baseline go
polymorphic across the four hash fns and get deopted, skewing
the comparison. Each impl now runs in its own child so V8 can
monomorphize the call site.

Also switched to a fixed-duration measure loop and a summary
row of min/avg/max speedup vs baseline.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.20%. Comparing base (b3ea7a4) to head (1809ebd).

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

@holgerd77
Copy link
Copy Markdown
Member

This is really interesting. I think we should not directly fully switching, people are likely not that quick with updating their "no WASM in our libraries" policies (this can realistically still take quite some time), but I guess we could do a second "on the libraries" run/test using our custom crypto logic/handing from Common and - if this plays out in a similar way - integrate this structurally and really prominently in the docs that people should use if they care about performance.

@paulmillr Do you regard these libraries already as mature/safe or are there rather still in the "be a bit careful for the first months" period?

@holgerd77 holgerd77 changed the title mpt: awasm noble keccak mpt: awasm noble keccak | Benchmark comparison May 12, 2026
@paulmillr
Copy link
Copy Markdown
Contributor

paulmillr commented May 12, 2026

@holgerd77 I would say it's production-ready for ordinary apps. It passes all noble tests. It's fine to use it as a secondary optional backend.

For wallets specifically, I would wait for a year or so. For something like "building an eth node" it's fine to use it today.

Year because that's approximation it would take for a community adoption, which could happen earlier, or later. Perhaps someone would also audit it, although LLM-assisted self-audits were much more productive versus third-parties.

@holgerd77
Copy link
Copy Markdown
Member

@paulmillr makes sense, thanks!

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