How to get started with:
- ccache
- memcached
- distcc/distccd
Pull request:
These instructions are for Ubuntu 16.04 LTS.
Install the distcc client/server component.
$ sudo apt-get install distcc
Setup the server configuration (127.0.0.1
):
$ export DISTCC_HOSTS=127.0.0.1
Edit /etc/default/distcc
to allow nets/hosts.
$ sudo service distcc restart
Run distccd with --stats, for statistics. [optional]
DAEMON_ARGS="$DAEMON_ARGS --stats"
$ telnet localhost 3633
Install the memcached server component.
$ sudo apt-get install memcached
Setup the server configuration (default=64M):
$ export MEMCACHED_SERVERS=localhost
Edit /etc/memcached.conf
to increase memory.
$ sudo service memcached restart
Also install memstat, for statistics. [optional]
$ sudo apt-get install libmemcached-tools
$ memcstat # ubuntu has renamed this tool
Build ccache with memcached support (needs libmemcached):
$ git clone https://github.com/ccache/ccache.git
$ cd ccache
$ git checkout dev/memcached
$ sudo apt-get install autoconf
$ ./autogen.sh
$ sudo apt-get install libmemcached-dev
$ ./configure --enable-memcached
$ make -j4
$ make test
$ sudo apt-get install --no-install-recommends asciidoc xsltproc docbook-xml docbook-xsl
$ sudo make install
Upload the existing $CCACHE_DIR cache contents [optional]:
$ sudo apt-get install python-memcache
$ ./upload-memcached.py
Configure memcached servers to use for ccache (see above):
$ export CCACHE_MEMCACHED_CONF="--SERVER=localhost"
Configure ccache to use distcc for compilation (see above):
$ export CCACHE_PREFIX="distcc"
The compilation will be done by the distcc server (distccd), only the preprocessing will be done locally (from ccache).
Configure ccache to only run the preprocessor (cpp) once:
$ export CCACHE_NOCPP2=1
Make a simple compilation, with verbose logging enabled:
$ echo 'int main() {}' > test.c
$ export CCACHE_LOGFILE=$PWD/ccache.log
$ export DISTCC_VERBOSE=1 DISTCC_LOG=$PWD/distcc.log
$ ccache cc -c test.c
This will create one manifest entry and one object entry:
664202a7dafbe30973103db470837ccd-143
fc5f78b19f525061889c52036a902cbd-253
Enabling us to get direct hits, even when not in local cache...
You can now continue by adding more (i.e. non-local) servers.
For the impatient, here's a Vagrantfile to do it for you.
@afbjorklund the ccache checout dont work, the branch dev/memcached is missing. :(
root@item:/tmp# git clone https://github.com/ccache/ccache.git
Cloning into 'ccache'...
remote: Enumerating objects: 37, done.
remote: Counting objects: 100% (37/37), done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 16332 (delta 14), reused 24 (delta 12), pack-reused 16295
Receiving objects: 100% (16332/16332), 7.43 MiB | 9.37 MiB/s, done.
Resolving deltas: 100% (11672/11672), done.
root@item:/tmp# cd ccache
root@item:/tmp/ccache# git checkout dev/memcached
error: pathspec 'dev/memcached' did not match any file(s) known to git
root@item:/tmp/ccache#