Cache repeated computations in program construction hot paths - #63897
Cache repeated computations in program construction hot paths#63897no-yan wants to merge 1 commit into
Conversation
- fileLoader.toPath: called once per import edge with heavily repeated file names; cache the canonical path per loader. - Resolver conditions: newResolutionState rebuilt the same conditions slice for every resolution; precompute the import/require variants per resolver (project reference redirects fall back to GetConditions). The import/require classification is factored into conditionsUseImport, shared with GetConditions, and a test asserts the cached slices match GetConditions for every resolution mode. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
no-yan please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
1 similar comment
|
no-yan please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Part of a series reducing allocation churn on hot paths (see #63895 for
motivation and series-wide measurements).
This PR
fileLoader.toPath: called once per import edge with heavilyrepeated file names; each call re-normalized and re-lowercased the
path. Cache the canonical path per loader (
collections.SyncMap).newResolutionStaterebuilt the sameconditions slice for every resolution. Precompute the import/require
variants once per resolver; project-reference redirects (rare, options
differ from the resolver's own) fall back to
GetConditions. Theimport/require classification is factored into
conditionsUseImport,shared with
GetConditions, so the two cannot drift.Results
fileLoader.toPath→ToFileNameLowerCaseGetConditions(allocations per full vscode/src check, heap-profile attribution.)
BenchmarkNewProgramis unchanged (±1%, p > 0.19).Verification
TestGetConditionsCacheMatchesGetConditionsasserts the cached slicesequal
GetConditionsfor every resolution mode across representativeoption sets (node16/nodenext/bundler, custom conditions,
noDtsResolution).🤖 Generated with Claude Code