GitNexus/gitnexus/bench
Gergő Magyar 96132bd13a
perf(scope-resolution): stop re-scanning the ParsedFile store once per language (#3211)
* perf(scope-resolution): stop re-scanning the ParsedFile store once per language

Scope resolution calls `loadParsedFilesForPaths` once per language, and every
call walks every shard in the store. The skip decision needs the envelope's
path listing, and that listing is only trustworthy after the payload digest
has been checked -- so a pass that wants 50 Python files still opens and
SHA-256s all 413 shards / 301MB of a TypeScript-dominated store to prove it
can skip them. A pass wanting a SINGLE file costs 335ms. The cost scales with
language count, not with the files that language has, so a polyglot repo pays
it worst.

`tryLoadV8Cache` now returns the listing it already parsed for that skip
decision, and the store memoizes it per run. Later passes skip on the
memoized listing without reopening the file.

Measured on a 2234-file, 3-language repo, min-of-5:

  before   python 411ms   typescript 2872ms   javascript 507ms  = 3834ms
  after    python 415ms   typescript 2805ms   javascript 248ms  = 3484ms

-350ms here, roughly -250ms per additional language elsewhere. The first pass
is unchanged by construction -- it is what populates the memo. End-to-end the
graph is byte-identical: 51,288 nodes / 163,094 edges / 2106 clusters /
759 flows on a true incremental run.

Keyed on size+mtime as well as name. Shard names are content-addressed, so a
name collision across different content should be impossible, but that
invariant lives in the parse-cache keying rather than here and one stat per
shard is a few ms against the hundreds this saves. The memo holds one store
directory at a time, so a new repo in a long-lived MCP process drops the
previous set instead of accumulating.

The failure mode a listing memo introduces is a FALSE SKIP: a pass concludes a
shard holds nothing it wants and those files silently never reach the graph --
an exit-0 wrong answer, not a crash. The new test walks four passes with
disjoint wants over one store, plus a shard written after the memo is warm;
it fails when the skip is forced.

Also records the full scopeResolution breakdown in bench/. The headline is
that `emit` is 7161ms of the 14.7s phase and ~21% of the edit loop, spread
across a fan of passes with no hot inner loop -- so the win there is not
running them for unchanged files, which is a design rather than a patch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Address PR review feedback (#3211)

Strengthen the shard-listing memo test so a later miss asserts fs.open and
v8.deserialize never run for the skipped shard. Key-set checks alone still
passed if the memo never skipped.

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore(autofix): apply prettier + eslint fixes via /autofix command

---------

Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-09-08 13:48:30 +01:00
..
callable-value-flow fix(scope-resolution): parse def coordinates after file paths (#2743) 2026-07-30 07:34:32 +01:00
cfg feat(impact): opt-in PDG-backed impact mode - statement + inter-procedural slicing, resolved-callee-id soundness, mutation-oracle validated (#2227) 2026-06-20 12:04:32 +01:00
cpp-qualified-ns perf(cpp): index qualified namespace members once per pipeline run (#2788) (#2794) 2026-08-02 15:52:33 +01:00
cross-repo-trace fix(group)!: stop group sync claiming matching it never did (#3020) 2026-08-27 18:27:32 +01:00
emit-persistence feat(zig): mark CALLS edges inside comptime-false branches as staticGated (#3161) 2026-09-03 19:49:16 +01:00
finalize-reexport fix(python): resolve calls through __init__.py re-exports (#2864) 2026-08-09 12:21:06 +01:00
impact-pdg fix(impact-pdg): make the Impact PDG Mutation Report workflow pass (3 latent oracle bugs) (#2258) 2026-06-20 20:40:28 +01:00
import-target feat: add Zig language support (#1432) 2026-09-03 13:29:42 +01:00
java-lombok-synthesis feat(jvm): synthesize Lombok and Kotlin JVM accessor methods (#2885) 2026-08-31 17:55:52 +00:00
java-wildcard-route-constants feat(jvm): fold Java static wildcards and Kotlin star imports for route constants (#3110) 2026-08-31 21:58:40 +00:00
kotlin-import-target fix(kotlin): resolve imports from declared packages (#2990) 2026-08-18 20:47:30 -07:00
kotlin-jvm-accessors feat(jvm): synthesize Lombok and Kotlin JVM accessor methods (#2885) 2026-08-31 17:55:52 +00:00
kotlin-star-route-constants feat(jvm): fold Java static wildcards and Kotlin star imports for route constants (#3110) 2026-08-31 21:58:40 +00:00
lib feat(jvm): fold Java static wildcards and Kotlin star imports for route constants (#3110) 2026-08-31 21:58:40 +00:00
parse-dispatch-rounds perf(parse): tighten the dispatch-round memory bound and unclamp the worker-pool override (#3200) 2026-09-07 13:53:31 +01:00
python-scope feat: add Zig language support (#1432) 2026-09-03 13:29:42 +01:00
receiver-resolution feat: add Zig language support (#1432) 2026-09-03 13:29:42 +01:00
schema-pairs fix(scope-resolution): link Record graph nodes (#2871) 2026-08-07 18:33:27 +01:00
scope-capture feat: add Zig language support (#1432) 2026-09-03 13:29:42 +01:00
scope-emission fix(scope-resolution): resolve calls through a closure-valued binding across languages (#2693) (#2695) 2026-07-27 07:52:18 +01:00
spring-conditionals feat(spring): model profiles, conditions, and auto-configuration (#2678) 2026-07-28 07:05:41 +01:00
spring-config-bindings feat(kotlin): bind Spring config consumers on Kotlin sources (#3126) 2026-09-01 10:32:09 +00:00
v8-sidecar perf(store): V8 sidecars plus hardlinked ParsedFile restore (#3099) 2026-08-30 20:50:20 +00:00
zig-cross-file-resolution fix(zig): resolve cross-file static gates (#3185) 2026-09-07 07:19:30 +01:00
analyze-phase-breakdown.md perf(scope-resolution): stop re-scanning the ParsedFile store once per language (#3211) 2026-09-08 13:48:30 +01:00
parse-throughput.md fix(parse): correct worker-pool docs drift + surface worker-side stack on crash (#2068) (#2070) 2026-06-08 07:20:12 +01:00