On a save with 2,700 lines on screen, Firefox spent about 95% of each
frame painting, and the dotted line on lit fiber (~160 ms) and the link
labels (~55 ms) were half of it, in a tangle where neither can be read.
draw() now counts the lines it would paint (linesOnScreen(), same box and
margin as its own culling, boxes cached on the geometry) and above
MAP_BUSY = 1000 leaves out both. They come back as soon as fewer lines
show, zooming in for instance. The selected link keeps its label.
Firefox Developer Edition headless, 1600x900 at DPR 2, player save, median
of 3x9 frames: save view 414 -> 214 ms, pan 472 -> 238, zoom 0.6 269 -> 181,
New York zoom 2 213 -> 107, selected link 412 -> 201. Under the threshold
pixels are identical (canvas SHA-1): zoom 3.2 and 6 on the player save, six
views of the big-network fixture.
draw() asked dfCap() three to five times per fiber link and per frame (width,
colour, label, up or down), each time over all its channels: on a save with
3,140 dark fibers of 18 channels on average that was about half of draw()'s
JavaScript. dfCap() now keeps its answers in DFC while one frame is drawn
(cleared in a finally, so a failed frame keeps nothing), and the link label is
built once per line instead of once per world copy. Links entirely above or
below the screen are skipped like those left or right of it already were.
Player save (202 POPs, 3,142 links), jsdom: draw() 40 -> 25 ms; perf-bench
"Map at three zoom levels" 89.7 -> 47.1 ms. Canvas call log identical at
every zoom without the vertical skip; Firefox pixels identical (SHA-1 of the
canvas) in 7 views. Firefox still spends ~95% of the frame painting.
compute(), the daily mood check and new alien-wave/fiber-pair offers asked
S.links.find() or S.biz.filter() once per customer or per link. On a save
with 2,950 links and 18,000 customers (16,000 alien waves) that was ~150 ms
per compute, ~250 ms more per day, and ~650 ms when a wave offer spawned.
linkIds() and fiberUse() build the lookups in one pass; fiberOk, bizSf,
soldSlots, freeCh and pairFree take them optionally, and give the same
answers as before (first link with the id wins, sums in S.biz order).
Player save (202 POPs, 2,958 links, 17,967 customers), median of 15:
compute 323 -> 124 ms, dayTick 545 -> 133 ms, after 356 -> 149 ms.
Big-network fixture: unchanged. Routing results identical to main.
The group split runs over an index range with one scratch array instead of
map/reduce/forEach and slice, leftover exits go into one reused array and are
sorted in place (insertion sort for short lists; both sorts are stable, so
the order is the same), flows are split without per-flow arrays, and the hot
loops use indexes instead of for...of. Without Auto-TE, exits whose path is
already full are not called at all. One routing pass on the big network
allocates 23 MB in Chromium instead of 66 MB.
Routing results are identical. The speed test's plain path now also uses the
original group split and sort, and a new test routes around a full 10G link
with Auto-TE (and a spill script) and compares both paths; planted bugs in
the split, the sort and both full-path skips are caught.
Big network vs main, two runs: headless routing -23% to -30%, Chromium
desktop -14% to -27%, phone -15% to -27%. Steps 2-4 together vs c76dd4d:
Chromium desktop routing -49%, phone -34%, a game day -26% and -30%.
Capacity only shrinks while traffic is routed, so a path with one full link
or node fits nothing for the rest of the pass: push marks it and later tries
return at once (92% of pushes on the big network went into such paths). The
nearest group of exits is found in one scan instead of two, and exits that
filled up are dropped from the shared lists once a quarter of a list is full.
Routing results are identical to before. The speed test's plain path now also
runs without these, with Auto-TE and with a RouteScript that keeps headroom on
every link; planted bugs in each of the three are caught.
Big network vs main, two runs: headless routing -51% to -58%, Chromium
desktop -22% to -31%, Chromium phone -15% to -29%.
Builds a copy of compute() with the own-exits shortcut, the first-group
scan and the per-network exit index switched off, and compares both on a
busy network with Auto-TE, preferred and backup exits, two upstreams per
city, route servers and two cache boxes per CDN. Verified it fails when
either shortcut is deliberately broken.
On a phone the NOC dashboard, scrolled past its top edge, fills the whole
screen, but the map underneath was still drawn every frame: about 4 ms per
frame on a big network on a fast PC, several times that on a phone. While a
panel covers the map completely it is no longer drawn, and it comes back as
soon as any of it shows. At the top of the dashboard the strip of map above
the card keeps moving, and on desktop, where the map shows around the
dashboard, nothing changes. No payday floaters are made while the map is
hidden, so they cannot pile up out of sight.
- Payday floaters were stamped with performance.now() but aged with the map's
animation clock, which stops while paused. After a pause they never faded:
they sat off-screen and were drawn every frame, about a hundred more per
payday on a big network, so long sessions got slower and slower. They are
stamped with the animation clock now.
- While paused or with animations off, the map is only redrawn when the camera,
the selection, hover or drag, the network or a new day changes it, plus once
a second and while the land picture catches up after a zoom. A paused frame
drops from ~4 ms to ~0.05 ms.
- After a day ends, the open panels update on the next frame, so one frame does
not carry both the day's simulation and the panels. With a day on every frame
they still follow, one frame behind.
The Connections tab drew every connection at once: 1,486 rows with their
buttons came to 32,000 elements, and laying them out again after every day
took about half a second while the dashboard was open (far longer on a phone).
The Connections and Customers lists now show 100 rows and a "+100 more"
button. Filters, sorting and totals still cover every row, and changing a
filter or the sort starts the list short again.
A network with a hundred POPs and a thousand peering ports froze the game for
most of a second every day and after every click, because routing checked all
~1,800 exits for each of ~14,000 flows. Now:
- compute(): exits are asked once per network which networks they reach, each
flow scans only those, and the first ECMP group is found without sorting. The
graph runs on city indices with a typed-array Dijkstra (same heap moves, same
ties), routers and per-link traffic are kept in typed arrays, the diverse-path
check reuses one live-link graph, and R.ef is put together when a link is read.
Results are bit-identical to before.
- Panels and the NOC dashboard are patched in place (morph) instead of being
rebuilt, so the browser no longer restyles 1,500 rows every tick. Buttons whose
action changed are swapped out, keeping #44's tap protection.
- The Networks tab works out each IX port's sessions once instead of once per
network.
- draw() reuses screen-point buffers, a per-frame pair index and cached label
widths, strokes the dotted fiber line on the path it already has, and uses
native roundRect: about a third fewer canvas calls per frame, same output.