Skip to content

[Bug]: one edited file still costs a full rebuild, so a warm graphify update goes from 2 s back to 68 s #4800

Closed

Description

@Deepjyoti-Sarmah

Pre-flight checks

  • I have checked the Troubleshooting section in the README

What happened?

v0.9.96 already skips a run where nothing changed. #4748 put a gate at the top of
_rebuild_code (graphify/watch.py:2081) that compares the manifest's per-file
ast_hash and a build-state stamp, then returns early.

That gate asks one yes/no question. Edit a file and it declines, so the run takes
the full path: detect, extract, build, cluster, analyze, report, export over the
whole corpus. One edited file costs what a cold build costs.

Same tree, 1,059 scanned files, one process per run:

run wall peak RSS
warm, nothing changed (gate) 1.96 s 46 MB
two files edited 68.15 s 1,071 MB

Nothing derives a change set. The manifest stores a content hash per file, and
_rebuild_code already accepts changed_paths; the only caller that passes one is
the post-commit hook, which gets it from git diff. graphify update passes
nothing (graphify/cli.py:2877), which the function documents as "the full code
corpus".

Expected: a run with two changed files re-extracts those two files.

Steps to reproduce

### Steps to reproduce


# graphify v8 at dac06345 (0.9.96), from a source checkout
# in a repo of about a thousand files:
graphify update .                      # cold build
graphify update .                      # warm: the gate skips, about 2 s
printf '\n# note\n' >> src/a.py
printf '\n# note\n' >> src/b.py
graphify update .                      # back to the full pipeline, about 68 s


Neither `--force` nor `changed_paths` is passed. `detect()` runs again, `extract()`
is handed the whole corpus, and build, cluster, analyze and report work over every
node. The call site is the `update` command:


# graphify/cli.py:2877
ok = _rebuild_code(watch_path, force=force, no_cluster=no_cluster, block_on_lock=True)

Error output or graph output

### Output

Same tree, 1,059 scanned files, one process per run.


# nothing changed
[graphify watch] No relevant changes; graphify-out left untouched.
1.96 s, peak RSS 46 MB

# two files edited, current v8
[graphify watch] Rebuilt: 22025 nodes, 47132 edges, 1031 communities
68.15 s, peak RSS 1,071 MB

# two files edited, with a manifest-derived change set (prototype, not on v8)
[graphify watch] Incremental: re-extracting 2 of 1059 scanned files that changed since the last build.
[graphify watch] Rebuilt: 22026 nodes, 47135 edges, 1017 communities
48.72 s, peak RSS 537 MB


19 of the 68 seconds, and half the memory. The rest is the pipeline after
extraction, which still runs over every node.

The one extra node in the third run is the pre-existing `any` residue: v8 with an
explicit `changed_paths` produces it too, so it is not something the change set
introduces.

Graphify version

0.9.96

Operating System

Linux

Python Version

3.13

Installation Method

built from source (git clone)

Additional Environment Details

Reproduced on a clean checkout of v8 (dac06345, 0.9.96), on a copy of this
repository's tracked files with worked/ removed: 1,059 scanned files, 583 of them
code. No provider environment variables involved, update is AST-only, and every
measurement is one process with no other load.

The warm rows are the second of two consecutive runs in the same tree, so the gate
sees an untouched output fingerprint. Copying a built tree with cp -r is not
equivalent: the copy gets new mtimes, the gate declines, and the run looks slow for
a reason that has nothing to do with this issue.

Additional context

Why this is separate from #4748. That PR answers "did anything change?" and
shipped in 0.9.96. The maintainer closed #4769 as superseded by it, because the two
look like the same work. They cover different cases: #4748 returns early only when
every scanned file already matches the manifest. One edited file leaves that early
return, and the whole cost returns with it. That is the 2 s to 68 s above.

What a change set would be. Content-addressed, from the manifest: rows whose
ast_hash moved, plus rows whose file is gone from disk. A deleted row has to be in
the set, or its nodes survive and the shrink guard refuses the write. The unchanged
corpus's AST nodes go to extract() as resolution context, or a call from a changed
file into an unchanged one loses its edge (#2406). A missing or unreadable manifest,
--force, and an explicit changed_paths all keep the full path.

What it does not fix. Extraction is only part of the run. Build, cluster,
analyze, report and export still work over every node, which is why 68 s becomes
49 s rather than seconds. On this corpus the JS/TS resolution pass re-parses the
TypeScript files too, because those suffixes bypass the AST cache on purpose. A
corpus where the graph stages dominate would gain less than this one.

Related. #4740 is the umbrella. #4748 shipped the no-change gate. #4769 was the
change-set attempt, closed as superseded. #2543 is why a corpus holding a file that
never extracts can never take the skip.

Found while working through #4740.

Activity

  1. added
    bug
    on Oct 26, 2026
  2. github-actions commented on Oct 26, 2026

    @github-actions

    Thanks for opening this issue, @Deepjyoti-Sarmah. 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.

  3. safishamsi commented on Nov 3, 2026

    @safishamsi
    Member

    Fixed in 0.9.102 (published to PyPI) via #4801 (and #4802). graphify update now re-extracts only the files whose content changed, with a graph identical to a full rebuild; a contended incremental request is recorded instead of dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions