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

opened this

Merged 10d 3h ago, 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.

Notes

opened this

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:

StepBudgetMeasured
Layout (layout)400 msabout 225–235 ms
First paint (layout plus the map's markup)500 msabout 240–270 ms
One pan step16 msabout 0.05 ms
  • Server budgets: they are the measured cost plus slack for a loaded machine, not 150 ms. layout is the cost, and in production it runs off the serving thread and is cached by the write clock. Getting to 150 ms means reworking order() in src/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.ts and 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.

Closes #15588

3 earlier comments
commented

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:

StepBudgetMeasured
Layout (layout)400 msabout 225–235 ms
First paint (layout plus the map's markup)500 msabout 240–270 ms
One pan step16 msabout 0.05 ms
  • Server budgets: they are the measured cost plus slack for a loaded machine, not 150 ms. layout is the cost, and in production it runs off the serving thread and is cached by the write clock. Getting to 150 ms means reworking order() in src/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.ts and 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.

commented

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 test was run on a box with a load average over 115. Wall-clock timings stretched about 5×, and the existing map-layout-budget test 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_MS figure 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() in src/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 rng and productionGraph into test/helpers/map-graph.ts, with a seed parameter, so the new test and map-layout-budget.test.ts share 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.

commented

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 SLOW entry in scripts/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.

commented

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_MS and the import-time slack() 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). rng is imported from test/support/deadends.ts, and the duplicate is removed.
  • Hygiene (point 5).
    • Removed the trailing blank line in map-graph.ts.
    • Dropped the console.log calls.
    • Rewrapped the header comment in map-scale.test.ts.
    • Sorted the imports in map-layout-budget.test.ts.
  • Old fixture (point 6). productionGraph only adds titles, state and assignee when asked, via titled. map-layout-budget gets its old shape back and map-scale passes titled.

Check status (point 7)

  • map-scale passed three runs in a row here, and bun x tsc --noEmit is clean.
  • bun scripts/gate.ts --fix printed nothing.
  • test/map-layout-budget.test.ts has one test that fails in this sandbox at about 6 s: "costs a few pairwise counts…". It also fails with main'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.
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs