[CRIU] [PATCH 5/7] travis: enable ccache for local builds

Kir Kolyshkin kir at openvz.org
Wed Mar 15 16:17:22 PDT 2017


For now, it's done for local builds only (i.e. no per-arch Docker
builds yet). The reason is, it's easier to play with ccache when
the compiles are (relatively) fast.

Performance: there is 2x to 3x improvement in build speeds for
ideal cases (same code, hot cache), but the absolute savings
are negligible (example: 7 seconds instead of 23).

Note that ccache is not compatible with gcov, so we only enable it
for non-gcov build (which happens to be the one with clang).

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 .travis.yml                 |  4 +++-
 scripts/travis/travis-tests | 27 +++++++++++++++++++++------
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 70d666d..a5dfb9f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,7 @@
 language: c
 sudo: required
 dist: trusty
+cache: ccache
 services:
   - docker
 env:
@@ -16,6 +17,7 @@ env:
   - TR_ARCH=ppc64le     CLANG=1
   - TR_ARCH=alpine      CLANG=1
 script:
-  - sudo make -C scripts/travis $TR_ARCH
+  - sudo make CCACHE=1 -C scripts/travis $TR_ARCH
 after_success:
+  - ccache -s
   - make -C scripts/travis after_success
diff --git a/scripts/travis/travis-tests b/scripts/travis/travis-tests
index 75d15f5..ec73001 100755
--- a/scripts/travis/travis-tests
+++ b/scripts/travis/travis-tests
@@ -13,12 +13,25 @@ travis_prep () {
 
 	service apport stop
 
+	CC=gcc
+	# clang support
+	if [ "$CLANG" = "1" ]; then
+		TRAVIS_PKGS="$TRAVIS_PKGS clang"
+		CC=clang
+	fi
+
+	# ccache support, only enable for non-GCOV case
+	if [ "$CCACHE" = "1" -a -z "$GCOV" ]; then
+		# ccache is installed by default, need to set it up
+		export CCACHE_DIR=$HOME/.ccache
+		[ "$CC" = "clang" ] && export CCACHE_CPP2=yes
+		# uncomment the following to get detailed ccache logs
+		#export CCACHE_LOGFILE=$HOME/ccache.log
+		CC="ccache $CC"
+	fi
+
 	apt-get update -qq
 	apt-get install -qq $TRAVIS_PKGS
-		if [ "$CLANG" = "1" ]; then
-			apt-get install -qq clang
-			MAKE_VARS=CC=clang
-		fi
 	chmod a+x $HOME
 }
 
@@ -28,8 +41,10 @@ ulimit -c unlimited
 echo "|`pwd`/test/abrt.sh %P %p %s %e" > /proc/sys/kernel/core_pattern
 
 export GCOV
-make ${MAKE_VARS}
-make ${MAKE_VARS} -C test/zdtm
+time make CC="$CC" -j4
+time make CC="$CC" -j4 -C test/zdtm
+
+[ -f "$CCACHE_LOGFILE" ] && cat $CCACHE_LOGFILE
 
 ./criu/criu check
 ./criu/criu check --all || echo $?
-- 
2.9.3



More information about the CRIU mailing list