ITK/Release 4/Wrapping/ccache: Difference between revisions

From KitwarePublic
< ITK‎ | Release 4‎ | Wrapping
Jump to navigationJump to search
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Using CCache for WrapITK =
= Using CCache for WrapITK =
== Installation of CCACHE ==
Using CCache[http://ccache.samba.org] to build WrapITK can improve the build times considerably. For all unix systems (including MacOS X), ccache is enabled by creating symbolic links to the g++/gcc compiler:
Using CCache[http://ccache.samba.org] to build WrapITK can improve the build times considerably. For all unix systems (including MacOS X), ccache is enabled by creating symbolic links to the g++/gcc compiler:
  ln -s /usr/bin/ccache /usr/local/bin/g++
  ln -s /usr/bin/ccache /usr/local/bin/g++
Line 6: Line 8:
  $ sudo port install ccache
  $ sudo port install ccache
  $ export PATH= /opt/local/libexec/ccache:$PATH
  $ export PATH= /opt/local/libexec/ccache:$PATH
== ITK Specific configuration Flags ==
Note that ccache is installed outside of ITK, and will benefit any software project that uses gcc.
The other parts of WrapITK which can benefit from ccache are gccxml and swig. To enable ccache usage with them, just turn ON the option WRAP_ITK_USE_CCACHE and everything is gonna be set up for you automatically.
== Example of speed-ups ==
=== 8-cores (8 physical threads) ===
All the subsequent builds of WrapITK would use ccache and we can see a speedup of as much as 40 minutes for repeated invocations. For example, following lists the results for building WrapITK with & without ccache (for 8-core Quad-Core Intel Xeon with Mac OSX Snow Leopard):
All the subsequent builds of WrapITK would use ccache and we can see a speedup of as much as 40 minutes for repeated invocations. For example, following lists the results for building WrapITK with & without ccache (for 8-core Quad-Core Intel Xeon with Mac OSX Snow Leopard):


'''Without cache:'''
'''Without cache:'''
  time make -j 12
  time make -j 12
  real     46m58.307s
  real 46m58.307s
  user     41m49.829s
  user 41m49.829s
  sys       4m22.580s
  sys 4m22.580s


Repeated invocation:
Repeated invocation:
  make clean
  make clean
  time make -j 12
  time make -j 12
  real     44m3.667s
  real 44m3.667s
  user   39m29.606s
  user 39m29.606s
  sys     3m49.870s
  sys 3m49.870s
 
On enabling ccache, the build times reduce considerably as noted below:


On enabling ccache, the build times reduce considerably as noted below
'''With cache:'''
""With cache:""
  time make -j 12
  time make -j 12
  real   45m44.488s
  real 45m44.488s
  user   40m3.881s
  user 40m3.881s
  sys     4m25.381s
  sys 4m25.381s
    
    
  ccache -s
ccache -s
  cache hit (direct)                   19
cache hit (direct) 19
  cache hit (preprocessed)     1
cache hit (preprocessed) 1
  cache miss                             2658
cache miss 2658
  called for link                         396
called for link 396
  compile failed                         22  
compile failed 22  
  preprocessor error                 12
preprocessor error 12
  no input file                             21
no input file 21
  files in cache                           5307
files in cache 5307
  cache size                               593.9 Mbytes
cache size 593.9 Mbytes
  max cache size                       1.0 Gbytes
max cache size 1.0 Gbytes


Repeated invocation:
Repeated invocation:
Line 44: Line 58:
  time make -j 12
  time make -j 12


  real     2m48.801s
  real 2m48.801s
  user   1m28.743s
  user 1m28.743s
  sys     0m40.986s
  sys 0m40.986s


  ccache -s
  ccache -s
  cache hit (direct)                 2435
  cache hit (direct) 2435
  cache hit (preprocessed)   0
  cache hit (preprocessed) 0
  cache miss                             0
  cache miss 0
  called for link                     152
  called for link 152
  files in cache                     5307
  files in cache 5307
  cache size                         593.9 Mbytes
  cache size 593.9 Mbytes
  max cache size                 1.0 Gbytes
  max cache size 1.0 Gbytes

Latest revision as of 16:00, 9 December 2011

Using CCache for WrapITK

Installation of CCACHE

Using CCache[1] to build WrapITK can improve the build times considerably. For all unix systems (including MacOS X), ccache is enabled by creating symbolic links to the g++/gcc compiler:

ln -s /usr/bin/ccache /usr/local/bin/g++
ln -s /usr/bin/ccache /usr/local/bin/gcc

Alternatively, on MacOS X, Install ccache with Macports. The Macports installation would automatically create the symbolic links to g++/gcc compilers and put them in the directory /opt/local/libexec/ccache. The only remaining thing then is to add this directory to the PATH variable (alternatively you can add it to the .bash_profile or .profile in home directory)

$ sudo port install ccache
$ export PATH= /opt/local/libexec/ccache:$PATH

ITK Specific configuration Flags

Note that ccache is installed outside of ITK, and will benefit any software project that uses gcc.

The other parts of WrapITK which can benefit from ccache are gccxml and swig. To enable ccache usage with them, just turn ON the option WRAP_ITK_USE_CCACHE and everything is gonna be set up for you automatically.

Example of speed-ups

8-cores (8 physical threads)

All the subsequent builds of WrapITK would use ccache and we can see a speedup of as much as 40 minutes for repeated invocations. For example, following lists the results for building WrapITK with & without ccache (for 8-core Quad-Core Intel Xeon with Mac OSX Snow Leopard):

Without cache:

time make -j 12
real  46m58.307s
user  41m49.829s
sys  4m22.580s

Repeated invocation:

make clean
time make -j 12
real  44m3.667s
user  39m29.606s
sys  3m49.870s

On enabling ccache, the build times reduce considerably as noted below:

With cache:

time make -j 12
real  45m44.488s
user  40m3.881s
sys  4m25.381s
 
ccache -s
cache hit (direct)  19
cache hit (preprocessed)  1
cache miss  2658
called for link  396
compile failed  22 
preprocessor error  12
no input file  21
files in cache  5307
cache size  593.9 Mbytes
max cache size  1.0 Gbytes

Repeated invocation:

make clean
time make -j 12
real  2m48.801s
user  1m28.743s
sys  0m40.986s
ccache -s
cache hit (direct)  2435
cache hit (preprocessed)  0
cache miss  0
called for link  152
files in cache  5307
cache size  593.9 Mbytes
max cache size  1.0 Gbytes