Skip to content

perf(rust): BigInt in the value word under 31 bits, in its heap slot up to 128 - #90

Merged
kommander merged 1 commit into
devfrom
perf/stack-07-bigint
Nov 26, 2026
Merged

kommander merged 1 commit into
devfrom
perf/stack-07-bigint

Conversation

@hearnadam

Copy link
Copy Markdown
Contributor

Every BigInt result was a heap slot, a box, a digit vector and a hash. Under 31
bits it is now in the id of its Value::Big, with no object; up to 128 bits it
is in place in one heap slot, with machine arithmetic; larger, the slot holds a
boxed num_bigint as before. Each value has exactly one form, so equality and
Map keys still compare ids. JavaScriptCore has only the heap form (its inline
BigInt32 was never enabled, and was removed in 2026).

64-bit FNV hash, 100k rounds: 640M to 409M instructions, 44.6 to about 17 ms.
Checked against Bun on 8,385 results across the 31-, 64- and 128-bit
boundaries.


Part 7 of 11 in a stack; based on perf/stack-06-gc-while-waiting. Each part was built, linted and tested on its own (cargo test --release --workspace, the same under PSYCHOSCRIPT_GC_STRESS=1, and the conformance cases under PSYCHOSCRIPT_ROUNDTRIP=1). Numbers are instructions retired, from rust/bench/examples/corpus and mem_probe (part 1).

@hearnadam
hearnadam added this pull request to stack #95 November 26, 2026 17:17
@hearnadam
hearnadam force-pushed the perf/stack-07-bigint branch from 4a78136 to ae7c629 Compare November 26, 2026 17:20
@kommander
kommander force-pushed the perf/stack-07-bigint branch 4 times, most recently from cc33123 to 375fdbf Compare November 26, 2026 22:52
Base automatically changed from perf/stack-06-gc-while-waiting to dev November 26, 2026 22:54
…up to 128

Every BigInt result was a heap slot, a box, a digit vector and a hash. Under 31
bits it is now in the id of its Value::Big, with no object; up to 128 bits it
is in place in one heap slot, with machine arithmetic; larger, the slot holds a
boxed num_bigint as before. Each value has exactly one form, so equality and
Map keys still compare ids. JavaScriptCore has only the heap form (its inline
BigInt32 was never enabled, and was removed in 2026).

64-bit FNV hash, 100k rounds: 640M to 409M instructions, 44.6 to about 17 ms.
Checked against Bun on 8,385 results across the 31-, 64- and 128-bit
boundaries.
@kommander
kommander force-pushed the perf/stack-07-bigint branch from 375fdbf to be65e21 Compare November 26, 2026 22:54
@kommander
kommander merged commit d857b24 into dev Nov 26, 2026
1 check passed
@kommander
kommander deleted the perf/stack-07-bigint branch November 26, 2026 22:55
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