Skip to content
2SOLID AI

Insights

Thirty-three instruments, one census — measuring every hero on the site

· performance · instruments · verification

Every hero on this site is a computed instrument — real physics, real math, running in the reader’s browser. The census counted thirty-three of them, one per scene. They are also, collectively, a performance liability nobody had measured.

This is the story of the first census — what it found, and the bug that turned out to be hiding in plain sight.

The instrument

tools/perf-census.mjs loads every route in headed Chromium with GPU acceleration, waits for the scene to settle, then samples requestAnimationFrame deltas for two seconds. For each scene it reports mean frame time, p95, worst frame, and the percentage of frames over the 16.7ms budget — the share of time the scene spends below 60fps.

Headed matters. Headless Chromium rasterizes on CPU and lies about GPU-bound scenes; the census runs headed so WebGL and canvas scenes report numbers a real browser would produce. The trade-off is variance — a desktop session has GC pauses and scheduler noise — which is why the tool reports distributions, not a single score.

The census

Thirty-three scenes. Twenty-nine locked at 16.6ms mean with zero dropped frames — effectively a perfect 60fps. Two sat marginally above budget. And one was nowhere near:

scene mean p95 worst drop%
serverRoom (/privacy-policy/) 50.3ms 399ms 848ms 7%

A privacy-policy page was the worst performer on the site. That alone was worth knowing — but the interesting part was why.

The diagnosis

The scene fetches an 866KB SVG — a datacenter illustration built from 4,198 individual <path> elements — then animates a stroke draw-in. Reading the code with the numbers in hand, three defects surfaced:

Geometry reads inside a sort comparator. The draw-in sorts paths left-to-right for its stagger wave, and the comparator called midX(el) — which calls el.getBBox() — on every comparison. Sorting 4,198 elements is ~50,000 comparisons. That is ~50,000 forced layout/geometry reads for one sort. This was the dominant cost, and it was invisible until counted.

The same measurement, twice. pathLen() calls getTotalLength() — another forced geometry computation — once in initDrawIn and again inside buildPulse, on all 4,198 paths both times. Roughly 8,400 reads where 4,198 sufficed.

A floor set too low. Only paths longer than 120px were meant to animate; the rest snap drawn. But the length distribution showed 692 paths above that floor — and 432 of them were under 300px, where a fixed 220ms draw transition reads slower than the geometry warrants.

The fix

One commit, three changes, no visual redesign:

  • Sort keys computed once per element — and only for the 260-path animated subset, since snapped paths don’t need ordering.
  • Path lengths computed once and shared between the draw-in and the pulse builder.
  • The animation floor raised to 300px — every structural stroke still draws itself; the sub-per-length strokes that looked sluggish now appear immediately.
  • 4,198 appendChild calls became a single DocumentFragment insertion.

The final rendered art is identical. Only the work required to produce it changed.

The numbers, after

metric before after
setup longtasks 91 + 350 + 90ms one 288ms
census mean 50.3ms 37.0ms
census p95 399ms 287ms
steady-state p95 — 18.5ms (~60fps)

The residual is honest: the census window sits inside the scene’s 3.2-second intro animation, so ~37ms mean reflects a bounded, once-per-pageview cost — not sustained jank. Steady state after the intro measures clean.

Why this is the product

The bug was not exotic — it was the ordinary kind: a helper function called where a cached value belonged, a threshold set before the distribution was known. It survived because nothing measured the scene. Plausible code, unmeasured, on a page nobody watches.

That is the same failure shape as the content drift the rest of this site is built to catch. The instruments here don’t just render — they get measured, censused, and filed. A hero that can’t hold 60fps is a claim the page can’t support.

The census stays in the repo. The next scene that drifts gets caught by the same instrument that caught this one.