graphify icon indicating copy to clipboard operation
graphify copied to clipboard

[Bug]: update starts one worker per CPU core even for tiny repos (about 1 GB on a 12-core laptop for requests)

Open rohit-jsfreaky opened this issue 3 weeks ago • 1 comments

Pre-flight checks

  • [x] I have checked the Troubleshooting section in the README

What happened?

graphify update on a small repo starts one worker process per CPU core (max_workers = min(cpu_count, uncached files) in graphify/extract.py). Each worker loads graphify and the tree-sitter grammars, so memory grows with the core count, not with the repo. A 12-core laptop uses about 1 GB to index requests.

GRAPHIFY_MAX_WORKERS=12 on a 4-core Linux box, to match a 12-core laptop (tree RSS = main process + workers):

repo (code files) 12 workers on v8 1-3 workers
requests (62) 2.32 s / 1,050 MB 2.84 s / 122 MB
flask (102) 3.12 s / 1,063 MB 3.39 s / 271 MB
click (145) 4.44 s / 1,096 MB 4.18 s / 377 MB

On a real 12-core Windows laptop: click 701 MB with 12 workers vs 183 MB with 1, graph identical.

Steps to reproduce

git clone --depth 1 https://github.com/pallets/click && cd click
/usr/bin/time -v graphify extract . --code-only --out /tmp/o   # on a many-core machine
GRAPHIFY_MAX_WORKERS=1 /usr/bin/time -v graphify extract . --code-only --out /tmp/o2

Error output or graph output

No error. Memory is 3-8x higher than the work needs. Users can set GRAPHIFY_MAX_WORKERS, but most don't know it exists.

Graphify version

0.9.106 (v8 at 35d1d203)

Operating System

Linux (measured), also Windows

Python Version

3.13

Installation Method

uv tool install (recommended)

rohit-jsfreaky avatar Nov 11 '26 18:11 rohit-jsfreaky

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.

github-actions[bot] avatar Nov 11 '26 18:11 github-actions[bot]