Repository navigation
Conversation
An incremental update calls _StoredSourcePaths.rebase_preserved for every preserved node, edge and hyperedge, and absolute_identity for every stored node and edge of the resolve context. Each call builds Path objects and walks parent directories, though the answer depends only on the stored source_file and roots fixed in __init__. Guava has 337k such items from 3.3k files. Cache both per file, as 1d38e84 did for identity(). A one-file update on Guava goes from 51.4s to 43.8s, with the reconcile step from 8.48s to 1.96s. graph.json, graph.html and GRAPH_REPORT.md are byte-identical on seven repos after a full build, one-file edits, and a delete plus add. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the pull request, @Max17190. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify code review 
Review completed · 5044b76025e1
Tip
Merge confidence: 5/5 · Looks safe to merge · 🟠 High impact
No issues reported
The change caches absolute-path identity and preserved-source rebasing results by source path.
Full summary
The change caches absolute-path identity and preserved-source rebasing results by source path. It adds tests for repeated-path cache reuse and unchanged rebasing results.
Code graph and static checks · 782 functions depend on this change
Impact & health
Impact — 782 functions depend on the 144 functions this change touches.
Health — grade A; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):
_rebuild_code()— 281 callers, 76 callees (high)dispatch_command()— 8 callers, 156 callees (high)main()— 128 callers, 3 callees (high)watch()— 8 callers, 15 callees (high)_reconcile_existing_graph()— 6 callers, 16 callees (high)_check_shrink()— 18 callers, 5 callees (high)_run_cli()— 11 callers, 8 callees (high)_reconcile_graph_html()— 8 callers, 5 callees (high)- …and 2 more
Formal checks — 782 functions this change can affect weren't formally checked in this review. Formal checks are informational only.
Gate & verification
✅ PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 506 function(s) in the blast radius were not formally verified this run
Test selection
49 of 593 test file(s) selected (8%) via static blast radius.
tests/test_4978_reconcile_cost.py— impacttests/test_build.py— impacttests/test_cache_stale_import_target.py— impacttests/test_code_only_scope_4923.py— impacttests/test_compact_graph_json.py— impacttests/test_cpp_forward_declarations.py— impacttests/test_cpp_incremental_type_resolution.py— impacttests/test_cpp_member_declaration_identity.py— impacttests/test_csharp_method_owner_labels.py— impacttests/test_csharp_object_creation.py— impacttests/test_elixir_import_resolution.py— impacttests/test_elixir_qualified_calls.py— impacttests/test_elixir_unqualified_call_scope.py— impacttests/test_export_direction.py— impacttests/test_external_stub_endpoints.py— impacttests/test_go_receiver_member_calls.py— impacttests/test_incremental_unscanned_placeholders.py— impacttests/test_java_member_calls.py— impacttests/test_java_nested_type_identity.py— impacttests/test_kotlin_grammar.py— impacttests/test_labeling.py— impacttests/test_language_override_lifecycle.py— impacttests/test_linked_worktree_reconcile.py— impacttests/test_lost_saved_semantic_nodes.py— impacttests/test_markdown_code_spans.py— impacttests/test_markdown_sections.py— impacttests/test_no_cluster_undeclared_endpoints.py— impacttests/test_pr10_watch_overrides.py— impacttests/test_python_inherited_method_calls.py— impacttests/test_python_injected_factory_calls.py— impacttests/test_python_property_reads.py— impacttests/test_python_pytest_fixture_receivers.py— impacttests/test_qualified_type_competition.py— impacttests/test_rust_use_trees.py— impacttests/test_semantic_origin_stamp.py— impacttests/test_skill_persisted_scan_options.py— impacttests/test_solidity_inherited_calls.py— impacttests/test_terraform_modules.py— impacttests/test_undirected_two_file_import_cycle.py— impacttests/test_update_incremental.py— impacttests/test_update_js_resolution_inputs.py— impacttests/test_update_lock_contention.py— impacttests/test_update_missing_graph.py— impacttests/test_update_no_change_gate.py— impacttests/test_watch.py— impacttests/test_watch_identity_cache.py— impact, changed-testtests/test_watch_inotify_overflow.py— impacttests/test_watch_manifest_location.py— impacttests/test_watch_pruned.py— impact
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Why
After a one-file change,
graphify updatestill spends seconds on path bookkeeping for the whole graph._reconcile_existing_graphcallsrebase_preservedfor every preserved node, edge and hyperedge, and the resolve context callsabsolute_identityfor every stored node and edge. Each call builds Path objects and walks parent directories, though the answer depends only on the storedsource_fileand roots fixed in__init__. Guava has 337k such items from 3.3k files, and its deep Java package paths make each call slower.1d38e84 cached
identity()andin_watch_root()for the same reason. These two calls were left uncached.graphify updateMedian of 3 runs on an Apple M5 with Python 3.13. The whole-update saving is larger than the reconcile saving because the resolve context's
absolute_identitycalls sit outside_reconcile_existing_graph.Summary
rebase_preservedworks out the newsource_fileonce per distinct stored value and reuses it. The rewrite logic moves unchanged into_rebased_uncached.absolute_identitycaches per(source_file, root), the same wayidentity()does._StoredSourcePathslives for one update, and its roots are resolved before the update starts, so a cached answer cannot go stale.Test plan
The first new test counts normalizations and containment checks across 51 passes over three files. On v8 it fails with 210 and 153, and with this change both stop at 10 and 3 after the first pass. The second test pins the rewritten
source_filefor paths inside the root,./and..segments, backslashes, a path outside the root, empty and missing values, and a watched root outside the project root. Its expected values pass on v8 too.End to end on gin, ripgrep, axum, clap, excalidraw, Django and Guava, I ran a full build, three one-file edits with
graphify update, and an update that deleted one file and added another, on v8 and on this branch at the same path.graph.json,graph.htmlandGRAPH_REPORT.mdcame out byte-identical after every step.manifest.jsonand the build state differ only in timestamps.