SonarCFamily cache does not reduce Scan time

For the incremental feature, I have enabled it and set:


I have copied the .sonarqube directory content to D:\sonarcache - i’ve also added it to a git repo, incase the incremental sonar run changes anything in the cache directory.

the directory content looks like:

i’m now using this cache on another branch using the following command:
SonarScanner.MSBuild.exe begin / /d:sonar.cfamily.threads=8 /d:sonar.sourceEncoding=UTF-8 /d:sonar.cfamily.cache.enabled=true /d:sonar.cfamily.cache.path=D:\sonarcache /k:xxxxxxxx /n:xxxxxxxx /d:sonar.pullrequest.branch=xxxxxxxx
/d:sonar.pullrequest.key=2058 / /d:sonar.login=********

in the cache directory I see a directory being created: analysis_state with 257 Files

But the Scan time is not drastically reduced

I have tried different cache folder
the root of the previous run .sonarqube
and .sonarqube\out folder
but I don’t see a difference.

Now I have to say… 99% of the code is C#…
hmmmm :slight_smile: let me try this also on a code base with allot of C++ code

am I on the right track here?

Kind regards,

The cache will help speed up analyzing C/C++/Obj-C code, nothing else.

1 Like

the question I have is to put the files there beofore or after the Sonarscanner end of the master run?

What am I doing wrong:

12-Mar-2020 19:10:42 INFO: Cache: 0/742 hits, 188020758 bytes


Hi @Ed_Die,

did you manage to properly setup your project with cache?

@mpaladin No :frowning: i’m trying ccache now

any guidance you can give me would very much be appreciated

Hi @Ed_Die,

could you please explain the current state of things?

Hi @mpaladin

when using the cache I assume the sonar.cfamily.cache.path location is something that points to a directory with the cache, but what is the cache… I assume, it is the content from the .sonarqube directory from a previous run on the same code base. what I didn’t do is copy the .sonarqube directory after the SonarScanner.MSBuild.exe end but I copied the file after the build was finished… maybe I shouldn’t have done this?

Kind regards,

Hi @Ed_Die,

No, they are two distinct folders. sonar.cfamily.cache.path is used only by the C/C++/Objective-C analyzer.

Hi @mpaladin,

when I say, use the .sonarqube directory from a previous run I mean, the content of the .sonarqube would be copied to another directory, for example D:\sonarcache and sonar.cfamily.cache.path point to that directory

Hi @Ed_Die,

I have some troubles following you, it seems like you are complicating things. Could you please try the following locally and confirm you get a good 100% cache hit?

  1. Build your project with build-wrapper
  2. Analyze the project with sonar.cfamily.cache.enabled=true and sonar.cfamily.cache.path=.sonarcfamily
  3. Reanalyze the project with sonar.cfamily.cache.enabled=true and sonar.cfamily.cache.path=.sonarcfamily and do nothing between step 2 and 3
1 Like