Start Fast: Kit Build, World Open and Lazy Scenery
Frame rate is what a child feels while playing; start-up is what decides whether they get to play. Day 5 turns two silent waits, building the object catalogue and opening a world, into measured rails, and cuts them from seconds to a fraction.
Make start-up a rail
Frame benchmarks never noticed start-up, because they begin after it. So the suite gained a startup rail: the time to build the kit (load and validate the object catalogue) and the time to open a world, in Node and in the browser, projected per device class and ratcheted against a baseline like every other rail.
The first measurement was startling. Building the kit took 2 351 ms on the cloud runner: about 14 s on a low-end phone, before any world appeared.
The catalogue: one index instead of 33 million checks
The kit validates every interaction rule ("a bird can sit in a tree") against every object blueprint, so a typo in a rule fails at load time instead of mid-game. The validation scanned all 3 697 blueprints twice per rule, for 4 444 rules: about 33 million selector matches.
The fix builds one selector index, once: for each tag or id, the set of blueprints it selects. Each rule then becomes a couple of lookups. Kit build went from 2 351 ms to 298 ms (7.9×), and a check compared the indexed selections with the original matching for all 8 888 rule selectors: zero mismatches.
The same fix landed on the integration branch in parallel, from another session. At merge, this branch took that implementation and kept its own measurements, and the ledger records exactly that.
World open: a layout per object
Opening the market world took 8.3 s at 6× CPU. A trace of the open showed most of it in the view's first frame: each object's tap pad was sized from getBBox() of its drawing, called between writes. That is Day 3's forced-layout problem again, now once per object: about 90 full layouts of the world svg in one frame.
Batching fixed it: read every missing tap-pad box first, in one pass, then write. The view's render during open went from 3.4 s to 0.8 s.
Don't build what nobody sees: lazy scenery
The rest of the open was building scenery: about 29 000 SVG nodes for a market world, before the first frame. Day 4's raster tiles mean almost none of those vectors are ever shown for long: each one hides as soon as its tile image loads.
So scenery vectors became lazy: built only near the view, and only until their tile is up. Scrolling builds the next screen's vectors just ahead of time. Later (EXP-029) vectors whose tile already covers them are not merely hidden but removed.
On native, the same idea applied to the Skia backdrop chunks from Day 2: they were all recorded on the first frame. Now each chunk is recorded the first time it is drawn, plus a small per-frame budget that records the chunks nearest the view in idle time. Native first frame: market 198 → 124 ms, playground 96 → 41 ms, pixel parity exact.
Before and after side by side
Start-up: the same build opened at 6× CPU. The new build shows the world at 14 s; the old one is still blank at 20 s (the runner is slow; the ratio is what matters).

World open: the market world, 6× CPU, with a clock burned into the recording: 6 984 ms before, 1 965 ms after.

| measurement | before | after |
|---|---|---|
| kit build (catalogue + validation) | 2 351 ms | 298 ms |
| page open → stage ready, 6× CPU, market | 21.1 s | 13.3 s |
| world open, 6× CPU, market | 8.3 s | 2.2 s |
| DOM nodes after open, market | 34 398 | 8 258 (later 6 782) |
| JS heap after open, market | 72.3 MB | 68.7 MB |
Design principles at work
- Precompute an index, don't repeat a search (DRY at runtime). The selector index computes "which blueprints does this select?" once; validation, interactions and hosts reuse it.
- Lazy initialisation behind the same interface. Scenery nodes and Skia chunks are created on first use; the code that draws them is unchanged, and so is everything that reads them.
- Make the slow path a test. The startup rail turns "the app feels slow to open" into a number with a budget, so the next regression fails a run instead of a review.
Key takeaways
- Start-up and world open deserve rails of their own; frame benchmarks start too late to see them.
- Validation that scans everything per rule is a hidden O(n × m); an index makes it O(n + m).
- Forced layout can hide in a loop over objects, not just in a frame.
- If most of what you build is replaced by a cheaper representation, build it lazily, near where it is needed.