Abnormal CPU usage
See original GitHub issueI have a few traces, but not sure how useful they are:
- Output of
code --status:
With Prisma Insider v7.0.3:
Version: Code 1.48.2 (a0479759d6e9ea56afa657e454193f72aef85bd0, 2020-08-25T10:09:08.021Z)
OS Version: Darwin x64 19.6.0
CPUs: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (12 x 2200)
Memory (System): 16.00GB (1.12GB free)
Load (avg): 4, 5, 3
VM: 0%
Screen Reader: no
Process Argv: --inspect-extensions=9993
GPU Status: 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
CPU % Mem MB PID Process
0 98 47408 code main
0 66 47414 gpu-process
0 16 47417 utility
0 131 47435 shared-process
0 0 47717 /bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command=
0 295 47524 window (schema.prisma — studio)
262 524 47525 extensionHost
0 82 47529 electron_node tsserver.js
0 131 47530 electron_node tsserver.js
0 82 47536 electron_node typingsInstaller.js typesMap.js
0 33 47531 electron_node cli.js
0 49 47532 electron_node server.js
0 33 47526 watcherService
0 33 47528 searchService
Workspace Stats:
| Window (schema.prisma — studio)
| Folder (studio): 921 files
| File types: ts(233) svg(93) js(89) tsx(74) scss(72) map(55) json(34)
| DS_Store(31) sh(24) html(16)
| Conf files: package.json(10) tsconfig.json(6) github-actions(3)
| project.json(1) webpack.config.js(1)
With Prisma (Stable?) v2.6.1:
Version: Code 1.48.2 (a0479759d6e9ea56afa657e454193f72aef85bd0, 2020-08-25T10:09:08.021Z)
OS Version: Darwin x64 19.6.0
CPUs: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (12 x 2200)
Memory (System): 16.00GB (1.18GB free)
Load (avg): 4, 4, 4
VM: 0%
Screen Reader: no
Process Argv: --inspect-extensions=9993
GPU Status: 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
CPU % Mem MB PID Process
0 98 47408 code main
0 66 47414 gpu-process
0 16 47417 utility
0 131 47435 shared-process
0 0 47789 /bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command=
46 295 47740 window (schema.prisma — studio)
209 541 47743 extensionHost
0 82 47748 electron_node tsserver.js
0 147 47749 electron_node tsserver.js
0 82 47755 electron_node typingsInstaller.js typesMap.js
0 33 47751 electron_node cli.js
0 49 47752 electron_node server.js
0 33 47744 watcherService
0 33 47747 searchService
Workspace Stats:
| Window (schema.prisma — studio)
| Folder (studio): 921 files
| File types: ts(233) svg(93) js(89) tsx(74) scss(72) map(55) json(34)
| DS_Store(31) sh(24) html(16)
| Conf files: package.json(10) tsconfig.json(6) github-actions(3)
| project.json(1) webpack.config.js(1)
Without any Prisma Extension
Version: Code 1.48.2 (a0479759d6e9ea56afa657e454193f72aef85bd0, 2020-08-25T10:09:08.021Z)
OS Version: Darwin x64 19.6.0
CPUs: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (12 x 2200)
Memory (System): 16.00GB (1.56GB free)
Load (avg): 3, 4, 3
VM: 0%
Screen Reader: no
Process Argv: --inspect-extensions=9993
GPU Status: 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
CPU % Mem MB PID Process
0 98 47408 code main
0 66 47414 gpu-process
0 16 47417 utility
0 131 47435 shared-process
0 0 47832 /bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command=
0 279 47799 window (schema.prisma — studio)
0 98 47800 extensionHost
0 82 47801 electron_node tsserver.js
0 131 47802 electron_node tsserver.js
0 82 47806 electron_node typingsInstaller.js typesMap.js
0 49 47804 electron_node server.js
0 33 47805 searchService
0 33 47809 watcherService
Workspace Stats:
| Window (schema.prisma — studio)
| Folder (studio): 921 files
| File types: ts(233) svg(93) js(89) tsx(74) scss(72) map(55) json(34)
| DS_Store(31) sh(24) html(16)
| Conf files: package.json(10) tsconfig.json(6) github-actions(3)
| project.json(1) webpack.config.js(1)
Notable difference is the CPU usage by extensionHost.
- Profiling info (from VSCode) (with Prisma Insider v7.0.3): CPU-20200903T140515.170Z.cpuprofile.txt
I’ve been following this guide for this information: https://github.com/Microsoft/vscode/wiki/Performance-Issues
Also note that there isn’t one single action that causes the slowdown, just having the extension enabled seems to be enough.
If you need any more info, please let me know!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:11 (4 by maintainers)

Top Related StackOverflow Question
Background
I am noticing the same issue with 2.6.2, 2.6.1 and 2.6.0. Took me forever to hunt down which extension was causing the issue. I believe this is also the reason my extensions/vs code have been crashing when left open for a long time (like overnight)
Debugging
I have traced the issue back to here. https://github.com/prisma/language-tools/blob/5cef1e72ffb8c6addd052fb66d69daa865485535/packages/vscode/src/extension.ts#L70
Without this line the high CPU issue does not occur. This line was introduced in this commit. https://github.com/prisma/language-tools/commit/2979552ee371085c645ece28f857eada2f71959b
When logging the
watcherit shows thatusePollingis enabled with an interval of100. This is because internally tochokidarit checks to see iffseventsis installed dynamically usingrequire()(asfseventsis an optional dependency) and in this casefseventsis not a dependency of theprismalanguage service.Summary
The issue is because
chokidaris polling becausefseventsis not a dependency. The easy solution is to addfseventsas a dependency however I am not sure iffseventsworks in all environments (like Windows) aschokidardetails in their documentation thatuseFsEventsis only the default on macOS. It may be a good idea to reduce the interval to avoid issues on other platforms or find another solution rather then polling.Additional problems
I have noticed in the latest release that the TS Sever will spam restart when running
ngccin a project with the Prisma extension installed and aprisma.schemafile open. I would greatly appreciate it if this could be avoided.Temporary fix (macOS Only)
Run the following commands in the terminal
Then reload VS Code
@Jolg42 Hi, same here, it’s all good.
I went from 161% CPU to 0% and everything refreshes as expected.
MacOS 12.5.12,6 GHz Intel Core i7