You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
graphify update is O(V×E) on large repos due to betweenness_centrality in suggest_questions #341
graphify update <path> becomes extremely slow on large monorepos (50k+ files, ~450k nodes, ~690k edges). On a 96-core Xeon server, the command ran for 114 minutes without completing and had to be killed.
Root Cause
_rebuild_code() in watch.py calls suggest_questions() in analyze.py, which runs:
betweenness=nx.betweenness_centrality(G)
nx.betweenness_centrality has O(V × E) time complexity. For our graph (450k nodes × 690k edges = ~310 billion operations), this is infeasible in single-threaded Python.
Timeline breakdown on 96-core Xeon 8163 @ 2.5GHz:
Phase
Time
Status
AST extraction (55,903 files, cache hit)
~6 min
OK
build_from_json (450k nodes)
~5 min
OK
cluster (Leiden via graspologic)
~15 min
OK
score_all
unknown
—
surprising_connections
unknown
—
suggest_questions → betweenness_centrality
90+ min, never finished
Bottleneck
For reference, the same repo builds in ~10 min on Apple M3 Pro (4.8x faster single-core), suggesting betweenness_centrality dominates even locally.
Environment
graphifyy 0.4.11
Python 3.11
NetworkX 3.6.1
graspologic installed (Leiden works fine)
Repo: 55,903 code files across 83 git submodules
Suggested Fix
For large graphs, suggest_questions should either:
Skip betweenness_centrality when node count exceeds a threshold (e.g. 10k nodes)
Use approximate betweenness (nx.betweenness_centrality with k parameter for sampling)
Make the analyze/report phase optional in _rebuild_code() — the graph.json is the valuable output, not the report
Option 3 would be most impactful — users running graphify update on large repos primarily want the graph.json for MCP tool queries, not the GRAPH_REPORT.md.
Workaround
Currently we have no workaround other than building locally on a faster machine. A --skip-report flag on graphify update would unblock server-side builds immediately.
Activity
Fix 9 issues: kiro package data, betweenness perf, wiki step, opencod…
safishamsi commentedon Apr 14, 2026
Implemented in v0.4.14.
Fix 9 issues: kiro package data, betweenness perf, wiki step, opencod…
Fix 9 issues: kiro package data, betweenness perf, wiki step, opencod…