Analyzing typescript files takes a long time

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    CLI: sonar-scanner-cli-4.4.0.2170
    NPM: sonarqube-scanner: 2.7.0
    Sonar Server: 7.9.1
  • what are you trying to achieve
    Faster analyzing of typescript files
  • what have you tried so far to achieve this
    Tried everything from this thread Sonar Scanner is really slow scanning typescript

We are noticing it take ~7secs to scan 50 files. This occurs during the sonarTS sensor analyzing. We have over 15000 files and the analyzing is taking around 22mins.

Hi @feldmanz66 ,

Welcome to SonarSource Community! :sonarsource:

You are using SonarQube 7.9, which is our LTS version, but it uses an old SonarJS/SonarTS plugin. Please download SonarQube 8.7 and try your analysis with this version.

Also, what version of Node are you using? Update to at least Node 14 and make sure there is no antivirus software scanning your project folder.

Lastly, see Troubleshooting section on slow analysis. You can try adjusting sonar.javascript.node.maxspace to 4096 or 8192, corresponding to 4GB and 8GB, respectively.

If it fails or is too slow, please attach Sonar scanner logs with -X for debug level.

Joe

Hi @Joe it’s great to be in the Sonar Community!

Currently we are on enterprise Sonar and upgrading is not something we can easily do. I did follow this 2-minute-guide from Sonar to test our repo in an 8.7 Sonar container. I did not see a performance enhancement on sonar analyzing the 8k typescript files.

We are on node 14.x and running it on a Jenkins agent without any antivirus. We also added 8192 maxspace. Do you know if the size of repo has any performance impact on the analyzing. Testing it on a very small repo it was quite fast analyzing in fact.

Thanks in advance!
Zach

1 Like

Hi @feldmanz66 !

Yea, I understand, upgrading isn’t so easy for some organizations. You mentioned 15000 files earlier but now 8k files. Are these 2 different repositories? Can you attach sonar-scanner debug logs for either of these runs?

If it isn’t too much trouble, can you try upgrading to Node 15 and try running it again with the maxspace setting 8192? Make sure Jenkins isn’t being bogged down by other processes and there’s enough file space on the server. I don’t have any performance statistics to offer, there are too many factors to consider (OS, hardware specs, # of files, complexity of code, number of rules in your quality profile, etc.).

Another idea is to make sure you optimize your tsconfig.json’s includes/excludes parameters. This can help reduce excessive time in files/folders you don’t care to scan, aside from the sonar.exclusions parameter.

Attaching debug scanner logs might give us more insight so please attach it when you can.

Joe