Skip to content

perf(web): comprehensive graph rendering and UI performance overhaul#1

Open
QusayNaserFHS wants to merge 1 commit intomainfrom
perf/web-ui-optimization
Open

perf(web): comprehensive graph rendering and UI performance overhaul#1
QusayNaserFHS wants to merge 1 commit intomainfrom
perf/web-ui-optimization

Conversation

@QusayNaserFHS
Copy link
Copy Markdown
Collaborator

Summary

  • Progressive node loading: For graphs >2k nodes, only Folders/Files/Classes visible initially. Functions/Methods/Variables hidden — reveal via Filters tab. Reduces visible nodes from 55k→10k.
  • Edge optimization: Max 8-15 edges per node, skip structural edges (CONTAINS/DEFINES/IMPORTS) for 5k+, straight lines instead of curves for 5k+. Reduces edges from 186k→15k.
  • Skip O(n²) layout: For 10k+ nodes, skip ForceAtlas2 entirely — hierarchical positions from graph-adapter are sufficient. Cached positions in sessionStorage for instant reload.
  • Context splitting: New CodeRefsContext isolates AI citation updates so GraphCanvas/FileTree/Header don't re-render during chat streaming.
  • O(1) lookups: Pre-built nodeMap, nodeIdSet, filePathIndex, fileNodeIndex replace all graph.nodes.find() O(n) calls in hot paths.
  • Reducer fast-paths: For 2k+ graphs, skip dimming of non-active nodes — only modify selected/highlighted nodes. Turns O(N) allocations into O(k).
  • Lazy mermaid: ~480KB loaded on first diagram render via import('mermaid') + SVG caching.
  • Sigma tuning: 30fps animation throttle, color caching, disable hover/edge events for large graphs, adaptive label density.
  • Bundle: 8 vendor chunks (added vendor-git, vendor-ml, vendor-markdown), debounced search, useTransition for filters, code viewer windowed to ~70 lines.
  • FPS counter: Live overlay top-right for monitoring.

Test plan

  • Load small repo zip — verify graph renders normally with all features
  • Load agent_playground.zip (55k nodes) — verify FPS counter shows >30, interactions are responsive
  • Click node — verify code panel opens, no lag
  • Toggle Filters — verify node types show/hide (Functions initially hidden for large graphs)
  • Use AI chat — verify no graph lag during streaming
  • Refresh page after loading — verify cached layout restores instantly
  • Check Mermaid diagrams render correctly in chat (lazy loaded)

🤖 Generated with Claude Code

Addresses severe lag when visualizing large codebases (55k+ nodes).
Reduces visible nodes from 55k→10k, edges from 186k→15k, eliminates
O(n²) layout for huge graphs, and prevents cascading re-renders during
AI chat streaming.

Key changes:
- Progressive node loading: hide Functions/Methods/Variables for 2k+ graphs
- Edge limits: max 8-15 edges per node to prevent dense clusters
- Straight line edges for 5k+ graphs (cheaper GPU rendering)
- Skip FA2 layout for 10k+ nodes (use hierarchical positions)
- Cache layout positions in sessionStorage for instant reload
- Split CodeRefsContext to isolate AI citation re-renders
- O(1) node lookups via pre-built Maps (replace graph.nodes.find)
- Lazy-load Mermaid (~480KB) with SVG caching
- Reducer fast-paths: skip allocations for non-active nodes
- Color computation caching, 30fps animation throttle
- Disable hover/edge events for large graphs
- useTransition for filter toggles, debounced search inputs
- Better Vite chunking (8 vendor chunks)
- FPS counter overlay for monitoring
- Code viewer windowed to ~70 lines around symbol

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant