Repository navigation
Description
Opt target 3 — pipeline: 1.18x Node, but 1.85x instructions at 1.05x cycles
This one is a different animal from the other two, and the difference is the whole ticket.
Measurement — quiet M1 mini, 5 shuffled interleaved repeats, verdict CLEAN, perry fefdc367b
| node | perry | ratio | |
|---|---|---|---|
| wall | 0.098 s | 0.115 s | 1.18x |
| instructions | 1.211 G | 2.243 G | 1.85x |
| cycles | 0.347 G | 0.364 G | 1.05x |
| IPC | 3.49 | 6.16 | — |
| peak RSS | 84.8 MB | 21.2 MB | 0.25x |
Perry retires 85% more instructions but spends only 5% more cycles, at nearly double Node's
IPC. That combination says the extra instructions are cheap, well-predicted, and largely free —
so cutting the instruction count is not where the 18% comes from. The wall gap is somewhere a
sampling profiler cannot see it.
asyncpipe had exactly this shape and it has now been fixed — it sat at 1.07x wall against
1.71x instructions, and #8570 flipped it to 0.84x by suppressing redundant same-thread
promise-drain wakeups and removing per-element closure/guard/chained-promise allocations from
the intrinsic Promise.all path. Its instruction ratio fell 1.71x → 1.31x as a side effect.
That fix is the strongest available hint for this row, and #8243 has prior analysis.
What NOT to do
Do not reach for a sampler and start cutting instructions. asyncpipe taught this: aggregating
sample over 14 runs of an ~88 ms program yielded one usable self-time sample, because the
process is almost always parked rather than running. A profiler will show you a flat, uninformative
profile and you will conclude there is nothing to fix.
Method
Instrument the event loop and the scheduling machinery rather than the code:
- count and time event-loop wakeups, and how many are redundant with a drain already in flight
- count microtask-queue drains, and jobs consumed per drain
- count timer registrations and their latency from due-time to run
- look for per-element allocations on the intrinsic paths, as perf(runtime): eliminate redundant asyncpipe microtask work #8570 found in
Promise.all
PROFILE_NOTIFY_DRAIN_SUPPRESSED_COUNT exists from #8570 and is a working example of making
this class of subject countable rather than merely observable.
Acceptance
- Wall time is the primary signal here, unusually — the instruction count is already
known not to be the constraint. Report both, but do not claim a win on instructions alone. - Because the bench host is contended and this row is ~100 ms, use many interleaved repeats and
report spread; treat a wall delta as real only when the ranges are disjoint. - All 20 corpus programs byte-exact; whole-corpus timing before and after, every row moving
more than 1% reported. - RSS is 0.25x Node. Do not trade it.
Activity