Execution Guide
Tool versions
| Tool | Version used |
|---|---|
| Node.js | 23.11.0 |
| playwright-core | 1.62.1 |
| Chrome for Testing | 149.0.7827.55 (arm64) |
Browser resolution as in fe-01: $CHROME, newest Playwright cache build, then system Chrome.
Quick start
cd fe-03-object-shapes-and-jit/src
npm install
npm run ic # 1. inline caches: mono/poly/megamorphic (~15s)
npm run shapes # 2. hidden classes, delete, dictionary mode (~20s)
npm run arrays # 3. array element kinds (~25s)
npm run perspective # 4. what any of it is worth (~40s)
npm run all
Run perspective even if you skip the others. It is the module.
Tuning
ITER=10000000 npm run ic
N=1000000 npm run shapes
N=20000000 npm run arrays
Why every case gets a fresh page
Micro-benchmarks contaminate each other in ways that are silent and directional:
- Inline caches are per-site and persist. A shared helper function accumulates feedback across cases, so case 1 pays warm-up and case 4 inherits a warm-but-polymorphic function. This produced a backwards result while building the module.
- JIT tier is per-function and persists. By case 3, a function may be in TurboFan; case 1 ran in Sparkplug.
- The DOM persists. A case that appends 5,000 elements makes every later layout measurement enormous.
Fresh page per case costs ~150 ms of setup and removes all three. It is not optional.
Reading the harness
lib/bench.mjs addresses three standard micro-benchmark failures:
| Failure | Mitigation |
|---|---|
| Dead-code elimination removes the work | every benchmark returns a value, accumulated into window.__sink |
| Cold JIT dominates the first sample | 3 warm-up runs before measurement |
| Single-sample noise | median of 7 reps, with min/max retained |
It does not address: timer coarsening (performance.now() is quantised to ~0.1 ms in
non-isolated contexts, so keep per-rep work above ~5 ms), thermal throttling on long runs, or
other processes on the machine.
A warning about editing the page templates
Page scripts are embedded in JS template literals. A backtick anywhere inside them — including
inside a comment — terminates the template and produces a syntax error reported at a confusing
line. This happened twice while building this module. Write the (a[i] || 0) form, never
`a[i] || 0`, inside a page template.