Make big networks fast: routing, panels and map drawing

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.
This commit is contained in:
Frederic Jung 2026-10-26 00:03:05 +01:00
parent 6c2d5da5b8
commit a887b65a2f
5 changed files with 347 additions and 126 deletions

View file

@ -90,6 +90,10 @@ never freezes the game.
5. Layer-2 customers (L2VPN, SD-WAN, waves) are carved out of link capacity first.
6. Totals costs (`R.cost`) and revenue (`R.rev`) per month.
It runs every day and after every action, so it is built for big networks: the graph works on city
indices (`CIDX`), each exit is asked once per network what it can reach, and `R.ef` (what crosses each
link) is only put together for a link when something reads it.
Served share per city (`sfOf`) drives eyeball revenue and customer mood.
## Actions and rendering
@ -102,6 +106,8 @@ Served share per city (`sfOf`) drives eyeball revenue and customer mood.
- `renderLeft()` draws the left tabs (deals, NOC, customers…), `renderPanel()` the
selection panel (city, link, network). On phones these become bottom sheets
controlled by `renderTabbar()`.
- These panels and the dashboard are rebuilt as HTML every tick and written with `morph()`, which
patches only what changed. Buttons whose action changed are replaced, so taps stay safe (#44).
- The map is a canvas drawn every frame by `draw()`. Zoomed out (`lodFar()`) it uses
a simplified style; parallel waves are grouped by `linkGroups()`.