Early-read var analysis repeatedly rescans large bundles for named function references
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
Direzione di ricerca
Read the regression tests in packages/compiler/src/frontend/lowering/var-hoisting.test.ts and the existing implementation described in the issue. Run pnpm exec vitest run packages/compiler/src/frontend/lowering/var-hoisting.test.ts from a prepared checkout to review the four tests covering scan counts and binding boundaries. The requested work is already present in main and PR #1577; this issue's contribution is test coverage.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
We are experimenting with compiling the complete Sentry CLI with scriptc without removing functionality, then benchmarking it against the existing Node SEA build. Its large dependency bundle exposed repeated whole-file work in early-read var analysis.
Observed behavior
earlyReadVarSymbols already builds a symbol-keyed reference index for a source file. However, ScopeAnalysis.referencesOf calls referencesByName again for each named function it analyzes. A bundle with many function declarations can therefore trigger repeated traversal of the same AST.
A reduced call-chain workload has this shape, scaled to 1,000 links:
var value = 7;
function f0() { return value; }
function f1() { return f0(); }
function f2() { return f1(); }
// Continue the chain through f1000.
f1000();
In three local fresh-program runs on Darwin arm64 with Node 24.22.0, the early-read analysis alone took approximately 961–1,010 ms before the change and 15–16 ms after it. An unused-functions control remained around 15–17 ms in both versions. The baseline was 18400d0, compared with PR head 17fa1a4. These are analysis microbenchmarks, not full compilation or CLI runtime measurements.
Expected behavior and reproduction
Whole-file reference scans should not grow with the number of named functions. Reuse must preserve binding identity, shadowing, duplicate declarations, shorthand references, and separate immutable source-file snapshots.
The regression tests in #1577 compare whole-file scan counts for 12- and 48-function chains and cover those binding boundaries. From a prepared checkout containing the tests:
pnpm exec vitest run packages/compiler/src/frontend/lowering/var-hoisting.test.ts
Proposed fix and scope
#1577 includes function names when building the existing per-file index and passes that index into ScopeAnalysis. Function references are retrieved by symbol rather than by another file traversal. It preserves the existing settlement rules.
Local baseline/candidate checks returned identical early-read results for 30 explicit and 150 generated cases. The 32-workload artifact comparison and compiler self-host LLVM comparison were also byte-identical. The complete CLI remains blocked elsewhere; whole-compiler timing and full CLI benchmarks are still outstanding.
Current status
Main now contains an alternative fix in 70aed0f13: it collects identifiers for function declarations in one lazy per-file name index and resolves the relevant references by symbol. PR #1577 preserves that implementation exactly and now contributes the four regression tests described above. The original timing comparison documents the investigation; it is not a new performance gain attributable to the current test-only PR.
- Lingua principale
- TypeScript
- Stelle
- 6.4k
- Fork
- 201
- Merge medio
- 4h 19m
- PR unite (30g)
- 878
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vercel-labs/scriptc
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 53/100
vercel-labs/scriptc#2159 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
vercel-labs/scriptc#2158 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 49/100
vercel-labs/scriptc#2143 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 56/100
vercel-labs/scriptc#2142 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 57/100
vercel-labs/scriptc#2141 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di vercel-labs/scriptc
Issue simili
-
bug require-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
expressjs/expressjs.com#2549 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
umami-software/umami#4686 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug]: Device screenshot fails with 500 on iPhone Duo (Xcode 27.2): serve-sim calls simctl without --displayForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
pingdotgg/t3code#24900 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
inu-appcenter/UNIDorm-web#411 ·
I maintainer di solito rispondono entro 1 giorno
-
🐛 bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni