mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-30 17:33:26 +08:00
The check took ~257s and would sometimes run out of memory. Two separate bottlenecks were responsible. layersChecker.ts built a full in-process ts.Program (15s, 2GB) and then asked the type checker for a symbol at every property access in the program, ~2.5M identifiers. Each lookup materialized symbol and type objects, pushing the heap past 3.6GB, and the alias/containment chain was then walked per symbol. It now runs on the TS7 native API that the repo already vendors for build/lib/tsgo.ts: - updateSnapshot replaces createProgram, so the program lives in the compiler rather than the V8 heap - the disallowed types are resolved to symbols once up front, turning the per-reference check into a local id lookup - symbol lookups are batched instead of issued one node at a time - property accesses are prefiltered by member name, so only those that could name a member of a disallowed type are resolved at all That brings it from 48.6s and 3.8GB peak to 11.7s and 0.8GB peak. The six tsconfig.<layer>.json projects were type checked serially with TS6, which accounted for the remaining ~208s. They move to the native compiler and run in parallel in the new layersTypeCheck.ts, taking ~11s. Concurrency is derived from free memory (the largest project peaks at ~3.5GB) so a memory-constrained machine falls back towards serial execution rather than swapping. Verified to report byte-identical violations, including line and column, against a seeded set covering direct references, import aliases, inherited members, nested member access and ipcMain. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>