Skip to content

Use `ccache` to speed-up C-based compilation

Kamil Trzciński (Back 2025-01-01) requested to merge use-ccache into master

Bundler and Gitaly depend on handful of C-based code. Today this is recompiled each time. The ccache offers big performance gains for full wipe and recompile, but also incremental changes.

1. Gitaly tests

$ cd ~/gitlab/tmp/tests/gitaly

# Completely fresh everything (except bundler)
$ git clean -fdx
$ rm -rf _build
$ ccache -C
$ time make all git
real	1m32.061s
user	3m26.404s
sys	0m51.797s

# Second run (cache hot)
$ git clean -fdx
$ rm -rf _build
$ time make all git
real	0m43.782s
user	0m58.831s
sys	0m19.796s

2. GitLab bundler reinstall

cd ~/gitlab

# Completely fresh everything (except bundler)
$ rm -rf /data/cache/bundle-2.7.*
$ ccache -C
$ time bundle install
real	7m9.852s
user	5m11.328s
sys	1m11.777s

# Second run (cache hot)
$ rm -rf /data/cache/bundle-2.7.*
$ time bundle install
real	3m23.932s
user	1m52.868s
sys	0m39.968s

3. Ccache stats

$ ccache -s

cache directory                     /data/cache/ccache
primary config                      /data/cache/ccache/ccache.conf
secondary config      (readonly)    /etc/ccache.conf
stats updated                       Tue Oct 26 14:10:33 2021
cache hit (direct)                  4028
cache hit (preprocessed)             174
cache miss                          4652
cache hit rate                     47.46 %
called for link                    72331
called for preprocessing             540
compile failed                       559
preprocessor error                    85
bad compiler arguments                34
unsupported source language            6
autoconf compile/link                938
no input file                        187
cleanups performed                    32
files in cache                      5039
cache size                         384.0 MB
max cache size                       5.0 GB
Edited by Kamil Trzciński (Back 2025-01-01)

Merge request reports

Loading