Repository navigation
fix(build): speed up declaration input discovery - #164374
Conversation
Use the native syntax API without creating a project for each visited file. Keep acquisition lazy after source reads and retain the outer graph's module-resolution, ownership, failure-order, and cleanup contracts. The full 11-case declaration command used 6.63% less wall time and 4.69% less CPU in the source-pinned A-B-B-A comparison. Tests and runtime policy are unchanged.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 11:51 AM ET / 15:51 UTC (Revision 2). ClawSweeper reviewWhat this changesThe declaration build helper parses import syntax directly instead of creating a compiler project for each visited source file. Merge readiness✅ Ready for maintainer review The optimization remains useful and has no actionable review findings. The updated evidence resolves the previous current-input validation blocker. Priority: P3 Review scores
Verification
How this fits togetherDeclaration input discovery identifies source and toolchain files that affect generated TypeScript declarations and build-cache freshness. It extracts imports, resolves their targets, and supplies the declaration writer with a complete input inventory. flowchart TD
A[Declaration writer] --> B[Source and configuration files]
B --> C[Direct syntax parsing]
C --> D[Import resolution and ownership checks]
D --> E[Complete input inventory]
E --> F[Declaration generation and cache validation]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceOther +4. Total +4 across 1 file. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use direct syntax parsing while retaining the existing graph's resolution, input ownership, and cleanup contracts. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug report; the recorded native comparison provides a concrete way to measure the existing declaration discovery overhead. Is this the best way to solve the issue? Yes. The pinned compiler supports direct syntax extraction, and the patch preserves the existing owner for module resolution rather than introducing another graph. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 384d14f609e8. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
Use the native syntax API without creating a project for each visited file. Keep acquisition lazy after source reads and retain the outer graph's module-resolution, ownership, failure-order, and cleanup contracts. The full 11-case declaration command used 6.63% less wall time and 4.69% less CPU in the source-pinned A-B-B-A comparison. Tests and runtime policy are unchanged. Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Declaration input discovery creates a native compiler project for every source file when it only needs import syntax.
User Impact
Less compiler work during repository build validation. The measured full 11-case declaration command used 6.6% less wall time and 4.7% less CPU, with no intended declaration output or production-runtime change.
Why This Change Was Made
Use the pinned TypeScript API's
createSourceFilefor syntax extraction. A local disposable holder keeps API construction lazy, after graph setup and the source read. The existing outer graph still owns configuration and module resolution; dynamic-edge ownership, traversal and failure ordering stay unchanged. Cleanup retains its existing scope and exception behavior.Evidence
Merged as
b80b4d0b579568457b582f44e061b9b923649bc9through the native maintainer workflow. Current-input correctness, exact-head hosted CI, and post-merge consumer proof passed.On source
9a190f34b9c3198e40b43bdbd0f802088ea631d5, the completeCI=1 corepack pnpm test test/scripts/write-unified-entry-dts.test.tscommand ran A–B–B–A on one native Testbox. All four arms passed the same 11 cases, including dynamic/unresolved-edge rejection, declaration cache invalidation, and failed publication preserving the previous generation. Tests, fixtures, concurrency, caches and deadlines were unchanged; B1 and B2 used continuously identical candidate bytes.Mean wall time fell 22.56 → 21.065 s (6.63%); mean CPU fell 49.755 → 47.42 s (4.69%). Both candidate runs beat both baselines. RSS is GNU's process maximum, not aggregate concurrent memory. These measurements apply to this frozen 11-case workload, not the whole suite or production.
Focused formatting, script lint and script typechecking passed. Fresh independent review found no actionable findings through P2. Source, installed compiler inputs and native binaries were verified across the comparison, every managed process group joined, and baseline source was restored. Native Testbox run, Node 24.19.0, Linux x64, four available CPUs; its holder was canonically stopped after all proof and subsequent diagnostics settled.
Current-main applicability was inspected separately. The ACP/acpx dependency update is outside the selected fixture's executed package graph, but an imported worker-metadata module gained a test-worker entry. A separate full 11-case correctness run on main
a163d9b3db61f02143edef8a1f655c8a8448ee66with the exact reviewed candidate passed in 22.38 seconds, with matching case identities, source/dependency checks, joined processes and restored baseline. Current-input Testbox run; its holder was canonically stopped after the evidence was retained. This was a correctness check; the timing comparison remains attributed to the frozen source above.Exact-head hosted CI passed for
e7a547ca9466a4df11955b1b610726d0b9bd10cd. Its changed-test job covered other selected files, so the full current-input declaration proof comes from the separate run above. The full declaration consumer then passed all 11 cases on9f6cbe9c443769ac9c13b0b239b2c8f450230b77, a verified descendant of this merge. Source comparison established unchanged generator, parser, fixture, and dependency inputs; two unrelated test-routing lists changed. The AWS Crabbox command completed in 33.79 seconds on Node 24.19.0/Linux x64 with 32 available CPUs. All process groups joined and source/dependency bytes remained intact. This is descendant correctness evidence, not another performance comparison.