Comfy-Org / Comfy-Org/ComfyUI_frontend

Performance TODOs: graph hierarchy O(n) traversal, minimap brute-force diff

Open
#11,041 0 comments 0 reactions 0 assignees View on GitHub
area:minimap audit:refactor code-audit perf:speed
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Recommendation

### ♻️ REFACTOR: Optimize graph traversal and minimap diffing

Two acknowledged performance bottlenecks with TODO comments:

## What Was Found

### Graph Hierarchy — O(n) Traversal
- `src/composables/graph/useGraphHierarchy.ts:15` — `TODO: This traverses the entire graph and could be very slow; needs optimization. Consider spatial indexing or caching for large graphs.`
- `findParentGroup` is O(n) on all groups.

### Minimap Link Tracking — Brute-Force JSON Diff
- `src/renderer/extensions/minimap/composables/useMinimapGraph.ts:156`
- `src/renderer/extensions/minimap/data/AbstractMinimapDataSource.ts:60`
- Uses `JSON.stringify(g.links || {})` as a diff mechanism. Two TODO comments: `// TODO: update when Layoutstore tracks links`

## Context

Both are known performance concerns that will worsen with larger workflows.

---

**Category:** Refactoring Opportunity | **Confidence:** MEDIUM | **Tools:** Semantic analysis
_Filed by audit-code skill_

Part of #11022

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11041-Performance-TODOs-graph-hierarchy-O-n-traversal-minimap-brute-force-diff-33e6d73d36508118a147da8206882579) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.