Timeout issue with SonarLint

Hi there,

I have been trying to analyse our C++ source in a large Visual Studio project using the SonarLint extension. However when the analysis runs on Save etc, it fails with the following output

Analyzing C:\devel\my-project\src\Base62Encoding.cpp
WARNING: Timed out after waiting 10000 ms for process C:\USERS\SANTHONISZ\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\16.0_5F098674\EXTENSIONS\BLGS5O1F.XNL\lib\subprocess.exe to complete: it has been terminated, but its child processes may still be running.

It happens every time, both in VS2017 and VS2019, and with the 4.12 and 4.13 versions of the SonarLint extension.

If I create a new simple ā€œConsole Appā€ project the analysis is working as expected.

How would I go about diagnosing why this is timing-out on the large project - is it simply because it would take longer than the hard-coded 10 second timeout limit?

Thanks,

Sam

Hello @santhonisz,

The size of the project itself is not a big issue for sonarlint :sonarlint:, since the analysis is performed file by file. So to understand the issue, we need to have better information about Base62Encoding.cpp. If you put just this file in the basic console application, do you have the same issue? If so, can you provide us with this project, so that we can try to reproduce this issue?

Do you work with recent&powerful hardware? How long does it take for the file to compile on your environment?

Is the file containing tricky code, such as template metaprogramming or advanced use of constexpr which could make it inherently slow to process?

Thank you,

LoĆÆc

1 Like

Thanks for your reply LoĆÆc,

I’ve done a bit more troubleshooting and it seems to be that the cause of the timeout is the amount of time it takes to parse the headers included via our pre-compiled header file i.e. stdafx.h. There doesn’t seem to be any single header file that is causing the timeout, rather it is just the sheer volume of header files that need to be processed. Our projects typically leverage pre-compiled headers extensively, and they are very large due to the complex dependency tree’s of our projects (potentially up to 100 projects).

Do you have any ideas and/or suggestions as to how SonarLint can be used in such a case. Refactoring our code obviously isn’t an option, but the overhead of having to re-analyze the stdafx.h every time a cpp file that uses it is saved just wont work in the context of the 10 second timeout.

Thanks,

Sam

1 Like

Hello @santhonisz,

Unfortunately, I don’t see anything that can be done from your side, apart from the refactoring you mentioned, which would be a large effort.

I’m looking what can be done on our side. I’ll come back to you when I’ve been able to synchronize with some colleagues.

Thank you,

LoĆÆc

Hello @santhonisz,

The next version of SonarLint will contain an option to tune the value of the timeout for testing purposes. I’ll keep you informed so that you can try it and see if a larger value can solve your issue.

Thank you,

LoĆÆc

Thanks for the update LoĆÆc - sorry for my late reply, I’ve been on leave the last few weeks.

I look forward to being able to test out the change.

Cheers,

Sam

Hi @santhonisz.

No problem - hope you had a good break.

FYI SLVS v4.14 was released a few days ago and supports the environment variable SONAR_CFAMILY_TIMEOUT_MS that you can set for testing purposes. The environment variable should be set before starting VS. Let us know how you get on.

Cheers,
Duncan

Hi Duncan,

Thanks for the update. I tried v4.14 and set the environment variable, but it was still timing out after 10 seconds. I then had a quick look at the source and discovered you had renamed the environment variable to SONAR_INTERNAL_CFAMILY_ANALYSIS_TIMEOUT_MS (https://github.com/SonarSource/sonarlint-visualstudio/commit/9febe92e6f2090e8abbeee4bb660795f3cdc6a1e). I used that instead and the analysis is now working perfectly! Ironically the file that I reported the original issue on takes about 12 seconds to analyse, so it didn’t need much more time to complete.

Thank you both for your efforts!

Cheers,

Sam

1 Like

Hi @santhonisz, just a heads up – we’ve just released SLVS 4.23 and we’ve renamed the environment variable. However, we’ve also increased the timeout to 60 seconds and done performance improvements to the analyzer, so the settings this environment variable should not be needed.