Skip to content

[Bug]: extract() resolves the same paths ~24k times and the call tie-break re-parses candidate paths on every site #4194

Closed

Description

@rohit-jsfreaky

Pre-flight checks

  • I have checked the Troubleshooting section in the README

What happened?

Profiling a no-change graphify update on graphify's own repo shows two pieces of repeated path work that do not depend on anything that changes during the run:

  1. extract()'s id remap calls Path.resolve() on the same file paths once per input, once per target_file-stamped edge (_raw_tp.resolve(), stem_forms.get(Path(tf).resolve())) and once per node (prefix_remap.get(Path(sf).resolve())): 23,819 calls from extract() itself for ~1k distinct files.
  2. paths._path_proximity_winner (the Cross-file calls edges dropped for any symbol with 2+ same-named definitions (test-mock stubs erase the real call graph) #1553 god-node tie-break) builds a PurePosixPath for every candidate's parent directory, twice (same-directory tier and common-prefix tier), on every ambiguous call site. A common name brings the same candidate files back on every site: 226,809 Path objects per update.

Expected: each distinct path resolved/parsed once; same graph.

Steps to reproduce

git clone https://github.com/Graphify-Labs/graphify && cd graphify
graphify update . --force                      # first build
python -c "import cProfile,sys; from graphify.__main__ import main; sys.argv=['graphify','update','.','--force']; cProfile.run('main()','u.prof')"
python -c "import pstats; p=pstats.Stats('u.prof'); p.sort_stats('cumulative'); p.print_callers('pathlib.py.*\\(resolve\\)'); p.print_callees('_path_proximity_winner')"

Error output or graph output

Path.resolve <- extract()            23,819 calls
_path_proximity_winner  1,649 calls -> PurePosixPath.__new__ 226,809 calls

Wall time of the whole update (not profiled), graphify's repo, 18,830 nodes: cold ~28 s, no-change ~21-25 s.

Graphify version

0.9.79 (f765dcb)

Operating System

Windows

Python Version

3.12

Installation Method

built from source (git clone)

Additional Environment Details

No provider keys set. Reproduces on a clean checkout of graphify itself.

Additional context

#3500 memoized path resolution inside the symbol-resolution passes; this is extract()'s own remap and the paths.py tie-break, which it did not cover. A fix with before/after numbers and identical-output checks is ready; PR right after this.

Activity

  1. github-actions commented on Oct 7, 2026

    @github-actions

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

  2. safishamsi commented on Oct 9, 2026

    @safishamsi
    Member

    Fixed by #4195 (thanks @rohit-jsfreaky), shipped in v0.9.80. Closing as resolved.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions