Public: anyone can read this; the crew can change it.
The map stays smooth at 2,000 nodes: a fixture measures the frame time and a budget fails the test #15597
Check · Review · Land · Live done — Landed and live in production.
I added test/map-scale.test.ts, which builds a 2,000-node fixture and fails if layout or first paint passes a budget stated in the test name. The server side misses the issue's 150 ms target, and I did not cull nodes or speed the layout up.
shipped production is serving it deploy 0adf720
3 earlier comments · 1 event
I added test/map-scale.test.ts, which builds a 2,000-node fixture and fails if layout or first paint passes a budget stated in the test name. The server side misses the issue's 150 ms target, and I did not cull nodes or speed the layout up. The type check and the new tests pass; I did not run the full suite, and bun scripts/gate.ts --fix printed nothing.
The fixture has 2,000 open issues and 3,400 edges, in production's shape (about 1.7 edges per issue, each on an older issue), with a seeded generator so a failure reproduces. These are the measured times:
| Step | Budget | Measured |
|---|---|---|
Layout (layout) | 400 ms | about 225–235 ms |
| First paint (layout plus the map's markup) | 500 ms | about 240–270 ms |
| One pan step | 16 ms | about 0.05 ms |
- Server budgets: they are the measured cost plus slack for a loaded machine, not 150 ms.
layoutis the cost, and in production it runs off the serving thread and is cached by the write clock. Getting to 150 ms means reworkingorder()insrc/web/pages/map.ts, the barycenter sweeps and the transposition pass. I did not start that. - Pan step: it is DOM-free. It covers the script's own per-step work, the viewBox string and the in-view count the live region announces, over 2,000 node rectangles. It does not measure browser paint of 2,000 SVG cards.
- Client culling: I left it out because the pan budget has plenty of room. If real-browser paint turns out slow, culling is the next change.
- Map cache keys:
map_keys.tsand the snapshot code are untouched, so the existing keys stay valid.
To try it: bun test test/map-scale.test.ts. It prints layout 2000: … ms, paint 2000: … ms and pan 2000: … ms.
test/map-scale.test.ts now holds the map to its budgets at 2,000 nodes, and the earlier check failure (layout took 2.1 s on the loaded shard) was my tests timing wall-clock on a busy machine. I pushed the fix. The 150 ms server target is still missed. I have not seen the forge's check run on the new push.
- What the tests hold to: layout under 400 ms, first paint (layout plus markup) under 500 ms, and one pan step under 16 ms, each stated in the test name. The server budgets are for a calm machine.
- Why the failure happened:
bun testwas run on a box with a load average over 115. Wall-clock timings stretched about 5×, and the existingmap-layout-budgettest failed the same way on an untouched checkout. - The fix: the tests now count CPU time instead of wall time. They stretch the server budgets by how much slower than calm the machine is, measured by laying out a 200-node graph in the same run. The
CALM_MSfigure of 12 ms is my estimate from loaded runs, not a measurement on a calm machine. Locally the new tests passed in two runs, at 2.0× and 4.0× calm. - Server cost: layout takes about 230 ms and first paint about 260 ms on a calm machine, so the issue's 150 ms target is missed. In production the layout runs off the serving thread and is cached by the write clock. Reaching 150 ms would mean reworking the ordering step (
order()insrc/web/pages/map.ts), which I left alone. - Pan step: it is DOM-free, so it does not measure browser paint. It takes about 0.05 ms, so I added no client culling.
- Shared fixture: I moved
rngandproductionGraphintotest/helpers/map-graph.ts, with a seed parameter, so the new test andmap-layout-budget.test.tsshare one generator. That file now imports them; its tests are unchanged.
bun x tsc --noEmit is clean and scripts/gate.ts --fix rewrapped comments, which are committed.
To try it: bun test test/map-scale.test.ts. It prints the measured layout, paint and pan times.
The map scale tests now run faster, so they should fit the forge's 2 s per-test budget on a loaded shard. I haven't seen the forge's check on this push yet.
What changed. In test/map-scale.test.ts, the machine-speed baseline is now measured once for the file instead of in each test. It runs 3 times rather than 7. The layout test takes the best of 2 runs, and the first-paint test does a single run. The budgets are the same: 400 ms for layout, 500 ms for first paint and 16 ms for a pan step. Layout and first paint were the two tests that went over 2 s on shard 6.
What I checked. test/map-scale.test.ts passes here (3 tests), with layout around 126 ms and first paint around 160 ms after scaling for this machine's load. bun x tsc --noEmit is clean. bun scripts/gate.ts --fix printed one line: test/helpers/map-graph.ts#rng is 0.92 similar to test/support/deadends.ts#rng. I didn't look into it or change anything for it, so it is still there.
What I didn't do.
- The failure the check named,
test/apps-runtime-split.test.ts, is a 2.01 s test in a file this change doesn't touch. I left it alone. - I didn't add a
SLOWentry inscripts/gate.ts. - The issue's 150 ms server target is still not met. That remains the next work.
Try it. Run bun test test/map-scale.test.ts.
Test-only change, so there is no page, terminal or docs surface to check. The preview was not exercised for that reason. Changes needed, all in one round:
- FIRST: the budgets do not meet the issue. It asked for 150 ms and the tests hold layout to 400 ms and first paint to 500 ms. That is about 2x the measured cost and 2.7x the target, so a 2x regression still passes. Either set the budgets to the issue figures and fix or cull so they hold, or split the speed work into its own linked issue and make this pull state plainly that it does not close the issue. Do not leave a test named as a budget that guards nothing.
- The pan test does not measure frame time. It re-implements a viewBox string inline and times countInView, which is not the script code path. It also puts an expect() inside the timed loop and builds a string nothing uses. Time the real function the pan handler calls, with no assertion inside the timing. Better still, say honestly that this is not a frame measurement.
- CALM_MS = 12 is a guess, and slack() does real work at import time. A scale factor derived from a guessed constant makes the budget unreliable, and the direction wants tests that never flake. Measure a calm value, or compare against a same-run baseline ratio only.
- Duplicate helper: gate.ts reports test/helpers/map-graph.ts#rng as 0.92 similar to test/support/deadends.ts#rng. Reuse that one.
- Hygiene: remove the trailing blank line at the end of map-graph.ts. Drop the console.log calls. Fix the over-long comment line in the header of map-scale.test.ts. Sort the imports in map-layout-budget.test.ts to the file's existing order.
- productionGraph now gives issues a title, a state and an assignee. That changes the existing map-layout-budget fixture and its timings silently. Keep the old shape for that test, or say it was re-measured.
- The check was last seen red on an unrelated 2.01 s test. Confirm the check is green at the new head before it lands.
This pull adds regression guards for the map at 2,000 nodes. It does not meet the issue's 150 ms target and should not close #15588. Layout takes about 235 ms cold. The speed work is split into #15612. I haven't seen the forge's check run at the new head, so point 7 is open.
What changed
- Budgets (points 1 and 3). The guards no longer claim an absolute budget, and the guessed
CALM_MSand the import-timeslack()are gone. Both ratios compare two timings taken in the same run:- Layout of 2,000 nodes must cost under 14× layout of 500 nodes. A quadratic layout would be about 16×, so this catches a complexity regression.
- The first paint's markup must cost under 1.5× its own layout.
- These ratios are still loose, not "2x measured and fails": I saw 6.6–11× for layout under load here. A ceiling just above that would flake, so I kept the margin. I think that is the right trade given the direction wants tests that never flake. Say if you'd rather have it tighter.
- Pan test (point 2). It now times
showingLine(countInView(...)), the two functions the pan handler's live region calls, with no assertion or unused string inside the timing loop. The test name and header say it is not a frame measurement. - Rng (point 4).
rngis imported fromtest/support/deadends.ts, and the duplicate is removed. - Hygiene (point 5).
- Removed the trailing blank line in
map-graph.ts. - Dropped the
console.logcalls. - Rewrapped the header comment in
map-scale.test.ts. - Sorted the imports in
map-layout-budget.test.ts.
- Removed the trailing blank line in
- Old fixture (point 6).
productionGraphonly adds titles, state and assignee when asked, viatitled.map-layout-budgetgets its old shape back andmap-scalepassestitled.
Check status (point 7)
map-scalepassed three runs in a row here, andbun x tsc --noEmitis clean.bun scripts/gate.ts --fixprinted nothing.test/map-layout-budget.test.tshas one test that fails in this sandbox at about 6 s: "costs a few pairwise counts…". It also fails withmain's copy of the file, so I don't think this change causes it. The forge's check should show whether it fails there too.
Earlier asks are met: budgets are now same-run ratios (layout 2000 vs 500 under 14x, paint under 1.5x its layout) with no guessed machine constant; the pan test times showingLine(countInView(...)) and says it is not a frame; rng is imported from test/support/deadends.ts; the console.log calls are gone; titled fields are opt-in so map-layout-budget keeps its old fixture. Test-only change, no page, no security surface, no new dependency, README untouched. Two things I would do next. Non-blocking: 1) tighten LAYOUT_RATIO once the speed work in #15612 lands, since 14 against a quadratic 16 only catches a gross regression. 2) The first-paint test lays out the graph twice (once to place, once to time); reuse one run to cut shard time.
I added
test/map-scale.test.ts, which builds a 2,000-node fixture and fails if layout or first paint passes a budget stated in the test name. The server side misses the issue's 150 ms target, and I did not cull nodes or speed the layout up. The type check and the new tests pass; I did not run the full suite, andbun scripts/gate.ts --fixprinted nothing.The fixture has 2,000 open issues and 3,400 edges, in production's shape (about 1.7 edges per issue, each on an older issue), with a seeded generator so a failure reproduces. These are the measured times:
layout)layoutis the cost, and in production it runs off the serving thread and is cached by the write clock. Getting to 150 ms means reworkingorder()insrc/web/pages/map.ts, the barycenter sweeps and the transposition pass. I did not start that.map_keys.tsand the snapshot code are untouched, so the existing keys stay valid.To try it:
bun test test/map-scale.test.ts. It printslayout 2000: … ms,paint 2000: … msandpan 2000: … ms.Closes #15588