Wednesday, May 11, 2011

Using ccache to build Android(2)

This is follow up of previous ccache post. (Japanese version)

Advice from JBQ


I mentioned previous post at Android Building of Google group. I got an advice from JBQ, Android Open-Source Project in Google.

Be sure to use a large cache. The default size is too small (1GB
IIRC) to fit the data from a single build. I use 100GB.

The biggest benefits of ccache come with lots of RAM (so that the
relevant ccache data remains in the disk cache from one build to the
other). On my machine, I saw some measurable differences when
upgrading to 24GB of RAM from 12GB.


I will buy memory at Akihabara on next visit to Tokyo.
Anyway, I investigated ccache configuration.

Configuration of ccache


Check version info and command line help.
$ prebuilt/linux-x86/ccache/ccache -V
ccache version 2.4
Copyright Andrew Tridgell 2002
Released under the GNU GPL v2 or later
$ prebuilt/linux-x86/ccache/ccache -help
ccache, a compiler cache. Version 2.4
Copyright Andrew Tridgell, 2002

Usage:
ccache [options]
ccache compiler [compile options]
compiler [compile options]    (via symbolic link)

Options:
-s                      show statistics summary
-z                      zero statistics
-c                      run a cache cleanup
-C                      clear the cache completely
-F <maxfiles>           set maximum files in cache
-M <maxsize>            set maximum size of cache (use G, M or K)
-h                      this help page
-V                      print version number


Current cache status.
$ prebuilt/linux-x86/ccache/ccache -s
cache directory                     /home/koba/.ccache
cache hit                          17847
cache miss                         10456
called for link                     1268
compile failed                         1
not a C/C++ file                     966
unsupported compiler option          144
files in cache                     16952
cache size                         820.1 Mbytes
max cache size                     976.6 Mbytes
$


Increase cache size to 10GB.
$ prebuilt/linux-x86/ccache/ccache -M 10G
Set cache size limit to 10485760k
$ prebuilt/linux-x86/ccache/ccache -s
cache directory                     /home/koba/.ccache
cache hit                          17847
cache miss                         10456
called for link                     1268
compile failed                         1
not a C/C++ file                     966
unsupported compiler option          144
files in cache                     16952
cache size                         820.1 Mbytes
max cache size                      10.0 Gbytes
$


Clear all cache and build,
$ prebuilt/linux-x86/ccache/ccache -C
Cleared cache
$ rm -rf out
$ ./build.sh

real 14m0.113s
user 112m22.100s
sys 6m37.810s
$ prebuilt/linux-x86/ccache/ccache -s
cache directory                     /home/koba/.ccache
cache hit                          18696
cache miss                         19178
called for link                     1690
compile failed                         1
not a C/C++ file                    1288
unsupported compiler option          192
files in cache                     17444
cache size                         835.4 Mbytes
max cache size                      10.0 Gbytes
$


Build again,
$ rm -rf out
$ ./build.sh

real 8m1.576s
user 63m33.490s
sys 4m6.700s
$ prebuilt/linux-x86/ccache/ccache -s
cache directory                     /home/koba/.ccache
cache hit                          28030
cache miss                         19186
called for link                     2112
compile failed                         1
not a C/C++ file                    1610
unsupported compiler option          240
files in cache                     17460
cache size                         835.9 Mbytes
max cache size                      10.0 Gbytes
$


In this case, used cache size is 835MB. It is smaller than default max size (1GB). But when I extend max cache size to 10GB, cache hit count is increased a bit, and build time becomes shorter a bit.
According to my friend's blog, cache size was bigger than 1GB and when building another source tree the cache size grew up to 2GB.
So the max cache size configuration should be (the number of working build trees x 1GB + alpha).

Links of ccache


Speed up rebuilding with ccache and building android disk vdi (in Japanese)
DNA - Free software - ccache (in Japanese)
Improve collaborative build times with ccache (in Japanese)

Related pages


Using ccache to build Android

No comments:

Post a Comment