question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Abnormal CPU usage

See original GitHub issue

I have a few traces, but not sure how useful they are:

  1. 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.

  1. 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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
wSedlacekcommented, Sep 6, 2020

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 watcher it shows that usePolling is enabled with an interval of 100. This is because internally to chokidar it checks to see if fsevents is installed dynamically using require() (as fsevents is an optional dependency) and in this case fsevents is not a dependency of the prisma language service.

Summary

The issue is because chokidar is polling because fsevents is not a dependency. The easy solution is to add fsevents as a dependency however I am not sure if fsevents works in all environments (like Windows) as chokidar details in their documentation that useFsEvents is 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 ngcc in a project with the Prisma extension installed and a prisma.schema file open. I would greatly appreciate it if this could be avoided.

Temporary fix (macOS Only)

Run the following commands in the terminal

cd ~/.vscode/extensions/prisma.prisma-2.6.2
yarn add fsevents

Then reload VS Code

3reactions
bbenezechcommented, Sep 16, 2022

@Jolg42 Hi, same here, it’s all good.

I went from 161% CPU to 0% and everything refreshes as expected.

MacOS 12.5.1 2,6 GHz Intel Core i7

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix High CPU Usage - Intel
How to Fix High CPU Usage · 1. Reboot · 2. End or Restart Processes · 3. Update Drivers · 4. Scan for...
Read more >
What is CPU usage, and how to fix high CPU usage
High CPU usage is often the cause of bad performance. Your computer may be affected by this problem if you're experiencing long loading ......
Read more >
How to Lower CPU Usage - NinjaOne
There are a few common fixes for high CPU load, some of which are Windows 10 specific, and others that work on nearly...
Read more >
How to Fix High CPU Usage (with Pictures) - wikiHow
1. Press .Ctrl+ Shift+Esc to open the Task Manager. This is a utility that monitors and reports on all of the processes and...
Read more >
How to Lower CPU Usage: Common Causes & Tips - N-able
The symptoms of high CPU usage are familiar: the cursor moves jerkily and slowly, and applications begin to lag or shut down.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found