Skip to content

Commit 73d755f

Browse files
committed
Merge remote-tracking branch 'origin/main' into perf/query-latency-regression
Impact: 3 functions changed, 8 affected
2 parents 7491363 + 54e6115 commit 73d755f

9 files changed

Lines changed: 502 additions & 37 deletions

File tree

.claude/skills/dogfood/SKILL.md

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,17 @@ Your goal is to install the published package, exercise every feature, compare e
6969
```
7070
This should report `engine: native`. If it falls back to `wasm`, record why.
7171
5. Record: platform, OS version, Node version, native binary package name + version, engine reported by `info`.
72-
6. **Do NOT rebuild the graph yet.** The first phase tests commands against the codegraph source repo without a pre-existing graph.
72+
6. **Update the native binary in the source repo.** The source repo's `node_modules` may have a stale native binary from a previous release. Since Phases 1–4 run commands against the source repo (using `--db` or directly), a version mismatch produces wrong results for **all phases**, not just benchmarks. Check and fix immediately:
73+
```bash
74+
# In the codegraph source repo:
75+
node -e "const p = require('@optave/codegraph-win32-x64-msvc/package.json'); console.log('Source repo native binary:', p.version)"
76+
```
77+
If the version does **not** match `$ARGUMENTS`, install the correct binary now:
78+
- **Stable release:** `npm install @optave/codegraph-win32-x64-msvc@$ARGUMENTS` (adjust platform suffix)
79+
- **Dev build:** `npm install https://github.com/optave/codegraph/releases/download/dev-v$ARGUMENTS/optave-codegraph-win32-x64-msvc-$ARGUMENTS.tgz`
80+
81+
Verify with `npx codegraph info` in the source repo. Revert `package.json` / `package-lock.json` changes after the session (do not commit them on the fix branch).
82+
7. **Do NOT rebuild the graph yet.** The first phase tests commands against the codegraph source repo without a pre-existing graph.
7383

7484
---
7585

@@ -202,30 +212,13 @@ Run all four benchmark scripts from the codegraph source repo and record results
202212

203213
### Pre-flight: verify native binary version
204214

205-
**Before running any benchmarks**, confirm the native binary in the source repo matches the version being dogfooded. A stale binary will produce misleading results (e.g., the Rust engine may lack features added in the release, causing silent WASM fallback during the complexity phase).
215+
If you followed Phase 0 step 6, the source repo's native binary should already match `$ARGUMENTS`. Double-check before benchmarking:
206216

207217
```bash
208-
# In the codegraph source repo — adjust the platform package name as needed:
209-
node -e "const r=require('module').createRequire(require('url').pathToFileURL(__filename).href); const pkg=r.resolve('@optave/codegraph-win32-x64-msvc/package.json'); const p=require(pkg); console.log('Native binary version:', p.version)"
218+
node -e "const p = require('@optave/codegraph-win32-x64-msvc/package.json'); console.log('Native binary version:', p.version)"
210219
```
211220

212-
If the version does **not** match `$ARGUMENTS`:
213-
214-
**Stable release** (no `-dev.` in version):
215-
1. Update `optionalDependencies` in `package.json` to pin all `@optave/codegraph-*` packages to `$ARGUMENTS`.
216-
2. Run `npm install` to fetch the correct binaries.
217-
3. Verify with `npx codegraph info` that the native engine loads at the correct version.
218-
4. Revert the `package.json` / `package-lock.json` changes after benchmarking (do not commit them on the fix branch).
219-
220-
**Dev build** (version contains `-dev.`):
221-
Native binaries for dev builds are not on npm — they are in the GitHub release tarballs. Install the platform binary directly:
222-
1. Download the platform tarball into the source repo:
223-
```bash
224-
# Example for Windows x64 — adjust platform suffix as needed:
225-
npm install https://github.com/optave/codegraph/releases/download/dev-v$ARGUMENTS/optave-codegraph-win32-x64-msvc-$ARGUMENTS.tgz
226-
```
227-
2. Verify with `npx codegraph info` that the native engine loads at the correct version.
228-
3. Revert the `package.json` / `package-lock.json` changes after benchmarking (do not commit them on the fix branch).
221+
If it doesn't match, go back to Phase 0 step 6 and fix it — **all benchmark results with a stale binary are invalid.**
229222

230223
**Why this matters:** The native engine computes complexity metrics during the Rust parse phase. If the binary is from an older release that lacks this, the complexity phase silently falls back to WASM — inflating native complexity time by 50-100x and making native appear slower than WASM.
231224

generated/benchmarks/BUILD-BENCHMARKS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,18 @@ remains at 6.6 ms/file (vs 5.0 in v2.0.0). The WASM/Native ratio widened from
166166
2.0x to 3.5x. Further optimization of WASM boundary crossings in the JS
167167
extractor is needed to recover the regression.
168168

169+
**Build regression (v3.1.4 3.5 ms/file → v3.3.0 8 ms/file, +129% native):** The codebase grew from
170+
398 to 429 files (+8%), but the per-file regression is real and driven by richer extraction. Between
171+
v3.1.4 and v3.3.0, type inference was extended to all typed languages (#501), receiver type tracking
172+
with graded confidence was added (#505), re-exported barrel file symbols are now tracked (#515), and
173+
package.json exports + monorepo workspace resolution was introduced (#509). These produce 33% more
174+
nodes/file (13.4 → 17.8) and 28% more edges/file (28.8 → 36.8). The Parse phase tripled on native
175+
(468 → 1511 ms) because extractors now perform additional AST traversals for type annotations and
176+
receiver resolution. The Complexity phase grew 10× (16 → 179 ms) because 33% more functions each
177+
require full AST analysis. Major refactors also decomposed monolithic extractors into per-category
178+
handlers (#490) and split domain/feature modules (#491, #492), adding 31 new source files — the
179+
benchmark measures codegraph on itself, so more source files amplify per-file overhead.
180+
169181
**Native build regression (v3.0.0 4.4 ms/file → v3.0.3 12.3 ms/file):** The regression is entirely
170182
from new build phases added in v3.0.1 that are now default-on: AST node extraction (651ms),
171183
dataflow analysis (367ms), and CFG construction (169ms) — totalling ~1,187ms of new work. The original

generated/benchmarks/INCREMENTAL-BENCHMARKS.md

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Import resolution: native batch vs JS fallback throughput.
66

77
| Version | Engine | Files | Full Build | No-op | 1-File | Resolve (native) | Resolve (JS) |
88
|---------|--------|------:|-----------:|------:|-------:|------------------:|-------------:|
9+
| 3.3.0 | native | 429 | 3.0s ↑141% | 10ms ↑67% | 417ms ↑74% | 10ms ↑700% | 26ms ↑888% |
10+
| 3.3.0 | wasm | 429 | 4.3s ↑29% | 11ms ~ | 479ms ↑41% | 10ms ↑700% | 26ms ↑888% |
911
| 3.1.4 | native | 398 | 1.3s ↑9% | 6ms ~ | 240ms ↓11% | 1ms ↓37% | 3ms ↓45% |
1012
| 3.1.4 | wasm | 398 | 3.3s ↑10% | 11ms ↑83% | 340ms ↓28% | 1ms ↓37% | 3ms ↓45% |
1113
| 3.1.3 | native | 236 | 1.2s ~ | 6ms ↑20% | 271ms ↑3% | 2ms ↓5% | 5ms ~ |
@@ -31,37 +33,87 @@ Import resolution: native batch vs JS fallback throughput.
3133

3234
### Latest results
3335

34-
**Version:** 3.1.4 | **Files:** 398 | **Date:** 2026-03-16
36+
**Version:** 3.3.0 | **Files:** 429 | **Date:** 2026-03-19
3537

3638
#### Native (Rust)
3739

3840
| Metric | Value |
3941
|--------|------:|
40-
| Full build | 1.3s |
41-
| No-op rebuild | 6ms |
42-
| 1-file rebuild | 240ms |
42+
| Full build | 3.0s |
43+
| No-op rebuild | 10ms |
44+
| 1-file rebuild | 417ms |
4345

4446
#### WASM
4547

4648
| Metric | Value |
4749
|--------|------:|
48-
| Full build | 3.3s |
50+
| Full build | 4.3s |
4951
| No-op rebuild | 11ms |
50-
| 1-file rebuild | 340ms |
52+
| 1-file rebuild | 479ms |
5153

5254
#### Import Resolution
5355

5456
| Metric | Value |
5557
|--------|------:|
56-
| Import pairs | 175 |
57-
| Native batch | 1ms |
58-
| JS fallback | 3ms |
58+
| Import pairs | 664 |
59+
| Native batch | 10ms |
60+
| JS fallback | 26ms |
5961
| Per-import (native) | 0ms |
6062
| Per-import (JS) | 0ms |
61-
| Speedup ratio | 2.2x |
63+
| Speedup ratio | 2.7x |
6264

6365
<!-- INCREMENTAL_BENCHMARK_DATA
6466
[
67+
{
68+
"version": "3.3.0",
69+
"date": "2026-03-19",
70+
"files": 429,
71+
"wasm": {
72+
"fullBuildMs": 4265,
73+
"noopRebuildMs": 11,
74+
"oneFileRebuildMs": 479,
75+
"oneFilePhases": {
76+
"setupMs": 1.7,
77+
"parseMs": 193.6,
78+
"insertMs": 8.3,
79+
"resolveMs": 1.7,
80+
"edgesMs": 14.7,
81+
"structureMs": 16.5,
82+
"rolesMs": 50.4,
83+
"astMs": 0.2,
84+
"complexityMs": 0.1,
85+
"cfgMs": 0.1,
86+
"dataflowMs": 0.2,
87+
"finalizeMs": 13.3
88+
}
89+
},
90+
"native": {
91+
"fullBuildMs": 3048,
92+
"noopRebuildMs": 10,
93+
"oneFileRebuildMs": 417,
94+
"oneFilePhases": {
95+
"setupMs": 1.2,
96+
"parseMs": 134,
97+
"insertMs": 7.9,
98+
"resolveMs": 1.6,
99+
"edgesMs": 25.1,
100+
"structureMs": 19.6,
101+
"rolesMs": 45.9,
102+
"astMs": 0.3,
103+
"complexityMs": 0.1,
104+
"cfgMs": 0.2,
105+
"dataflowMs": 0.2,
106+
"finalizeMs": 12
107+
}
108+
},
109+
"resolve": {
110+
"imports": 664,
111+
"nativeBatchMs": 9.6,
112+
"jsFallbackMs": 25.7,
113+
"perImportNativeMs": 0,
114+
"perImportJsMs": 0
115+
}
116+
},
65117
{
66118
"version": "3.1.4",
67119
"date": "2026-03-16",

0 commit comments

Comments
 (0)