Orphaned processes and high CPU utilization with VS code and SonarLint extension

Please provide

  • Operating system: macOS Monterey 12.2
  • IDE name and flavor/env: VSCode Version: 1.65.2 (Universal)
  • SonarLint plugin version: 3.3.3
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): Connected to sonarlint.connectedMode.connections.sonarcloud hosted on https://sonarcloud.io/ (not sure where I can get a version on that)

And a thorough description of the problem / question:
My team is having some different issues and we have been unable to diagnose. All of us are using Mac machines (MacBook Pro) and we are seeing issues on both Big Sur as well as Monterey.

The problem I have is orphaned java processes. Example output from “ps”:

  UID   PID  PPID   C STIME   TTY           TIME CMD
  501  2796     1   0 10Mar22 ??         4:39.17 /usr/local/Cellar/openjdk/17.0.2/libexec/openjdk.jdk/Contents/Home/bin/java -jar /Users/andrew/.vscode/extensions/sonarsource.sonarlint-vscode-3.3.3/server/sonarlint-ls.jar 49440 -analyzers /Users/andrew/.vscode/extensions/sonarsource.sonarlint-vscode-3.3.3/analyzers/sonarjava.jar /Users/andrew/.vscode/extensions/sonarsource.sonarlint-vscode-3.3.3/analyzers/sonarjs.jar /Users/andrew/.vscode/extensions/sonarsource.sonarlint-vscode-3.3.3/analyzers/sonarphp.jar /Users/andrew/.vscode/extensions/sonarsource.sonarlint-vscode-3.3.3/analyzers/sonarpython.jar /Users/andrew/.vscode/extensions/sonarsource.sonarlint-vscode-3.3.3/analyzers/sonarhtml.jar /Users/andrew/.vscode/extensions/sonarsource.sonarlint-vscode-3.3.3/analyzers/sonarxml.jar -extraAnalyzers /Users/andrew/.vscode/extensions/sonarsource.sonarlint-vscode-3.3.3/analyzers/sonarsecrets.jar

In my case, sometime while working (and I do close the lid of my laptop and bring it home at night, so I do run VS code over multiple days), I will check my running java processes and find that I have more sonar java processes than open VS code windows. Only way to fix them is to reboot or just run pkill -9 java to terminate them.

If I just open & close VS code windows, they do seem to close, so it seems like more of an issue with running code over time. For example, I just checked and I had 6 sonar java processes running for just 3 vs code windows. After force quitting (pkill) those processes, 3 restarted (the number expected). So somehow 3 processes were running that should not have been running.

At least 3 of my coworkers have a worse problem in that sometimes their sonar processes spike their CPUs to 100% and severely impact their performance. All 3 have resorted to disabling sonar on their IDEs as they just got frustrated.

I have tried to compare my computer to theirs but have found no discrepancies with settings or environments that would figure out why theirs does this but mine does not.

Sorry to be light in details, but this is definitely affecting our ability to use the extension.

One of my coworkers had his process immediately go to 200% - 300% CPU after re-enabling his extension (he is using a JDK 11 as his java home).

SonarOutput.txt (7.2 KB)

Here is the sonar output from his VS code window with the process running high

Also here is the process explorer:

Note that he tried Java 17 and just now he said it seems better, but another one of my coworkers with the issue said Java 17 did not help

Hi @arobinson

First of all, thanks for taking the time to report the issue(s).

There are two (likely) separate issues:

  1. Orphaned Java processes (sonarlint-ls.jar). We are aware of the issue, and even experiencing it randomly on our side. Here is the ticket I just created to allow you to follow the resolution if you like: [SLVSCODE-261] Orphaned language server processes - SonarSource. This is high priority on our side, and since we can reproduce, we should be able to fix it.

  2. High CPU usage. This one is more tricky for us to investigate without at least a thread dump. That’s where we need your help, especially if you have a setup where you can reproduce consistently. Please see the different methods to collect a thread dump, and when the CPU spikes, trigger a dump and share the output with us.

Thanks

1 Like

Thank you, I’ve requested the developers that have this issue to try to get a thread dump, I’ll reply back when we can get one

Here is a stack dump of a runaway process (1100% CPU utilization in this case)
threaddump.txt (78.5 KB)

Here is another dump from a different user
threaddump (1).txt (59.7 KB)

Hello Andrew,

Thanks for those dumps, I already identified a problem on our side. A couple of questions:

  • are you all trying to open the same project in VSCode ?
  • are you opening a single folder or a workspace containing several folders ?
  • are you working on a big Git repository ? For example with a lot of history.

Thanks

Update: we recently changed the section of code that seems to be causing this CPU problem, could you give a try with this artifact please ? You can find how to install it here.

Sorry, didn’t get to my email last few days. Just let my co-workers know and will report back. Thank you so much for the quick attention.

Hey,
I have the same issue (both of them, actually) and this new artifacts really does help in my case.
As soon as I switch to latest stable version, issue re-appars. I just have to rapidly switch between files and java process would basically explode. This does not happen with provided version of extension

FYI, I have a workspace with several folders (~10), each having their own SQ config and git repo (with git history ranging from 5 to 70k commits).

One of my co-workers that had the problem said it went away with the downloaded version.

Hello there,

We just released a new version of SonarLint for VSCode on the Marketplace, that contains a lot of fixes for issues raised on this thread. We would be happy if some of you could install it and give us some feedback.

Thanks again for reporting and helping us improve the product!

A post was split to a new topic: Over 100% cpu usage on any changes