Sonarlint VS Extension performance

We have a very large C++ code base (over a million loc) and when i open a large file (unfortunately we have files with 25k+ loc) VS constantly locks up. Is there a way to disable analysis on large files? Or disable for an entire solution? I don’t want to fully disable the plugin because then i lose it for my other solutions that are more manageable…

Hello @dhettinger - welcome to the community.

No, I’m afraid there isn’t any way of disabling analysis at file or solution level. We’ve added it as a feature suggestion to the product backlog.

The only short-term hacking workaround I can think of is to turn off all of the rules locally when working with that particular solution. Turning them off individually isn’t practical, but you could do so by replacing your %appdata%\SonarLint for Visual Studio\settings.json file with this one: settings.json (61.1 KB)
This will only work if you are using standalone mode, and will be tedious if you are frequently switching between solutions you want to analyse and solutions you don’t.

We’d also like to understand what is causing the performance issue, and would be grateful for any more information you could give us about the symptoms.

To give some background, the actual C++ analysis is performed in a separate process called subprocess.exe. The only work done in VS itself is triggering the analysis, rendering the results in the Error List, and adding squigglies/tags to the editor pane.
The issue might be in VS, the background process, or both.

Some specific questions:

  1. Obvious question first: does VS lock up if SonarLint is not installed? (I’m assuming yes)

  2. What does “locks up” mean? Does the UI freeze temporarily, or permanently, or just become very slow? Does VS show a gold bar complaining about SonarLint making the IDE unresponsive?

  3. When does the lockup occur - when opening a very large file, typing, saving, changing tabs?

  4. Does SonarLint ever manage to successfully analyse any of the very large files? If so, roughly how many issues does it report, and how long does the analysis take? The SonarLint pane in the Output window will have a message like the following:

Finished analyzing D:\MyProject\foo.cpp, analysis time: 0.227s
  1. What does the CPU usage for VS and subprocess.exe look like? i.e. are either/both very high for an extended period?

Answers to any of the above would be very helpful. Thank you.

Thank you so much for the quick and informative response!!

  1. I am disabling the extension when i’m working in our monolithic C++ app, after i do this and restart VS, there is never a pause in VS, everything is instantaneous and smooth and VS does not lock up so i have narrowed it down to the Sonarlint extension causing the lock ups.
  2. Lock up means i start scrolling then the UI thread is completely blocked… 10 seconds later i get a VS has stopped responding window, then i either wait 30s+ or kill it. Sometimes it does this 5 times before finally settling in on the file i’ve got sometimes it only happens a couple times, sometimes it doesn’t happen at all.
  3. This one is a bit tricky, thinking back i think i was able to work in VS for a good hour or two before i noticed it but now that it’s happening it doesn’t seem to matter if i open a fresh instance of VS or not. It seems to happen when i switch tabs… i’m wondering if the more tabs i get open ends up reaching some limit that it then has to wait on something. But yes a lot of our files are very large (10k plus lines). It happens when i’m typing, or even just scrolling, haven’t noticed it on save.
  4. This i actually don’t know, i don’t remember seeing any more squiggles than what VS has so i don’t think so. I can try again and look at the output pane, i didn’t know that was there!
  5. I know i checked CPU and memory for VS and it was very reasonable (like 1.8gb ram and 30-40% CPU for the main process, i’m assuming the subprocess.exe is nested under that?)

I just re-enabled it, i haven’t really made any code changes (testing a feature i wrote right now) but here’s preliminary output. I will keep this running and check the logs the next time it locks up to see if there are any goodies to be had in there. Some of these larger classes (LB2View is split across 7 files and each file is about 20k long so that’s over 100k, and it does a lot of UI MFC thread stuff) never finish but others do.

Current VS version:
    Visual Studio Enterprise 2022
    17.0.31919.166
    17.0.2
Loaded settings from "C:\Users\dhettinger\AppData\Roaming\SonarLint for Visual Studio\settings.json".
Calculating effective rule settings...
No custom rules settings - using defaults
Note: the following CFamily rules are not available in SonarLint: cpp:S5536, c:S5536, cpp:S4830, c:S4830, cpp:S5527, c:S5527, cpp:S5801, c:S5801, cpp:S5814, c:S5814, cpp:S5815, c:S5815, cpp:S5816, c:S5816, cpp:S5824, c:S5824, cpp:S2612, c:S2612, cpp:S5802, c:S5802, cpp:S5849, c:S5849, cpp:S5982, c:S5982, cpp:S5813, c:S5813, cpp:S5332, c:S5332, cpp:S2068, c:S2068, cpp:S2245, c:S2245, cpp:S5443, c:S5443, cpp:S5042, c:S5042, cpp:S4790, c:S4790, cpp:S1313, c:S1313, cpp:S6069, c:S6069
Analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp
Finished analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp, analysis time: 10.915s
Found 550 issue(s) for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp
Initializing the telemetry package...
Finished initializing the telemetry package...
Initializing the SonarLint package...
Standalone mode detected.
Finishing initializing the SonarLint package
Initializing the notifications package...
Not connected: not checking for notifications
Finished initializing the notifications package
Initializing the daemon package...
Finished initializing the daemon package.
[Open in IDE] Creating request listener...
[Open in IDE] Checking availability of port 64120
[Open in IDE] Request listener created successfully. Listening on port 64120.
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Saving notifications settings...
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Using cached rule settings
Analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGRunMgt\QGMgrBoRunConcrete3.cpp
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGRunMgt\QGMgrBoRunConcrete3.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Using cached rule settings
Analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGTskLnkMgt\QGMgrBoTskLnkConcrete.cpp
Execution cancelled.
Using cached rule settings
Analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGTskMgt\QGMgrBoTaskConcrete.cpp
Finished analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGTskLnkMgt\QGMgrBoTskLnkConcrete.cpp, analysis time: 3.301s
Found 181 issue(s) for C:\WIP\App\Loadboard2\LB\BusLogic\QGTskLnkMgt\QGMgrBoTskLnkConcrete.cpp
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGTskMgt\QGMgrBoTaskConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Finished analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGTskMgt\QGMgrBoTaskConcrete.cpp, analysis time: 5.583s
Found 384 issue(s) for C:\WIP\App\Loadboard2\LB\BusLogic\QGTskMgt\QGMgrBoTaskConcrete.cpp
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGTskMgt\QGMgrBoTaskConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Execution cancelled.
Execution cancelled.
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGRunMgt\QGMgrBoRunConcrete3.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Execution cancelled.
Execution cancelled.
Execution cancelled.
Using cached rule settings
Analyzing C:\WIP\App\Loadboard2\LB\UserInterface\LB2\LB2View.cpp
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\UserInterface\LB2\LB2View.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Execution cancelled.

Ok, tagging on, VS locked up while i was modifying QGMgrApplyInstrConcrete.cpp for about 10 seconds, here’s output from that (tagging on from above):

Refreshing PCH file for C:\WIP\App\Loadboard2\LB\UserInterface\LB2\LB2View.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Execution cancelled.
Execution cancelled.
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Execution cancelled.
Execution cancelled.
Using cached rule settings
Analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrWrkQueConcrete.cpp
Execution cancelled.
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrWrkQueConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Execution cancelled.
Execution cancelled.
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Saving notifications settings...
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Execution cancelled.
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Using cached rule settings
Analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp
Finished analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp, analysis time: 47.475s
Found 672 issue(s) for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp

Sorry for the onslaught of responses, but i still have it enabled and it’s constantly freezing as i navigate around, i tried (close all tabs but this) to see if that would help but it hasn’t. Just navigating within the same file. I should say i am in the process of making changes so it doesn’t compile right now (changing method definition) but i’m not sure if that is always always the case when it locks up.

Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Using cached rule settings
Analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp
Execution cancelled.
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Execution cancelled.
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Execution cancelled.
Aborted analysis of C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp, analysis has been re-triggered or has timed-out.
Using cached rule settings
Analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp
Execution cancelled.
Execution cancelled.
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Execution cancelled.
Aborted analysis of C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp, analysis has been re-triggered or has timed-out.
Using cached rule settings
Analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp
Execution cancelled.
Execution cancelled.
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Execution cancelled.
Execution cancelled.
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Execution cancelled.
Execution cancelled.
Refreshing PCH file for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp. PCH file location: C:\Users\dhettinger\AppData\Local\Temp\SonarLintForVisualStudio.PCH.preamble
Finished analyzing C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp, analysis time: 53.2s
Found 672 issue(s) for C:\WIP\App\Loadboard2\LB\BusLogic\QGWrQMgt\QGMgrApplyInstrConcrete.cpp

Many thanks for the additional data @dhettinger. It suggests a couple of areas for us to focus on when trying to repro the issue, and it also rules a few things out.

Yes, subprocess.exe will appear under the main VS process in the Task Manager.

FYI Each instance of the process relates to the analysis of a particular file. The process runs, streams issues back to VS, then terminates. It’s possible in some cases to have multiple instance running at once, although triggering a new analysis for file A will kill any in-progress analysis that is analysing the same file.
Finally, an pre-analysis step will be triggered each time to switch to a new code tab in the editor. This also calls subprocess.exe, but it doesn’t do a full analysis. Rather, it does some pre-processing related to pre-compiled headers (that’s what all of those Refreshing PCH file messages in the log are about).

Ok, i’m not sure if this helps or confuses things more but when it locks up it looks like all the sub processes drop to 0% CPU.

I will also add, it definitely does this with much lower memory utilization, and also this is a corporate laptop that uses Cisco AMP as an antivirus which i believe scans files at the root level before it writes to disk and we have seen that cause slowness before (although everything VS related is supposed to be an exception). I wish i could disable it to rule that out but it’s password protected and they don’t allow us to disable it.

Also, just to further add (since i don’t think it’s obvious in my original post) i believe this has always behaved this way (even in VS 2019), i was just really excited to use sonarlint more with 2022 since it’s 64bit and performance has been way better for me across the board

We do write input/output files as part of the analysis and they are not in a VS folder so they probably will be being checked by the anti-virus software. It doesn’t seem to be causing an issue when analysis “normal” size code files, though, although it could be that the size of the generated file is a factor.

I think you’re probably right; the performance characteristics of VS2022 are completely different, so issues that were there before are now more visible.

FYI I’ve created a ticket to track this issue: SLVS#2798. We adding some ETW tracing specifically around the C++ analysis to help us work out exactly what is going on.

1 Like

Do you know the path these files are written to? If so i can put in a request to my IT department to have that folder excluded from scanning to see if that’s the culprit.

The files are all written directly to the %temp% folder, unfortunately.

The file names all start with SonarLintForVisualStudio.PCH.preamble

e.g. %temp%\SonarLintForVisualStudio.PCH.preamble
%temp%\SonarLintForVisualStudio.PCH.preamble.pch
%temp%\SonarLintForVisualStudio.PCH.preamble.pch-xxx.tmp

FYI we’ve managed to repro the issue locally, so we’ll be able to investigate the cause of the delay.
Many thanks for reporting the issue and for helping narrow down the scope of the problem.

That is great news! Thanks for the awesome support! And I believe their exclusion policies allow for wild cards and env variables so i asked that they exclude files that match that naming convention.

1 Like