Difference between revisions of "Speed Builds Using Compiler Cache"

From odroid US
Jump to: navigation, search
(Created page with "A package named ccache can speed up builds. It is easy to use. <pre> # install the c compiler cache # as root apt-get install ccache # add symlinks so ccache can invoke the ...")
 
Line 1: Line 1:
A package named ccache can speed up builds.  It is easy to use.
+
A package named ccache can speed up builds.  It is easy to use.  
  
 
<pre>
 
<pre>
Line 8: Line 8:
 
# /usr/local/bin is usually in the path before /usr/bin, so that is where we put the symlinks  
 
# /usr/local/bin is usually in the path before /usr/bin, so that is where we put the symlinks  
 
cd /usr/local/bin
 
cd /usr/local/bin
ln -s $(which ccache) gcc
+
# The CROSS_COMPILE environment variable should be empty for odroid native builds, it could be something like
ln -s $(which ccache) g++
+
# arm-none-linux-gnueabi- for cross-building on a host.
ln -s $(which ccache) cpp
+
ln -s $(which ccache)  $(echo $CROSS_COMPILE)gcc
ln -s $(which ccache) c++
+
ln -s $(which ccache)  $(echo $CROSS_COMPILE)g++
 +
ln -s $(which ccache)  $(echo $CROSS_COMPILE)cpp
 +
ln -s $(which ccache)  $(echo $CROSS_COMPILE)c++
 
</pre>
 
</pre>
  
Line 26: Line 28:
 
</pre>
 
</pre>
  
After about 45 minutes, the native build is complete.  
+
After about 45 minutes, the native build is complete, using SD Card.  An eMMC build completed after about 17 minutes.
  
 
<pre>
 
<pre>
Line 35: Line 37:
 
</pre>
 
</pre>
  
Now the complete build takes 27 minutesCheck the ccache statistics:
+
Now the clean re-build takes 2 minutes 15 seconds on (eMMC)
 +
 
 +
Check the ccache statistics:
 
<pre>
 
<pre>
 
root@odroidu2-1:/usr/src/linux# ccache -s     
 
root@odroidu2-1:/usr/src/linux# ccache -s     
Line 53: Line 57:
  
  
TODO: Repeat with eMMC.  The native build is much slower thatn I expected, even with ccache.
+
 
 +
=== Kernel Build Time Comparisons ===
 +
using odroidu2_ubuntu-defconfig and linux-3.0.57 (ed's kernel)
 +
 
 +
<pre>
 +
Processor     : Odroid-U2
 +
Memory     : 2GiB
 +
Operating System    : Debian Wheezy
 +
 
 +
SD-Card Clean cache, clean build 45m15s
 +
SD-Card cached, clean build [re-test this]
 +
eMMC Clean cache, clean build 17m14s
 +
eMMC cached, clean build 2m10s
 +
</pre>
 +
 
 +
This data is for cross-building on x86_64 Linux host CodeSourcery (2011.09-64) toolchain.
 +
<pre>
 +
Processor : 4x Intel(R) Core(TM)2 Quad CPU    Q9550 @ 2.83GHz
 +
Memory : 8177MB (2393MB used)
 +
Operating System : Linux Mint 13 Maya
 +
Using solid-state drive for source code and ccache directory (CCACHE_DIR)
 +
 
 +
SSD Clean cache, clean build 5m25s
 +
SSD cached, clean build 0m33s
 +
 
 +
</pre>

Revision as of 18:32, 14 January 2013

A package named ccache can speed up builds. It is easy to use.

# install the c compiler cache
# as root
apt-get install ccache
# add symlinks so ccache can invoke the compiler
# /usr/local/bin is usually in the path before /usr/bin, so that is where we put the symlinks 
cd /usr/local/bin
# The CROSS_COMPILE environment variable should be empty for odroid native builds, it could be something like
# arm-none-linux-gnueabi- for cross-building on a host.
ln -s $(which ccache)  $(echo $CROSS_COMPILE)gcc
ln -s $(which ccache)  $(echo $CROSS_COMPILE)g++
ln -s $(which ccache)  $(echo $CROSS_COMPILE)cpp
ln -s $(which ccache)  $(echo $CROSS_COMPILE)c++

To test, it build the kernel. You need to be set up with kernel source and prerequisites first: (link to tutorial)

cd /usr/src/linux
# clear the ccache
ccache -c
# start clean
make clean
#
time make -j8

After about 45 minutes, the native build is complete, using SD Card. An eMMC build completed after about 17 minutes.

# clean the object files
make clean
# time the build again
time make -j8

Now the clean re-build takes 2 minutes 15 seconds on (eMMC)

Check the ccache statistics:

root@odroidu2-1:/usr/src/linux# ccache -s    
cache directory                     /root/.ccache
cache hit (direct)                  2554
cache hit (preprocessed)               3
cache miss                             0
called for link                       11
called for preprocessing               2
unsupported source language           62
no input file                         68
files in cache                      7709
cache size                         316.4 Mbytes
max cache size                       1.0 Gbytes
root@odroidu2-1:/usr/src/linux# 


Kernel Build Time Comparisons

using odroidu2_ubuntu-defconfig and linux-3.0.57 (ed's kernel)

Processor	    : Odroid-U2
Memory		    : 2GiB
Operating System    : Debian Wheezy

SD-Card Clean cache, clean build 45m15s
SD-Card cached, clean build [re-test this]
eMMC Clean cache, clean build 17m14s
eMMC cached, clean build 2m10s

This data is for cross-building on x86_64 Linux host CodeSourcery (2011.09-64) toolchain.

Processor	: 4x Intel(R) Core(TM)2 Quad CPU    Q9550  @ 2.83GHz
Memory		: 8177MB (2393MB used)
Operating System		: Linux Mint 13 Maya
Using solid-state drive for source code and ccache directory (CCACHE_DIR)

SSD Clean cache, clean build 5m25s
SSD cached, clean build 0m33s