Indexing pretix (1,466 files) takes 19.9 s on main at 6560052a (1.6.2), up from 8.3 s. A git bisect over 290e03f7..6560052a points at cf449fda (#2163):
| Commit |
codegraph init on pretix |
d03e4dbf (parent) |
8.34 s |
cf449fda (#2163) |
18.65 s |
6560052a (1.6.2) |
19.91 s |
Each step was one run on Node 24 on a 16-vCPU WSL2 host, with CODEGRAPH_NO_DAEMON=1 and telemetry off. Across the nine runs the fast builds took 7.95 to 8.34 s and the slow ones 17.70 to 19.91 s.
Cause. matchDestructuredCallResult runs for every bare JS-family call in a file that contains const {, let { or var {. For each call it joins every line above the call, runs stripCommentsForRegex and blankStringContents over that text, walks it a character at a time in stackAt, and matches the binding regex across it. The work for a file grows with the square of its size. pretix ships bundled libraries under src/pretix/static/: pdfjs/pdf.worker.js (1.95 MB), d3/d3.v6.js (560 KB) and pdfjs/pdf.js (497 KB).
A node --cpu-prof run at cf449fda shows each of the six resolver workers busy for 15.7 s. Self time summed over all threads:
stripCStyle: 12.7 s
blankStringContents: 11.2 s
- the
const { test and the binding regex: 3.6 s
matchDestructuredCallResult: 2.5 s
stackAt: 0.6 s
Possible fix. Most calls in such a file don't go through a destructured name. Strip the file once, collect the local names its const { … } = f(…) bindings introduce, cache that set per file, and return early when ref.referenceName isn't in it. Only calls through a destructured name would then pay for the prefix scan, and the links found stay the same. My fork's port of this resolver does this.
The summary line leaves out this time. For the 19.9 s run, codegraph init printed 32,322 nodes, 81,229 edges in 1.7s. In indexAll (src/index.ts), nodesCreated and edgesCreated are recomputed after resolution, but durationMs keeps the value from orchestrator.indexAll, which covers extraction only. The printed time leaves out resolution and linking, which is where this slowdown happens, so the CLI output didn't show it.
Indexing pretix (1,466 files) takes 19.9 s on
mainat6560052a(1.6.2), up from 8.3 s. Agit bisectover290e03f7..6560052apoints atcf449fda(#2163):codegraph initon pretixd03e4dbf(parent)cf449fda(#2163)6560052a(1.6.2)Each step was one run on Node 24 on a 16-vCPU WSL2 host, with
CODEGRAPH_NO_DAEMON=1and telemetry off. Across the nine runs the fast builds took 7.95 to 8.34 s and the slow ones 17.70 to 19.91 s.Cause.
matchDestructuredCallResultruns for every bare JS-family call in a file that containsconst {,let {orvar {. For each call it joins every line above the call, runsstripCommentsForRegexandblankStringContentsover that text, walks it a character at a time instackAt, and matches the binding regex across it. The work for a file grows with the square of its size. pretix ships bundled libraries undersrc/pretix/static/:pdfjs/pdf.worker.js(1.95 MB),d3/d3.v6.js(560 KB) andpdfjs/pdf.js(497 KB).A
node --cpu-profrun atcf449fdashows each of the six resolver workers busy for 15.7 s. Self time summed over all threads:stripCStyle: 12.7 sblankStringContents: 11.2 sconst {test and the binding regex: 3.6 smatchDestructuredCallResult: 2.5 sstackAt: 0.6 sPossible fix. Most calls in such a file don't go through a destructured name. Strip the file once, collect the local names its
const { … } = f(…)bindings introduce, cache that set per file, and return early whenref.referenceNameisn't in it. Only calls through a destructured name would then pay for the prefix scan, and the links found stay the same. My fork's port of this resolver does this.The summary line leaves out this time. For the 19.9 s run,
codegraph initprinted32,322 nodes, 81,229 edges in 1.7s. InindexAll(src/index.ts),nodesCreatedandedgesCreatedare recomputed after resolution, butdurationMskeeps the value fromorchestrator.indexAll, which covers extraction only. The printed time leaves out resolution and linking, which is where this slowdown happens, so the CLI output didn't show it.