perf: inline @noble/hashes G1s/G2s into blake2 compress - #82
Draft
elicwhite wants to merge 1 commit into
Draft
Conversation
This was referenced Apr 20, 2026
Owner
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Apr 20, 2026
elicwhite
changed the base branch from
perf/avoid-spread-in-writer
to
graphite-base/82
April 20, 2026 14:34
elicwhite
force-pushed
the
perf/blake-inline-mixing
branch
from
April 20, 2026 14:34
bb1eaf6 to
c64d521
Compare
elicwhite
force-pushed
the
graphite-base/82
branch
from
April 20, 2026 14:34
1e3c27b to
2daa2a6
Compare
@noble/hashes uses a pattern where G1s and G2s each return a fresh
{ a, b, c, d } object per call, destructured by the caller inside the
compression loop. In the chart-hasher path this is ~112 object
allocations per compress call (16 G-calls × 7 rounds for blake3),
dominating GC and showing up as 30–35% of scanner CPU time in the
profile.
Inline both G functions directly into compress, writing through the
v0..v15 locals via a scratch `t` temp. Semantics are byte-identical
to upstream — the inlining only removes the allocation wrapper.
Measured on the scan-perf autoresearch bench (2000 charts, 8 workers):
baseline (tip of perf stack):
mean 6.156 ms, p50 5.299 ms, p95 13.818 ms, p99 20.051 ms, max 33.346 ms
this patch:
mean 2.730 ms, p50 2.223 ms, p95 6.952 ms, p99 10.165 ms, max 16.368 ms
delta: −55.7% mean, −49.7% p95, −50.9% max
(2.26× speedup on scanner)
0 hash mismatches across 2000 charts — byte-identical ScannedChart
output. 442/442 scan-chart tests still green.
The patch is stored at patches/@noble+hashes+1.8.0.patch and applies
via patch-package on install.
elicwhite
force-pushed
the
perf/blake-inline-mixing
branch
from
April 20, 2026 14:37
c64d521 to
6cde23e
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

@noble/hashes uses a pattern where G1s and G2s each return a fresh
{ a, b, c, d } object per call, destructured by the caller inside the
compression loop. In the chart-hasher path this is ~112 object
allocations per compress call (16 G-calls × 7 rounds for blake3),
dominating GC and showing up as 30–35% of scanner CPU time in the
profile.
Inline both G functions directly into compress, writing through the
v0..v15 locals via a scratch
ttemp. Semantics are byte-identicalto upstream — the inlining only removes the allocation wrapper.
Measured on the scan-perf autoresearch bench (2000 charts, 8 workers):
baseline (tip of perf stack):
mean 6.156 ms, p50 5.299 ms, p95 13.818 ms, p99 20.051 ms, max 33.346 ms
this patch:
mean 2.730 ms, p50 2.223 ms, p95 6.952 ms, p99 10.165 ms, max 16.368 ms
delta: −55.7% mean, −49.7% p95, −50.9% max
(2.26× speedup on scanner)
0 hash mismatches across 2000 charts — byte-identical ScannedChart
output. 442/442 scan-chart tests still green.
The patch is stored at patches/@noble+hashes+1.8.0.patch and applies
via patch-package on install.