Acknowledgement
Comment
Reproduction:
-
Clone the kibana repo
cd /tmp
git clone --depth https://github.com/elastic/kibana
cd kibana
yarn
yarn kbn bootstrap
code .
-
Generate typecheck tsconfigs:
node scripts/type_check.js
Don't wait for the script to finish.
Once you see info starting [tsc] > node_modules/typescript-7/bin/tsc -b tsconfig.refs.json --builders 6 --checkers 3 --pretty in output, you can ctrl-c it.
-
Put "js/ts.customConfigFileName": "tsconfig.type_check.json", into .vscode/settings.json
-
Open src/core/packages/chrome/browser/src/nav_links.ts
-
Locate category?: AppCategory and request Find All References on category
-
Run Developer: TypeScript: Save Heap Profile
-
Open alloc_space flamegraph
For projects like Kibana with a lot of compilerOptions.paths, allocating ParsedPatterns for every module resolution consumes too much memory.
|
func TryParsePatterns(pathMappings *collections.OrderedMap[string, []string]) *ParsedPatterns { |
|
paths := pathMappings.Keys() |
|
|
|
numPatterns := 0 |
|
for path := range paths { |
|
if pattern := core.TryParsePattern(path); pattern.IsValid() && pattern.StarIndex == -1 { |
|
numPatterns++ |
|
} |
|
} |
|
numMatchables := pathMappings.Size() - numPatterns |
|
|
|
var patterns []core.Pattern |
|
var matchableStringSet collections.Set[string] |
|
if numPatterns != 0 { |
|
patterns = make([]core.Pattern, 0, numPatterns) |
|
} |
|
if numMatchables != 0 { |
|
matchableStringSet = *collections.NewSetWithSizeHint[string](numMatchables) |
|
} |
|
|
|
for path := range paths { |
|
if pattern := core.TryParsePattern(path); pattern.IsValid() { |
|
if pattern.StarIndex == -1 { |
|
matchableStringSet.Add(path) |
|
} else { |
|
patterns = append(patterns, pattern) |
|
} |
|
} |
|
} |
|
return &ParsedPatterns{ |
|
matchableStringSet: matchableStringSet, |
|
patterns: patterns, |
|
} |
|
} |
Acknowledgement
Comment
Reproduction:
Clone the kibana repo
Generate typecheck tsconfigs:
Don't wait for the script to finish.
Once you see
info starting [tsc] > node_modules/typescript-7/bin/tsc -b tsconfig.refs.json --builders 6 --checkers 3 --prettyin output, you canctrl-cit.Put
"js/ts.customConfigFileName": "tsconfig.type_check.json",into.vscode/settings.jsonOpen
src/core/packages/chrome/browser/src/nav_links.tsLocate
category?: AppCategoryand request Find All References oncategoryRun
Developer: TypeScript: Save Heap ProfileOpen
alloc_spaceflamegraphFor projects like Kibana with a lot of
compilerOptions.paths, allocatingParsedPatternsfor every module resolution consumes too much memory.TypeScript/tsc/internal/module/resolver.go
Lines 2011 to 2044 in 8ac035a