perf: avoid BigInt alloc in calculateTrackHash binary layout - #83
Draft
elicwhite wants to merge 1 commit into
Draft
perf: avoid BigInt alloc in calculateTrackHash binary layout#83elicwhite wants to merge 1 commit into
elicwhite wants to merge 1 commit into
Conversation
This was referenced Apr 20, 2026
Owner
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Apr 20, 2026
elicwhite
force-pushed
the
perf/track-hash-no-bigint
branch
from
April 20, 2026 14:34
83d3d10 to
cdee272
Compare
elicwhite
force-pushed
the
perf/blake-inline-mixing
branch
from
April 20, 2026 14:34
bb1eaf6 to
c64d521
Compare
DataView.setBigInt64 forces a BigInt argument. In calculateTrackHash, every tick and length — per tempo, time signature, star power, solo section, flex lane, freestyle section, and note — allocated a new BigInt object. For a dense track with 10k notes that's ~20k BigInt allocations per track hash, feeding GC. Charts are bounded: no tick or length approaches 2^31, let alone 2^63. Replace each `setBigInt64(i, BigInt(x), true)` with a local helper that writes two unsigned 32-bit LE words (low = x, high = 0). Output is byte-identical — BigInt(x) for any non-negative int32 produces the same 8-byte little-endian layout. Measured on autoresearch-scan (2000 charts, 8 workers, 3-run avg): previous: 2.80 ms mean (runs: 2.730, 2.876, 2.876) this: 2.67 ms mean (runs: 2.634, 2.667, 2.717) delta: −4.5% mean, max tail steady around 15-24 ms 0 hash mismatches across all runs, 442/442 tests green.
elicwhite
force-pushed
the
perf/blake-inline-mixing
branch
from
April 20, 2026 14:37
c64d521 to
6cde23e
Compare
elicwhite
force-pushed
the
perf/track-hash-no-bigint
branch
from
April 20, 2026 14:37
cdee272 to
36cdb6d
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.

DataView.setBigInt64 forces a BigInt argument. In calculateTrackHash,
every tick and length — per tempo, time signature, star power, solo
section, flex lane, freestyle section, and note — allocated a new
BigInt object. For a dense track with 10k notes that's ~20k BigInt
allocations per track hash, feeding GC.
Charts are bounded: no tick or length approaches 2^31, let alone 2^63.
Replace each
setBigInt64(i, BigInt(x), true)with a local helperthat writes two unsigned 32-bit LE words (low = x, high = 0). Output
is byte-identical — BigInt(x) for any non-negative int32 produces the
same 8-byte little-endian layout.
Measured on autoresearch-scan (2000 charts, 8 workers, 3-run avg):
previous: 2.80 ms mean (runs: 2.730, 2.876, 2.876)
this: 2.67 ms mean (runs: 2.634, 2.667, 2.717)
delta: −4.5% mean, max tail steady around 15-24 ms
0 hash mismatches across all runs, 442/442 tests green.