Perf S2: viewport culling (zoomed-in) + throttled minimap - #69
Merged
Conversation
When zoomed into a large graph, most nodes are off-screen yet still painted every frame — off-screen SVG costs the same to paint as on-screen. Add geometric viewport culling: node groups (and edges with both ends hidden) outside the viewport + margin get display:none, so they are neither laid out nor painted. Do-no-harm gating (learned by measurement): culling is skipped below scale 0.5 (the whole-graph "fit" view, where every node is on screen and a cull pass is pure overhead — an early attempt that culled unconditionally slowed zoom). When zoomed back out below the threshold, everything is revealed once. Culling is only enabled above 200 nodes. Recomputed on a throttle during sim ticks AND on every pan/zoom (the one-shot sim is usually stopped, so the zoom handler is the only thing that can reveal nodes panned back into view). Also throttle the minimap position-dict rebuild (every tick -> every 8th); it doesn't need 60 Hz and was rebuilding a full 1000-entry dict per tick. Measured (Compute Core, 1000n/1400e, HIGH), zoomed in to scale ~1.7 (982 nodes culled): zoomed-in drag FPS 1.2 -> 9 (~8x). Whole-graph fit-view drag/zoom unchanged (do-no-harm); idle still 60 (S1 preserved). The whole-graph view (scale ~0.1, all elements painted) is bound by element count, addressed next by simplified-node LOD. large-graph-profile.spec.ts now also measures a zoomed-in drag + culled count. Verified: web typecheck 0; THE GATE 5/5; hierarchy-navigation green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🧪 Comprehensive Test Suite
Full-stack smoke gate runs in the CI workflow. |
This was referenced Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage 2 of the measured large-graph performance effort (follows #68)
When you zoom into a large graph, most nodes are off-screen but still painted
every frame. This adds geometric viewport culling: off-screen node groups
(and edges with both ends off-screen) get
display:none, so they're neither laidout nor painted.
Do-no-harm gating (driven by measurement)
A first attempt culled unconditionally and slowed zoom — because at the
whole-graph "fit" view (scale ~0.1) every node is on screen, so a cull pass is
pure overhead. So culling now:
zoom back out;
one-shot sim is usually stopped, so the zoom handler is what reveals nodes
panned back into view).
Also throttles the minimap position-dict rebuild (every tick → every 8th).
Result (Compute Core, 1000n/1400e, HIGH)
The whole-graph view (scale ~0.1, all 40k SVG elements painted) is bound by
element count, not culling — that's the next stage (simplified-node LOD at low
zoom), which targets the FPS you feel when looking at the entire graph.
Verification
test:smoke) 5/5hierarchy-navigationgreen (exercises the 1000-node Compute Core)large-graph-profile.spec.tsextended with a zoomed-in drag + culled-count assertion🤖 Generated with Claude Code