perf(hooks): eliminate multi-second foreground stalls before the detached launch#1601
Closed
TNRealtorApp wants to merge 1 commit into
Closed
perf(hooks): eliminate multi-second foreground stalls before the detached launch#1601TNRealtorApp wants to merge 1 commit into
TNRealtorApp wants to merge 1 commit into
Conversation
…ched launch Three foreground costs ran on every commit before the detached rebuild launcher even started: 1. Interpreter probes imported the full package. Each probe executed 'import graphify' wholesale — measured 13s per probe cold on a Windows 11 dev box with AV-scanned site-packages — and up to four probes could run synchronously. Probes now use importlib.util.find_spec, which locates the package without executing it (interpreter startup cost only). A broken install under the selected interpreter still fails loudly in the rebuild log, as before. 2. The shebang probe read a binary. Git for Windows' command -v can return the launcher path WITHOUT its .exe suffix, so the '*.exe)' guard missed and head -1 read a PE binary: the shell warned 'ignored null byte in input' on every commit and the garbage always fell through to the slow python3/python fallbacks. The Windows pip layout is now resolved directly (Scripts/graphify -> sibling ../python.exe, or ./python.exe for venvs), and the remaining POSIX shebang read strips NULs first. 3. GIT_DIR was re-derived. git exports GIT_DIR to hooks; the unconditional rev-parse added ~1.3s more on machines where every git exec is scanned. Now reused from the environment with rev-parse as the manual-run fallback. Measured on the affected machine: hook foreground drops from 26s+ (cold) to ~1.4s, warnings gone. Behavior is unchanged on healthy POSIX setups — probe order and fallback semantics are preserved. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
|
Merged into |
safishamsi
added a commit
that referenced
this pull request
Jul 2, 2026
Two 0.9.4 regressions (CLI cross-file indirect_call, stale community labels on re-cluster), the case-folding god-node fix (#1581), ~15 language extractor fixes (Ruby/Groovy/Elixir/Fortran/Rust/Julia/SystemVerilog/Scala/PowerShell/ ObjC/PHP/C#/C++/Swift), merge-graphs mixed-type handling (#1606), Swift singleton-into-local resolution (#1604), Homebrew python@ shebang (#1586), hooks foreground-stall perf (#1601), serve query stopwords (#1597) and multi-project MCP serving (#1594), plus JSON-loading hardening, dedup collision warning, and Windows hook worker limit. Built wheel validated in a clean venv: CLI reports 0.9.5, import resolves to the installed package, the case-folding and Swift-singleton fixes verified, and a real `graphify extract` produces indirect_call + inherits edges end-to-end. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows (and any machine with a cold import cache or AV-scanned site-packages),
git commitstalls for 10-40+ seconds inside the graphify post-commit hook before the #1161 detached launcher even starts:python -c 'import graphify', which executes the whole package import — measured 13s per probe (cold) on a Windows 11 dev box — and up to four probes can run synchronously per commit.command -v graphifycan return the launcher path without its.exesuffix, so the*.exe)guard misses andhead -1reads a PE binary: the shell printswarning: command substitution: ignored null byte in inputon every commit, and the garbage 'shebang' always fails the allowlist and falls through to the slowest fallbacks (including the Microsoft Storepython3alias).git rev-parse. git already exportsGIT_DIRto hooks; the unconditional re-derive costs another ~1.3s on machines where every git exec is AV-scanned.Fix
importlib.util.find_spec('graphify')— locates the package without executing it, so each probe costs interpreter startup only. A broken install under the selected interpreter still fails loudly in the rebuild log (same as today). Probe order and fallback semantics are unchanged.Scripts/graphify(.exe)→ sibling..\python.exe(or.\python.exefor venv Scripts dirs) — no binary parsing, works with or without the.exesuffix.head -c 256 | tr -d '\000' | head -n 1).GIT_DIR=${GIT_DIR:-$(git rev-parse --git-dir 2>/dev/null)}in both hooks (rev-parse remains the manual-invocation fallback).Measured (Windows 11, Python 3.13, real repo)
Tests
tests/test_hooks.py: 47 passed (4 new — find_spec probes, NUL-safe shebang read, sibling python.exe resolution, GIT_DIR reuse; plus the_launcher_payloaddocstring updated to match).🤖 Generated with Claude Code