nx-console icon indicating copy to clipboard operation
nx-console copied to clipboard

[WebStorm/IntelliJ] Nx console plugin causes high CPU load

Open FrancescoBorzi opened this issue 1 year ago • 23 comments

Current Behavior

  • When the plugin is active, it often spawns a "node" process which will consume a lot of CPU.
  • It seems one "node" process will be spawned per project
  • It happens both on Webstorm and Intellij
  • Even after you close the IDE, the node process will keep running until you either force-quit it or restart the machine

Expected Behavior

This should not happen

Steps to Reproduce

  • Use WebStorm 2023.3.4
  • Install Nx Console 1.18.0 and enable the plugin
  • Observe the high CPU load caused by some node process
  • Not sure if this makes a difference, probably not, but I tried on several Angular-based projects

Failure Logs / Images / Videos

No logs available

Environment

  • macOS 13.6.3
  • Nx Console version: 1.18.0
  • WebStorm version: 2023.3.4
  • (also tried on IntelliJ)

FrancescoBorzi avatar Feb 24 '24 11:02 FrancescoBorzi

The node process is the nxls which is needed to provide information about nx. It should shut down correctly though, so that's definitely a bug.

MaxKless avatar Feb 26 '24 11:02 MaxKless

I have the same thing on Intellij Idea 2023.3.4 / nx-console 1.19 / MacOS 13.6.4 / Node 18

fgloppe-cedreo avatar Mar 04 '24 16:03 fgloppe-cedreo

Same here. MacOS 14.3.1, WebStorm 2023.3.4, nx-console 1.19 Webstorm will consume 1000% cpu.

oh, i just wanted to reproduce it (by activating the plugin), and for kicks i tried the 'File' > 'Repair IDE', clicked trough the steps, and lo and behold. My machine behaves (again)!

stefanlivens avatar Mar 15 '24 12:03 stefanlivens

I spoke too soon: the spike is back

%CPU Subsystem

419.8 <Process total CPU usage> 311.5 <unidentified: DefaultDispatcher-worker->

Basicly it is impossible to work with the plugin active

stefanlivens avatar Mar 15 '24 13:03 stefanlivens

some fixes for disposing and coroutine mgmt will come with the next release. would be great if you could lmk if that will improve things.

MaxKless avatar Mar 15 '24 14:03 MaxKless

Hey! Can you check out idea.log and paste the contents here? I have a hunch that this is because something is wrong with file watching in IntelliJ and more files than needed are being picked up. Would be great if you could provide more info.

MaxKless avatar Mar 20 '24 12:03 MaxKless

Off course, when i started to prepare to get this log ready by cleaning out the logs, I can't reproduce it anymore. Also installed the latest version (1.20.0) and the issue is (not) there anymore. Or at least a lot less.

stefanlivens avatar Mar 29 '24 13:03 stefanlivens

Hey! I think this definitely has something to do with file watching in Nx Console. Please check the idea.log contents and be sure to insert #dev.nx.console:trace under Help > Diagnostic Tools > Debug Log Settings. Are you using yarn pnp by any chance, @FrancescoBorzi @stefanlivens

MaxKless avatar Apr 02 '24 09:04 MaxKless

Are you using yarn pnp by any chance, @FrancescoBorzi @stefanlivens

No, I'm not

FrancescoBorzi avatar Apr 10 '24 09:04 FrancescoBorzi

Okay that's good to know, thanks. Any chance you could provide those logs?

MaxKless avatar Apr 10 '24 10:04 MaxKless

I've got issues with node process CPU sage after closing PyCharm 2024.1. Everything works well before I close the PyCharm. After closing the node process doesn't stop and use 150% of CPU.

M1Pro Macbook

polyakov84 avatar Apr 23 '24 16:04 polyakov84

@FrancescoBorzi @polyakov84 If you run ps aux | grep node | grep -v grep | grep -e nxls -e daemon what output do you see?

jaysoo avatar Apr 30 '24 17:04 jaysoo

@jaysoo It takes 143% of CPU and will not exit until I kill it.

Screenshot 2024-05-01 at 08 42 55

polyakov84 avatar May 01 '24 05:05 polyakov84

@polyakov84 When you kill it, did kill work, or did you have to use kill -9? I've seen the nxls process hanging before, trying to reproduce it so we can fix.

jaysoo avatar May 01 '24 17:05 jaysoo

@jaysoo kill doesn't kill the process. The process still presents, and it increases CPU usage to 215%.

kill -9 kills process, and there are no node processes after that.

polyakov84 avatar May 01 '24 17:05 polyakov84

@jaysoo kill doesn't kill the process. The process still presents, and it increases CPU usage to 215%.

kill -9 kills process, and there are no node processes after that.

Thank you, that is consistent with what I observe as well. We'll fix this.

jaysoo avatar May 01 '24 18:05 jaysoo

If someone can link a gist of their IDEA log, that could help track down the problem.

Screenshot 2024-05-01 at 3 51 06 PM

jaysoo avatar May 01 '24 19:05 jaysoo

@jaysoo I don't have this menu item in PyCharm Pro. I also checked in other menus.

polyakov84 avatar May 01 '24 20:05 polyakov84

@polyakov84 On MacOS, it'd be at ~/Library/Logs/JetBrains under your IDE folder. For example, for me it is ~/Library/Logs/JetBrains/IntelliJIdea2024.1/idea.log.

For other OS, refer to this guide: https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files

jaysoo avatar May 01 '24 20:05 jaysoo

@jaysoo idea.log_sanitized.zip

polyakov84 avatar May 01 '24 20:05 polyakov84

@jaysoo Here is an additional log tail from closing PyCharm moment. Maybe it will be helpful.

`2024-05-01 23:46:40,610 [2604912] INFO - #c.i.o.w.i.WindowManagerImpl - === Release(true) frame on closed project === 2024-05-01 23:46:40,616 [2604918] INFO - #dev.nx.console.nxls.NxlsWrapper - Stopping nxls 2024-05-01 23:46:40,616 [2604918] FINER - #dev.nx.console.nxls.NxlsWrapper - Sending request to nxls: shutdown (null) 2024-05-01 23:46:40,619 [2604921] INFO - #dev.nx.console.nxls.client.NxlsLanguageClient - [Nxls] - 2024-05-01T20:46:40.618Z - Unregistering file watcher

2024-05-01 23:46:40,625 [2604927] INFO - #zielu.gittoolbox.blame.cache.xodus - Deleted 0 expired files 2024-05-01 23:46:40,626 [2604928] INFO - #zielu.gittoolbox.blame.cache.xodus - Deleted 0 expired revisions 2024-05-01 23:46:40,629 [2604931] FINER - #dev.nx.console.nxls.NxlsWrapper - Error from nxls: Request shutdown failed with message: Connection is disposed. 2024-05-01 23:46:40,662 [2604964] INFO - #c.i.u.s.SvgCacheManager - SVG icon cache is closed 2024-05-01 23:46:40,667 [2604969] INFO - #c.i.o.v.i.l.NativeFileWatcherImpl - Watcher terminated with exit code 0 2024-05-01 23:46:40,671 [2604973] INFO - #o.j.i.BuiltInServer - web server stopped 2024-05-01 23:46:40,680 [2604982] INFO - #c.i.u.i.FileBasedIndexImpl - Index dispose started 2024-05-01 23:46:40,717 [2605019] INFO - #c.i.p.s.StubIndexImpl - StubIndexExtension-s were unloaded 2024-05-01 23:46:40,717 [2605019] INFO - #c.i.p.s.SerializationManagerImpl - Start shutting down /Users/.../Library/Caches/JetBrains/PyCharm2024.1/index/rep.names 2024-05-01 23:46:40,718 [2605020] INFO - #c.i.p.s.SerializationManagerImpl - Finished shutting down /Users/.../Library/Caches/JetBrains/PyCharm2024.1/index/rep.names 2024-05-01 23:46:40,719 [2605021] INFO - #c.i.u.i.FileBasedIndexImpl - Index dispose completed in 39ms. 2024-05-01 23:46:40,726 [2605028] INFO - #c.i.o.v.n.p.PersistentFSImpl - VFS dispose started 2024-05-01 23:46:40,728 [2605030] INFO - #c.i.o.v.n.p.FSRecordsImpl - VFS closing 2024-05-01 23:46:40,729 [2605031] INFO - #c.i.o.v.n.p.PersistentFSImpl - VFS dispose completed in 2 ms. 2024-05-01 23:46:40,731 [2605033] INFO - #c.i.o.f.i.FileTypeDetectionService - 21 auto-detected files. Detection took 55 ms 2024-05-01 23:46:40,739 [2605041] INFO - #c.i.p.i.b.AppStarter - ------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------`

polyakov84 avatar May 01 '24 20:05 polyakov84

Hey! I just released a new version of IntelliJ for JetBrains, you should see it already. Can you check whether the issue still persists? We now have an additional check to kill the nxls process if it doesn't shut down by itself after 2 seconds :)

MaxKless avatar May 02 '24 10:05 MaxKless

@MaxKless It's fixed and works well in my case. Thanks.

polyakov84 avatar May 02 '24 10:05 polyakov84

That's great to hear! I'm closing this issue as resolved. If you still run into this problem, please let me know and I'll have another look.

MaxKless avatar May 06 '24 10:05 MaxKless