denofevil / import-cost

Displays the import size of the package you are importing inside the IJ platform products
Apache License 2.0
242 stars 8 forks source link

High Cpu usage on jetbrains Ides #49

Open ouedyan opened 1 year ago

ouedyan commented 1 year ago

Please fix high cpu usage when the plugin is enabled. For details please see: https://youtrack.jetbrains.com/issue/WEB-58351/WebStorm-EAP-high-CPU-usage#focus=Comments-27-6724186.0-0

anstarovoyt commented 1 year ago

I will try to reduce a number of thread for the calculation, but unfortunatelly we don't have much control from our side there. Related issue on the library side https://github.com/wix/import-cost/issues/272

JuHwon commented 1 year ago

i also noticed high cpu usage. fans are spinning high and all cores close to 100% when webstorm is opened. disabled plugin and everything was fine.

patric-eberle commented 1 year ago

Same here. I also have increased energy consumption on a PhpStorm > Node progress when checking on macOS Activity monitor. As soon as I disabled this plugin, the values returned to normal. This issue only popped up with PhpStorm 2022.3 and was not an issue with PhpStorm 2022.2.

Webbrother commented 1 year ago

+1

It is REALLY annoying.

Macbook Pro 2019, 2,4 GHz 8‑core Intel Core i9, 32Gb. OS: MacOS Ventura 13.2.1 Webstorm: 2022.3.3 Build #WS-223.8836.27, built on March 1, 2023

It loads CPU on 100%! The notebook becomes hot! If the webstorm is launched, the battery lasts for one hour.

na-ji commented 1 year ago

I will try to reduce a number of thread for the calculation, but unfortunatelly we don't have much control from our side there. Related issue on the library side wix/import-cost#272

This is not an issue with a number of threads, but because the plugin is creating an infinite number of processes at an incredible pace. All those processes are short-lived, less than an instant. In a few seconds, more than 5k processes were created on my machine. It takes less than 2 minutes for the PID of the processes created to reach the maximum PID number of 99999. The issue appeared around the release of Webstorm 2022.3, so around November 28th, 2022. I own a M1 MacBook Pro, and the moment this bug appeared was the first time I ever heard its fans.

Here is a video of all the processes that are created. Notice the PID on the right most column.

https://user-images.githubusercontent.com/757637/226021168-6c48235b-b937-410e-acad-86ff6f7f4807.mov

I can't figure which command those processes are running, since they are dying instantly. But here is the parent process:

node /Users/naji/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/223.8836.35/IntelliJ IDEA.app/Contents/plugins/javascript-impl/jsLanguageServicesImpl/js-language-service.js

I don't have any clue on how to develop an IJ extension, but I believe it might have something to do with this: https://github.com/denofevil/import-cost/blob/92fc91f96801f347f89f3583a53239792cf5a0f4/src/main/kotlin/com/github/denofevil/importCost/ImportCostLanguageService.kt#L65-L68

anstarovoyt commented 1 year ago

@na-ji thank you! Can you share the project which I can use for testing/ Or it works this way for all possible project for you?

na-ji commented 1 year ago

@anstarovoyt No, this doesn't happen for all possible project. It's hard to tell, but I noticed at first it happens really fast on monorepos, but it's not limited to those monorepos. After testing a few projects, my theory is that it happens because of typescript import aliases. I confirmed that the issue is happening on this example for instance: https://github.com/vercel/next.js/tree/canary/examples/with-absolute-imports On this example, it's not hitting the CPU as hard as on a real project, but I still see a noticeable increase and the same node processes that are created really fast.