microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.82k stars 12.46k forks source link

Editing Pulumi scripts (Typescript): CPU maxes out #45788

Closed vincesp closed 2 months ago

vincesp commented 3 years ago

Issue Type: Bug

Editing an NPM project that contains Pulumi scripts in Typescript.

High CPU load on process "Code Helper (Renderer)"

Error message in VS Code: "The TypeScript language service died unexpectedly 5 times in the last 5 Minutes."

VS Code version: Code 1.59.1 (3866c3553be8b268c8a7f8c0482c0c0177aa8bfa, 2021-08-19T11:53:52.479Z) OS version: Darwin x64 20.6.0 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|7, 9, 11| |Memory (System)|16.00GB (1.76GB free)| |Process Argv|--crash-reporter-id 87c9fe1a-c202-411b-8b12-fe0c69314b53| |Screen Reader|no| |VM|0%|
Extensions (63) Extension|Author (truncated)|Version ---|---|--- vscode-openapi|42C|4.6.3 Bookmarks|ale|13.1.0 ng-template|Ang|12.2.0 swagger-viewer|Arj|3.1.2 asciidoctor-vscode|asc|2.8.9 npm-intellisense|chr|1.4.0 bracket-pair-colorizer|Coe|1.0.61 vscode-svgviewer|css|2.0.0 xml|Dot|2.5.1 vscode-npm-script|eg2|0.3.22 prettier-vscode|esb|8.1.0 github-actions|for|0.0.1 go|gol|0.27.2 gitignore-templates|has|1.0.1 vscode-drawio|hed|1.6.2 reg|ion|1.0.3 vscode-edit-csv|jan|0.6.0 vue|jcb|0.1.5 vscode-gutter-preview|kis|0.27.1 git-graph|mhu|1.30.0 azure-pipelines|ms-|1.191.0 vscode-azureappservice|ms-|0.23.0 vscode-azurefunctions|ms-|1.5.0 vscode-azureresourcegroups|ms-|0.4.0 vscode-azurestaticwebapps|ms-|0.8.0 vscode-azurestorage|ms-|0.12.1 vscode-cosmosdb|ms-|0.18.1 vscode-docker|ms-|1.16.1 python|ms-|2021.9.1191016588 vscode-pylance|ms-|2021.9.0 jupyter|ms-|2021.8.1236758218 remote-containers|ms-|0.191.1 remote-ssh|ms-|0.65.7 remote-ssh-edit|ms-|0.65.7 remote-wsl|ms-|0.58.2 vscode-remote-extensionpack|ms-|0.21.0 azure-account|ms-|0.9.8 azurecli|ms-|0.5.0 color-highlight|nau|2.4.0 vetur|oct|0.34.1 vscode-sassdoc|raf|1.0.2 java|red|0.81.0 vscode-commons|red|0.0.6 vscode-xml|red|0.18.0 vscode-yaml|red|0.22.0 LiveServer|rit|5.6.1 vue-vscode-extensionpack|sdr|0.2.0 vue-vscode-snippets|sdr|2.2.1 rewrap|stk|1.14.0 copy-with-imports|str|0.2.0 vscode-stylelint|sty|0.86.0 c4-dsl-extension|sys|2.2.5 vscode-status-bar-format-toggle|tom|2.0.0 vscodeintellicode|Vis|1.2.14 vscode-java-debug|vsc|0.35.0 vscode-java-dependency|vsc|0.18.7 vscode-java-pack|vsc|0.18.4 vscode-java-test|vsc|0.31.3 vscode-maven|vsc|0.33.0 gitblame|wad|8.1.0 vscode-jumpy|wma|0.3.1 JavaScriptSnippets|xab|1.8.0 markdown-all-in-one|yzh|3.4.0 (1 theme extensions excluded)
gjsjohnmurray commented 3 years ago

Does the Start Extension Bisect command narrow the issue down to a specific extension?

vincesp commented 3 years ago

Unfortunately not:

Extension Bisect is done but no extension has been identified. This might be a problem with Code.

vincesp commented 3 years ago

I got an additional error message:

Source: TypeScript and JavaScript Langauge Features (Extension)

vincesp commented 3 years ago

Continuing investigation: when running tcs in one of the subfolders of the VS Code workspace causing the problem, we get:

tsc

<--- Last few GCs --->

[19488:0x1046e6000]   123182 ms: Mark-sweep (reduce) 4078.0 (4108.2) -> 4078.0 (4107.9) MB, 2168.5 / 0.0 ms  (average mu = 0.089, current mu = 0.000) last resort GC in old space requested
[19488:0x1046e6000]   125342 ms: Mark-sweep (reduce) 4078.0 (4092.9) -> 4078.0 (4093.9) MB, 2160.3 / 0.0 ms  (average mu = 0.046, current mu = 0.000) last resort GC in old space requested

<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 0x1012d96a5 node::Abort() (.cold.1) [/usr/local/bin/node]
 2: 0x1000a6309 node::Abort() [/usr/local/bin/node]
 3: 0x1000a646f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x1001e8f57 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x1001e8ef3 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 6: 0x100395df5 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 7: 0x10039f10c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 8: 0x100366800 v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArrayWithFiller(v8::internal::Handle<v8::internal::Map>, int, v8::internal::Handle<v8::internal::Oddball>, v8::internal::AllocationType) [/usr/local/bin/node]
 9: 0x1005e6fc0 v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::Rehash(v8::internal::Isolate*, v8::internal::Handle<v8::internal::OrderedHashMap>, int) [/usr/local/bin/node]
10: 0x1006d1d6f v8::internal::Runtime_MapGrow(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
11: 0x100a71919 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
zsh: abort      tsc

Root cause might be a bug in the tcs type resolution. Maybe the GUI plugin should use a different strategy in such a case, instead of aggressively trying to restart the buggy process?

mjbvz commented 3 years ago

Does this reproduce in the latest VS Code insiders build with all extensions disabled?

Also can you please share a minimal example project that demonstrates this issue?