• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

philihp / pcg / 26154403933
100%

Build:
DEFAULT BRANCH: main
Ran 20 May 2026 09:40AM UTC
Jobs 1
Files 6
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

20 May 2026 09:40AM UTC coverage: 99.541% (-0.5%) from 100.0%
26154403933

push

github

web-flow
perf: replace BigInt math with Uint64 hi/lo number arithmetic (#337)

* perf: replace BigInt arithmetic with Uint64 hi/lo number ops

The PCG hot paths (nextState, getOutput, randomInt) used BigInt
multiplications and shifts which are about an order of magnitude slower
than native number arithmetic on V8. Replace the BigInt math with a
small Uint64 helper module that operates on the {hi, lo} pair already
present in PCGState, using 16-bit lane decomposition for mul64 so
intermediate products stay within IEEE-754's exact integer range.

Output functions and the Brown jump-ahead in stepState now run entirely
on numbers. The output functions accept Uint64 directly instead of a
BigInt, so the per-call toBigInt/fromBigInt round-trip is gone too.
BigInt remains only at construction time, where LongLike seeds may be
bigger than 53 bits.

Also drops the PCGVariant registry: there is only one variant, so the
runtime lookup added cost without buying anything. createPcg32 is now a
plain function and PCGState no longer carries a variant tag. The
obsolete unknown-variant test goes with it.

Microbenchmark on Node 22 (1M iterations):
  nextState:  415ms -> 59ms  (~7x)
  randomInt:  858ms -> 186ms (~4.6x)
  getOutput:  228ms -> 5ms   (~45x)

https://claude.ai/code/session_013DgDaw4YJuA2Au68v3BKCa

* perf: use Math.imul in mul64 to skip lane carry-propagation

The low 32 bits of a 64-bit unsigned product mod 2^64 are exactly the
low 32 bits of (a.lo * b.lo), so Math.imul gives them directly and
sidesteps the carry-propagation loop. The high 32 bits still require
the 16-bit lane split for one product, but the cross-term contributions
(a.lo * b.hi, a.hi * b.lo) only affect the high half mod 2^64 and so
can also go through Math.imul.

V8 inlines Math.imul to a single machine multiply, so the new mul64
runs ~20% faster in microbenchmarks and ~28% faster in nextState
end-to-end (59ms -> 42ms per 1M iterations on Node 22).

All 65 tests, including the BigInt cross-check swe... (continued)

43 of 44 branches covered (97.73%)

Branch coverage included in aggregate %.

114 of 114 new or added lines in 3 files covered. (100.0%)

174 of 174 relevant lines covered (100.0%)

20336.11 hits per line

Jobs
ID Job ID Ran Files Coverage
1 26154403933.1 20 May 2026 09:40AM UTC 6
99.54
GitHub Action Run
Source Files on build 26154403933
  • Tree
  • List 6
  • Changed 3
  • Source Changed 0
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • 31e211b7 on github
  • Prev Build on refs/tags/v2.0.0 (#26066568947)
  • Next Build on main (#26155529220)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc