The analysis step takes approximately 35 minutes for a 38K lines TypeScript codebase in the ADO

  • ALM used: Azure DevOps
  • CI system: used Azure DevOps
  • Scanner command used when applicable:
- task: SonarCloudAnalyze@1
    condition: ${{ parameters.enableSonarCloud }}
  • Languages of the repository: TypeScript

We are struggling with the extensive analysis time for PR, which usually takes approximately 35 minutes for a 38k lines codebase.

Is this time frame typical for projects of this kind?
If not, what can we do to speed it up? Would it be helpful to post information about good practices for speeding up the analysis step, either here or somewhere else? I have a feeling that this topic arises from time to time, but the answers provided do not seem to be applicable to other projects.

Hi,

Welcome to the community!

Have you analyzed the main branch? I would expect only the changed files to be analyzed in a PR and the rest of the data analysis needs to be filled in from cached data from the main branch? If you have analyzed main (or the reference branch, altho to be clear I’m not sure on that point) then this could be a problem with the detection of new code.

Could you share your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Ann

Hello @ganncamp
thank you for your response!

We have turned on the Sensor cache functionality, so I believe that only changed files should be analyzed. What’s worse, even when we have only one file changed, we have to wait at least 15 minutes.
image

In the case of logs, I have to check, but most probably it will not be possible due to sensitive data.

Hi,

We can’t go much further without logs. Feel free to redact them as necessary.

 
Ann

Hello @ganncamp

I’ve received approval to share sanitized logs!

In the meantime, I’ve made a change to the configuration - the analysis scope has been modified for development and test files, based on this → Analysis Scope | SonarCloud Docs. This has reduced the analysis time (it’s currently around 16-18 minutes for PR), but there might still be a chance to make it even faster.

I would appreciate any help in speeding this up :slight_smile:
sonarlogs (1).txt (157.7 KB)

Hi,

Thanks for the log. I see this far more often than I would expect:

1/1192 file analyzed, current file:

I suppose
a) you redacted the file name
b) it’s the same in all cases
?

I’m going to refer this to more expert eyes, but they’ll probably need to see that file. Will you be able to share it privately?

 
Ann

Hi @ganncamp

Yes I redacted, all file name was deleted. Yes I will send you, tell me how :slight_smile:

Szymon

1 Like

Hello Szymon,

I will write to you a private message so you can send me a link for the file.

I noticed that you have a huge amount of tsconfig.json files in your project. This is indeed costly for the TypeScript parser.
Also, we perform quite a lot of storage IO. What is the disk type that you use?

Best,
Ilia

Thank you @ilia

I will find good example of logs and I will send you

Regarding tsconfig.json we use NX workspaces so for each lib we have separate tsconfig.json. As I understand reducing amount of libs can reduce sonar analyze time as well?

Disk type I have to check and I will back to you :slight_smile:
Thank you for your support so far!

Szymon

Hello @Szymon_Pawlak,

Seems some users with a similar issue fixed this by setting sonar.typescript.tsconfigPaths with the root tsconfig.json of the project. Can you please check if that helps in your case also?

Cheers,
Victor