Dashboard: reduce GPU usage from frequent re-renders#1383
Dashboard: reduce GPU usage from frequent re-renders#1383jayy-77 wants to merge 1 commit intoexo-explore:mainfrom
Conversation
Throttle TopologyGraph SVG rebuilds and switch state polling to adaptive timeouts (with backoff when the tab is hidden). Also disable link dash animations unless debug mode is enabled.
Code Review: Dashboard: reduce GPU usage from frequent re-rendersThanks for tackling this, @jayy-77. The core idea -- throttle full SVG teardowns, separate interaction styling from structural re-renders, and use adaptive polling -- is sound and should noticeably reduce GPU/CPU load. I have a few issues to flag, some of which could introduce bugs. TopologyGraph.svelte1. The structure key captures 2. The 3. Interaction style colors are duplicated between The wire/fill color logic (lines ~567-590 in the existing function computeNodeColors(nodeId: string) {
const isHighlighted = highlightedNodes.has(nodeId);
const isInFilter = filteredNodes.size > 0 && filteredNodes.has(nodeId);
const isFilteredOut = filteredNodes.size > 0 && !filteredNodes.has(nodeId);
const isHovered = Boolean(onNodeClick) && hoveredNodeId === nodeId && !isInFilter;
// ... return { wireColor, fillColor, strokeWidth, opacity }
}4. This is actually fine for the current usage -- they are only read inside 5. The metrics refresh interval (5s) does not account for When a browser tab is backgrounded, 6. Flow animation CSS: the In
If both rules end up active, the animation would not actually be disabled in non-debug mode, defeating the purpose of this optimization. app.svelte.ts7. When the tab becomes visible,
Overall the polling logic looks correct. Nice work avoiding the 8. In the Svelte 5 runes mode, 9. Missing cleanup of the visibility event listener if The app.css10. The ModelPickerGroup.svelte11. SVG Moving SummaryThe PR delivers meaningful performance improvements and the approach is well-reasoned. The main concerns are:
Everything else looks solid. The adaptive polling and throttled rendering are the right patterns for this problem. |
Code Review — PR #1383: Dashboard: reduce GPU usage from frequent re-rendersCI: No checks found | Merge status: CONFLICTING (needs rebase) OverviewThis PR tackles a real performance problem: the dashboard's topology graph was doing full SVG teardown-and-rebuild on every state poll (every 1s), even when only metrics changed — driving high GPU/CPU usage. The fix introduces three optimizations:
IssuesHigh Severity1. Svelte 5 In Svelte 5, The problem: when any of those tracked values change, the effect will re-run. But on re-run, if
In practice, a change to Recommendation: Wrap 2. CSS specificity conflict: On main, .graph-link {
animation: flowAnimation 1s linear infinite;
/* ... other styles */
}The PR adds to the component's :global(.graph-link) {
animation: none;
}
:global(svg.animate-links .graph-link) {
animation: flowAnimation 0.75s linear infinite;
}Both Fix: Either remove the Medium Severity3. The structure key includes Suggestion: When 4. Duplicated color/styling logic between The wire color, fill color, and stroke width computation is copy-pasted between Suggestion: Extract a 5.
This is probably intentional (Mac devices have a specific dark fill with memory-bar overlays), but the asymmetry should be documented with a comment explaining the intent. Low Severity6. The PR adds a 7. In the What's good
Merge blockers
VerdictThe PR addresses a genuine performance problem with a well-reasoned multi-pronged approach. The adaptive polling and throttled rendering are the right patterns. However, it needs a rebase onto current Review only — not a merge approval. |
Fixes #1025
Summary
TopologyGraphSVG rebuilds to structural changes + periodic metric refresh./statepolling to adaptive timeouts and back off when the tab is hidden.Test plan
cd dashboard && npm ci && npm run check