Quench.
MEASURINGMEMORY

blog / · 3 min read · measurement

Your peak RSS depends on which CPU you ran on

The same binary reported peak memory anywhere from 2,436 to 2,824 KiB across 20 runs. Four things we learned about measuring a JavaScript engine's memory before we could trust a single number.

Quench has a memory goal as well as a speed goal, so in October 2026 we built a scoreboard that failed any row where peak memory was more than 0.8 times the best other engine. Then rows started passing and failing without any code change.

1. Since Linux 6.2, RSS is counted per CPU

One RayTrace binary read 2,436 KiB of peak memory in one run and 2,592 KiB in another, pinned to a core. Across 20 runs the same binary ranged from 2,436 to 2,824.

Peak RSS of one unchanged binary, RayTrace, 25 October 2026lowest unpinned run2,436 KiBpinned to one core2,592 KiBhighest unpinned run2,824 KiB
Twenty unpinned runs of the same binary spanned this range. With a pass line within 5% of the target, CPU migration decided pass or fail.

Since Linux 6.2 the kernel keeps the RSS counters per CPU and reconciles them lazily. A process that migrates between cores can have its peak read low. The fix is boring: pin the process to one core for every memory measurement. The scoreboard does that now, and reports the worst of several pinned runs.

2. Address space layout changes instruction counts

We use callgrind instruction counts for speed decisions because they repeat exactly. Except they did not: with address space randomization on, the main thread's count flipped between two levels about 4.6% apart, depending on where things landed. A/B comparisons now run with randomization off.

3. The profile you train on is a hidden input

Our release builds are laid out by BOLT using a recorded profile. A scratch recipe passed three boards in a row. The identical recipe in the repository failed all three.

The difference was one line in a package.json. It had "type": "module", so every file in the training corpus loaded as an ES module, and the CommonJS loading path was never profiled. The hot code for CommonJS programs was laid out as if it were cold. Retraining moved single rows by 100 to 250 KiB.

4. The memory policy that was a code layout problem

We had a memory-first mode that released code pages at every collection. It met the memory target on six of eight benchmarks and cost 17 to 30% of the score on four. The obvious reading: collecting more often is slow.

The obvious reading was wrong. Turning off code release alone gave RayTrace 28% of its score back for 192 KiB of memory. The collector was fine. The time was going to page faults, bringing back code that had just been released and was needed again straight away.

+28%
RayTrace score

with code release off

+192 KiB
memory cost

of keeping the code

1,333
full collections

over about 2,900 live objects

A release policy cannot fix that. What fixes it is layout: keep the code a running program needs on pages that are never released, and release only what is truly cold.

What the board looked like once we trusted it

With pinning, fixed layout and a correct profile, the memory-first board on 27 October read as follows.

Worst-run peak RSS, V8-v7 benchmarks, 27 October 2026 (KiB)QuenchQuickJS (lowest other engine)Richards2,2363,556DeltaBlue2,7443,888Crypto2,8043,848RayTrace2,6723,596EarleyBoyer6,06417,932RegExp5,2447,156NavierStokes3,8325,316Splay31,73661,308
Five runs each, worst run shown, memory-first mode. QuickJS had the lowest memory of the other engines on every row. This is the mode that costs score, as described above.

Quench used between 0.34 and 0.74 times the memory of the next-lowest engine on every row. That mode was not the default, because of the score cost. The point of the chart is that the numbers held still long enough to argue about.

The checklist

  • Pin to one core for memory. Report the worst of several runs.
  • Turn off address randomization for instruction-count comparisons.
  • Treat the training profile as source code. Review what it actually exercised.
  • When a policy costs speed, find out where the time went before tuning the policy.
  • Copy the binary before measuring a cold start, because you cannot evict pages a running process still maps.

Try it

Quench builds from source with Cargo and runs TypeScript, JavaScript and WebAssembly.

Build and run

Work on it

Interpreter, JIT, AOT, GC, Node APIs. Every claim on this blog has a measurement you can rerun.

Where to start

Follow it

New posts land here as the engine moves. Star the repository or subscribe to the feed.

Star on GitHub Feed