Template for a good new topic, formatted with Markdown:
- ALM used: Azure DevOps
- CI system used:Azure DevOps (self-hosted agents, 8 cores, dynamic up to 32 GB RAM), Java 25 preinstalled, using build wrapper
- Scanner command used when applicable (private details masked)
- Languages of the repository: C++23 (mainly), C#, Powershell, YAML
- Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
Time for code analysis is much longer than for build.
In log I see##[warning]Free memory is lower than 5%; Currently used:- in all runs - Steps to reproduce
- task: SonarCloudPrepare@4
inputs:
SonarCloud: $(SonarQubeServiceConnection)
organization: $(SonarQubeOrganization)
projectKey: $(projectKey)
extraProperties: |
sonar.exclusions=external/\*\*,source/vcpkg_installed/\*\*
sonar.cs.vscoveragexml.reportsPaths=$(Agent.TempDirectory)/\*\*/\*.xml
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/\*\*/\*.trx
sonar.cfamily.vscoveragexml.reportsPath=$(Agent.TempDirectory)/TestResults/gtest/\*\*/\*.coveragexml
sonar.cfamily.reportingCppStandardOverride=c++23
sonar.cfamily.enableModules=true
sonar.cfamily.threads=6
sonar.cfamily.compile-commands=$(SonarOutDir)/compile_commands.json
sonar.sca.enabled=false
sonar.sca.cfamily=true
sonar.sca.exclusions="source/\*.Tests/\*\*"
sonar.sca.resolveAsRoot=true
sonar.sca.resolveDependencies=true
sonar.sca.resolveDependencySources=false
sonar.architecture.enable=false
- task: PowerShell@2
inputs:
pwsh: true
targetType: inline
script: |
& $vcpkgPath install --triplet x64-windows-v143 `
--overlay-triplets ".\triplets" `
--x-manifest-root ".\" `
--x-install-root ".\vcpkg_installed\x64-windows-v143"
- task: PowerShell@2
inputs:
pwsh: true
targetType: inline
script: |
$vswhere = "${env:ProgramFiles(x86)}\\Microsoft Visual Studio\\Installer\\vswhere.exe"
$msbuild = & $vswhere -latest -requires Microsoft.Component.MSBuild -find MSBuild\\\*\*\\Bin\\MSBuild.exe | select-object -first 1
& $msbuild MySolution.sln /t:restore /nologo
& "$(BuildWrapper)" --out-dir "$(SonarOutDir)" \`
"$msbuild" MySolution.sln \`
/t:Rebuild \`
/m \`
/p:Configuration=$(BuildConfiguration) \`
/nodeReuse:False \`
/nologo
- task: SonarCloudAnalyze@4
inputs:
jdkVersion: 'JAVA_HOME'
env:
SONAR_SCANNER_JAVA_OPTS: "-Xms24G -Xmx24G -XX:+UseG1GC -XX:MaxGCPauseMillis=200"
- Potential workaround
- Tried to increase number of cores (4 to 8, 16 GB):
- Build time dropped 10m 47s → 6m 39s
- Analyze 41 m 4s → 1h 11, 35 increased, limit number of threads to 4: 30m 33s
- Increase memory (8 cores, 16 GB → 32 GB) - nearly no change
- different settings on SONAR_SCANNER_JAVA_OPTS. In system diagnostics the effect on the system diagnostics
Memory: Used 24056.00 MB out of 30749.00 MB,- both numbers increase, the number of messages remain about 17 times.
- Tried to increase number of cores (4 to 8, 16 GB):
For vcpkg binary caching on the build server is used - if this has any effect on the analyze process.
I observe, that the number of cache hits are in general quiet low if any C++ code was changed. In a build I got 44 hits [177/283] Module scan cache hit for - and in this case only one module and 5 test files were changed, analyze run on the same build server.
I would like to get the analyze time to be below the build time. Any recommendation are welcome.