Repository navigation
Conversation
|
Warning Review limit reached
On-demand reviews are free for the next 27 days. After that, they cost $0.25 per reviewed file. Or wait 18 minutes for your next included review. View limit detailsLimit details: You’ve used all 5 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (9)
Comment |
| // maxLength boundary: maxLengthBits = 1 << 30. | ||
| { | ||
| const maxLengthBits = 1048576n; | ||
| const maxLengthBits = 1073741824n; |
There was a problem hiding this comment.
🟡 Three tests scaled to the new 1 << 30 boundary — bigint-inc-dec-in-place.js, bigint-exponential-oom.js, and big-int-out-of-memory-tests.js — should get //@ memoryHog! like the codegen tests did. They now allocate 128MB BigInts (the first holds several live at once), so they'll exceed the 200ms stress-test limit and may OOM on $memoryLimited runners (600MB cap) since without memoryHog! they run non-exclusively and aren't skipped there.
Extended reasoning...
What the issue is
This PR raises JSBigInt::maxLengthBits from 1 << 20 to 1 << 30 and scales the boundary tests accordingly — a 1024× increase from ~128KB BigInts to ~128MB BigInts. The PR correctly adds //@ memoryHog! to the three bigint-oom-in-codegen-*.js tests (which now build ~256MB source strings), but three other tests scaled by the same factor were left without it:
| Test | Directive before | Directive after | Now allocates |
|---|---|---|---|
bigint-inc-dec-in-place.js |
(none — runs in every config) | (none) | many 128MB values simultaneously |
bigint-exponential-oom.js |
(none — runs in every config) | (none) | 32MB and 128MB values |
big-int-out-of-memory-tests.js |
//@ runDefault(...) |
unchanged | 128MB all-ones + intermediates |
Since the same PR annotates the codegen tests, this looks like an oversight rather than a deliberate choice.
Why it matters
JSTests/README.md:19 requires stress tests to run in under 200ms in all configurations. Tools/Scripts/run-jsc-stress-tests:967-971 shows that memoryHog! does two things: it calls exclusive! (so the test doesn't run concurrently with other tests competing for RAM) and it skips the test entirely when $memoryLimited is set. On memory-limited runners, JSCTEST_memoryLimit is set to 600MB (line 3296), so a test that holds several 128MB BigInts live at once can hit a real allocator OOM and fail spuriously.
Step-by-step: bigint-inc-dec-in-place.js
This is the worst of the three because it has no //@ directive, so it runs in every stress configuration. Walking through the maxLength block at lines 86–112 with maxLengthBits = 1073741824n:
pow2(maxLengthBits - 1n)→ a 128MB BigInt.... - 1n,<< 1n,| 1n→ each produces a fresh 128MB BigInt; the last is bound tomaxand stays live for the whole block.shouldBe(dec(max), max - 1n)→ two more 128MB values, plus a 16M-digit!==comparison.shouldBe(inc(max - 1n), max)→ two more 128MB values.shouldBe(inc(-max), -(max - 1n))→ three more 128MB values.nearMax = max - pow2(maxLengthBits - 1n)→ two more 128MB values;nearMaxalso stays live.shouldBe(inc(nearMax), nearMax + 1n)→ two more.
With max and nearMax pinned by locals plus at least two temporaries per shouldBe, peak live-set is comfortably ≥4×128MB before GC can reclaim intermediates — over 512MB, and this runs in every config in parallel with other tests. On a $memoryLimited runner with a 600MB cap this can OOM outright; on any runner it will take multiple seconds, not <200ms.
bigint-exponential-oom.js is lighter (it materializes 2n ** 0xfffffffn ≈ 32MB and 2n ** 1073741823n = 128MB, each shifted right), but still has no directive so it runs in every config. big-int-out-of-memory-tests.js builds a 128MB all-ones value via (1n << 1073741823n) - 1n then << 1n | 1n (several 128MB intermediates) and only has //@ runDefault, which limits it to one config but doesn't set exclusive! or skip on memory-limited platforms.
Fix
Add //@ memoryHog! to the top of all three files (for big-int-out-of-memory-tests.js, add it alongside the existing //@ runDefault(...)). Alternatively, if you'd rather keep bigint-inc-dec-in-place.js fast in every config, the maxLength-boundary block could be split into its own memoryHog! file so the rest of the test still runs everywhere.
Severity
This is test-suite hygiene — the runtime change itself is correct and the tests pass — so it's a nit, but worth fixing to avoid CI flakiness on memory-limited bots and to keep stress-suite wall-clock in check.
Preview Builds
|
6cf2a37 to
7cc6d89
Compare
JSC capped a BigInt at 1 million bits, so workloads that run on Node.js (V8 allows 1 << 30 bits) failed with RangeError: Out of memory: BigInt generated from this operation is too big. oven-sh/WebKit#484 raises maxLengthBits to 1 << 30. Fixes #39964
JSBigInt::maxLengthBits was 1 million bits. V8 allows 1 << 30 bits, so BigInt workloads that run on Node.js failed here with RangeError: Out of memory: BigInt generated from this operation is too big, far from any real memory limit. The implementation supports maxInt / digitBits digits, so the constant can go up without code changes: every length check, the four static_asserts, and both toString paths (which already guard against JSString::MaxLength) hold at 1 << 30. Scale the JSTests that encode the old limit. The codegen OOM tests build their literals at runtime and move one hex digit past the new cap. bigint-oom-import.js imports a checked-in 1.05 million bit literal that cannot reasonably grow past 1 << 30 bits, so it now asserts the import succeeds.
7cc6d89 to
0de7d20
Compare
JSC capped a BigInt at 1 million bits, so workloads that run on Node.js (V8 allows 1 << 30 bits) failed with RangeError: Out of memory: BigInt generated from this operation is too big. oven-sh/WebKit#484 raises maxLengthBits to 1 << 30. Fixes #39964
|
Closing as superseded by #507, which is merged. #507 raises The bun-side WebKit bump for #507 is oven-sh/bun#40299. Issue oven-sh/bun#39964 is fixed by #507. |
Problem
JSC caps a BigInt at maxLengthBits = 1 << 20 bits (JSBigInt.h:527). Any operation past 1 million bits throws
RangeError: Out of memory: BigInt generated from this operation is too big. V8 allows 1 << 30 bits, so BigInt workloads that run on Node.js and Deno fail on Bun far from any real memory limit. oven-sh/bun#39964 hits this with a 3.5 million bit Fibonacci computation.Fix
Tests