perf: BytesView pattern matching for hash + benchmarks#3278
Conversation
|
Updated the PR branch to commit Benchmarked with: moon version
# moon 0.1.20260423 (48eeec5 2026-04-23)
moon bench --target native -p moonbitlang/core/benchResults on native:
Also checked semantics with: moon test builtin/hasher_test.mbt --target native
# Total tests: 18, passed: 18, failed: 0.So on this toolchain the |
|
I noticed regression on Js backend so I just made this draft. |
|
The problem with js/wasm-gc backend is caused by the unnecessary view wrapper compared with the original implementation. Should we make the optimization platform specific? @bobzhang |
|
Updated the PR branch to commit Benchmarked with: Results, comparing baseline/manual,
Takeaway: Checked semantics/build after rebasing onto |
Coverage Report for CI Build 4242Coverage decreased (-0.002%) to 94.613%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Summary
Hasher::combine_bytesandHash for BytesViewto use[u32le(x), .. rest]pattern matching instead of manual index arithmetic withendian32endian32helper functionBytesandBytesViewat 16B / 256B / 4KB sizesBenchmark results (native)
The pattern matching version is currently ~3x slower than the original:
This is filed as a compiler optimization opportunity — the
[u32le(x), .. rest]view pattern should ideally compile down to the same code as manual indexing, but currently creates a newBytesViewon each loop iteration.Test plan
🤖 Generated with Claude Code