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 on a cloned checkout re-extracts every file and rebuilds the whole graph (3 to 7 min, ~6 GB) even with zero changes #4740
Use case. One large monorepo, many git worktrees (one per branch / agent). The map is built once on a canonical checkout of main; each worktree gets a copy of graphify-out/graph.json (and manifest.json, and in one run cache/). We wanted each worktree to run graphify update so its map reflects the branch's changes. Correctness was fine: a new file and its function appeared. Cost was the blocker.
Environment. graphifyy 0.9.92 (pipx, Python 3.14.5), macOS, Apple M5 Max, 18 cores, 48 GB. Graph: 184,314 nodes, 463,239 edges, 4,610 communities, graph.json 258 MB, 19,397 code files. AST only (no LLM key set). Command each time: GRAPHIFY_OUT=<worktree>/graphify-out graphify update <worktree>.
run
change since the copy
wall
peak RSS
log
1
none
6m 12s
6.3 GB
rebuilt, same counts
2
49 files (42 modified/deleted, 1 new)
7m 2s
5.7 GB
rebuilt, correct
3
none
3m 12s
6.1 GB
AST extraction: 19397/19397 uncached files (100%) then No code-graph topology changes detected; outputs left untouched.
4
1 file, canonical cache/ (5,108 AST entries, 94 MB) copied in with the copy
Run 1 and 4: with no or one changed file, update still re-clusters and rewrites graph.json, graph.html and GRAPH_REPORT.md in full. Run 3 shows a "no topology changes" short-circuit exists; it would help if it also applied before re-extraction, and if a small change patched the graph instead of rebuilding it.
Ask. An incremental update whose cost scales with the changed files: re-extract only files whose content changed, patch their nodes and edges into the existing graph, skip re-clustering and the HTML/report when topology changes are local (or behind flags like --no-html --no-report). Related: #2406 (cross-file edges lost on incremental re-extract), #3763 (AST-only update drops semantic edges).
Happy to run a patched build against this corpus and report timings.
I dug into this on 0.9.95 (report is 0.9.92, same behavior). Two separate problems are bundled here, and they have different causes.
The bigger one is not the copy at all. TS/JS files never touch the AST cache. graphify/extractors/models.py:11 defines _JS_CACHE_BYPASS_SUFFIXES (.js .jsx .mjs .cjs .ts .tsx .mts .cts .vue .svelte .ejs), and extract.py:9420-9425 plus 9022-9043 skip both load_cached and save_cached for them. They get re-parsed on every run, copied cache or not. The bypass is a workaround for a portability bug. JS/TS resolution stamps a resolved target_file on edges (resolution.py:1392), but cache.py:700 only relativizes source_file and definition_file, so a JS/TS entry would replay a foreign absolute path. tests/test_cross_extension_reexport_self_cycle.py:293 documents the workaround. For a TS monorepo that is most of the corpus, which is why uncached_work lands on the total file count.
The copied cache itself does hit. I don't think the stat-index is the problem: file_hash (cache.py:512-614) salts on the root-relative path, and a stat miss only re-reads the bytes and reproduces the same digest. On a 20 .py + 20 .ts corpus:
scenario
bypass
cacheable
hits
uncached_work
cold
20
20
0
40
warm, same dir
20
20
20
20
cp -r, new mtimes
20
20
20
20
cp -a, preserved mtimes
20
20
20
20
copy, renamed namespace
20
20
0
40
Every cacheable file hit after both copies.
What zeroes a copied cache is _cleanup_stale_ast_entries (cache.py:86-111), which rmtree's sibling v*/ dirs under cache/ast/. The namespace is v{version}-s{schema}-g{grammar} (cache.py:1040), so a cache copied in from a different graphify version is deleted on first use. That fits run 4: 5,108 entries copied in, yet all 19,397 files read as uncached, which means the cacheable ones missed too.
Two smaller things. The (100%) in the log is a progress counter over the uncached set. extract.py:9181 prints done_count/len(uncached_work), so the final line is always N/N (100%) and the real total is never shown. And even with a perfect cache the run stays expensive: watch.py goes detect -> extract -> build_from_json -> topology compare at :2362, and only then can short-circuit at :2396. _rebuild_code does support changed_paths (watch.py:1915-1971), but cli.py:2838 never passes it, so update is always full corpus. legacy_layout (watch.py:2208) forces the full path when the copied graph.json is multi-line, which is probably run 1.
The incremental ask and the cache-hit ask are two different fixes. Happy to help on either.
Here's how I'll fix this. The report bundles two problems and each needs its own change, so this lands as several PRs rather than one.
Log the real cache hit rate (small, first)
The (100%) in the output counts progress through the uncached set, not cache
hits, so the last line always reads N/N ... (100%). The PR prints
cache_hits/total instead. No behavior change.
Skip the work when nothing changed
Today update runs detect -> extract -> build -> cluster and only then checks
for topology changes, so a no-change run still costs 3-6 min. I'll move that
check before extraction: compare the detected file set, per-file content
hashes (the manifest already stores them), and the non-code inputs that affect
resolution (tsconfig, package.json, lockfiles), then exit early when nothing
moved. Covers runs 1 and 3.
Make update incremental
_rebuild_code already accepts changed_paths, but update never passes them.
Wiring that through lets a small edit re-extract only what changed. Bigger,
lands after 2.
Make the TS/JS cache real
TS/JS files skip the AST cache because their edges carry a resolved absolute
target_file, and the cache only relativizes source_file and definition_file, so
a cached entry would replay a foreign path. Relativizing it is not enough on
its own: a JS/TS file's result also depends on which siblings exist and what
tsconfig/package.json say, which a content hash can't see, so a naive cache hit
goes stale. The sound fix is to cache only the parse output (pure in file
bytes) and keep resolution in the post-pass that already runs. This one is a
refactor, so it lands last.
Stop deleting a copied cache without a word
_cleanup_stale_ast_entries deletes AST entries from other versions and grammar
sets. That's correct, since a different extractor can't be trusted, but it
happens silently, which is why run 4 looks like a total miss. The PR logs how
many entries were discarded and why.
Fixed in v0.9.96 via #4748, now on PyPI (pip install graphifyy==0.9.96). graphify update skips extraction when no relevant inputs changed, so an unchanged cloned checkout no longer rebuilds the whole graph. Thanks for the report, @lavaxun.
Activity
github-actions commentedon Oct 24, 2026
Thanks for opening this issue, @lavaxun. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
Deepjyoti-Sarmah commentedon Oct 24, 2026
I dug into this on 0.9.95 (report is 0.9.92, same behavior). Two separate problems are bundled here, and they have different causes.
The bigger one is not the copy at all. TS/JS files never touch the AST cache.
graphify/extractors/models.py:11defines_JS_CACHE_BYPASS_SUFFIXES(.js .jsx .mjs .cjs .ts .tsx .mts .cts .vue .svelte .ejs), andextract.py:9420-9425plus9022-9043skip bothload_cachedandsave_cachedfor them. They get re-parsed on every run, copied cache or not. The bypass is a workaround for a portability bug. JS/TS resolution stamps a resolvedtarget_fileon edges (resolution.py:1392), butcache.py:700only relativizessource_fileanddefinition_file, so a JS/TS entry would replay a foreign absolute path.tests/test_cross_extension_reexport_self_cycle.py:293documents the workaround. For a TS monorepo that is most of the corpus, which is whyuncached_worklands on the total file count.The copied cache itself does hit. I don't think the stat-index is the problem:
file_hash(cache.py:512-614) salts on the root-relative path, and a stat miss only re-reads the bytes and reproduces the same digest. On a 20.py+ 20.tscorpus:cp -r, new mtimescp -a, preserved mtimesEvery cacheable file hit after both copies.
What zeroes a copied cache is
_cleanup_stale_ast_entries(cache.py:86-111), which rmtree's siblingv*/dirs undercache/ast/. The namespace isv{version}-s{schema}-g{grammar}(cache.py:1040), so a cache copied in from a different graphify version is deleted on first use. That fits run 4: 5,108 entries copied in, yet all 19,397 files read as uncached, which means the cacheable ones missed too.Two smaller things. The
(100%)in the log is a progress counter over the uncached set.extract.py:9181printsdone_count/len(uncached_work), so the final line is alwaysN/N (100%)and the real total is never shown. And even with a perfect cache the run stays expensive:watch.pygoes detect -> extract ->build_from_json-> topology compare at:2362, and only then can short-circuit at:2396._rebuild_codedoes supportchanged_paths(watch.py:1915-1971), butcli.py:2838never passes it, soupdateis always full corpus.legacy_layout(watch.py:2208) forces the full path when the copiedgraph.jsonis multi-line, which is probably run 1.The incremental ask and the cache-hit ask are two different fixes. Happy to help on either.
Deepjyoti-Sarmah commentedon Oct 24, 2026
Here's how I'll fix this. The report bundles two problems and each needs its own change, so this lands as several PRs rather than one.
Log the real cache hit rate (small, first)
The (100%) in the output counts progress through the uncached set, not cache
hits, so the last line always reads N/N ... (100%). The PR prints
cache_hits/total instead. No behavior change.
Skip the work when nothing changed
Today update runs detect -> extract -> build -> cluster and only then checks
for topology changes, so a no-change run still costs 3-6 min. I'll move that
check before extraction: compare the detected file set, per-file content
hashes (the manifest already stores them), and the non-code inputs that affect
resolution (tsconfig, package.json, lockfiles), then exit early when nothing
moved. Covers runs 1 and 3.
Make update incremental
_rebuild_code already accepts changed_paths, but update never passes them.
Wiring that through lets a small edit re-extract only what changed. Bigger,
lands after 2.
Make the TS/JS cache real
TS/JS files skip the AST cache because their edges carry a resolved absolute
target_file, and the cache only relativizes source_file and definition_file, so
a cached entry would replay a foreign path. Relativizing it is not enough on
its own: a JS/TS file's result also depends on which siblings exist and what
tsconfig/package.json say, which a content hash can't see, so a naive cache hit
goes stale. The sound fix is to cache only the parse output (pure in file
bytes) and keep resolution in the post-pass that already runs. This one is a
refactor, so it lands last.
Stop deleting a copied cache without a word
_cleanup_stale_ast_entries deletes AST entries from other versions and grammar
sets. That's correct, since a different extractor can't be trusted, but it
happens silently, which is why run 4 looks like a total miss. The PR logs how
many entries were discarded and why.
Each PR runs the full test suite.
fix(watch): only stamp build state after rebuild outputs are finalized (
test(watch): pin that a partial rebuild output is never stamped (Grap…
perf(update): skip extraction when no relevant inputs changed (#4740)
fix(watch): only stamp build state after rebuild outputs are finalized (
test(watch): pin that a partial rebuild output is never stamped (#4740)
safishamsi commentedon Oct 26, 2026
Fixed in v0.9.96 via #4748, now on PyPI (pip install graphifyy==0.9.96). graphify update skips extraction when no relevant inputs changed, so an unchanged cloned checkout no longer rebuilds the whole graph. Thanks for the report, @lavaxun.
Merge upstream/v8 (graphify 0.9.97, +885 коммитов) в 1C/BSL + ArcadeD…
feat(watch): derive changed_paths from the manifest in _rebuild_code (G…
feat(cli): use the incremental path for update (Graphify-Labs#4740)
fix(watch): keep cross-file resolution edges for the changed set (Gra…
test(watch): make the default-path assertion robust to the no-change …
fix(rebuild): include the code-only scope in the no-change skip key (#…
feat(watch): derive changed_paths from the manifest in _rebuild_code (#…
feat(cli): use the incremental path for update (#4740)
fix(watch): keep cross-file resolution edges for the changed set (#4740)
test(watch): make the default-path assertion robust to the no-change …
fix(update): restore missing clustered graph reports