Skip to content

Symbol graph: O(n²) colocation edges, duplicate accumulation, brace counting ignores strings #76

@haasonsaas

Description

@haasonsaas

Found during deep code review of symbol_graph.rs

1. O(n²) colocation edges per file (lines 179-192)

For N symbols per file, creates N*(N-1) bidirectional edges. 100-symbol module = 9,900 edges.

2. BFS traversal is O(E² log E) (lines 256-303)

Sorts entire frontier each iteration instead of using BinaryHeap. Nodes re-processed multiple times.

3. Duplicate edges accumulate without dedup

add_edge appends without checking for existing same-pair edges.

4. find_block_end ignores strings/comments (lines 489-511)

Brace counting treats braces inside string literals as real. let s = "}}}}" decrements depth by 4.

Acceptance

  • Cap colocation edges or skip large-symbol files
  • Use BinaryHeap for frontier
  • Deduplicate edges on insert
  • String/comment-aware brace counting

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingperformancePerformance and resource optimization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions