[ovs-dev,1/3] travis: Cache DPDK build.
diff mbox series

Message ID 20190806114607.9659-2-i.maximets@samsung.com
State Accepted
Headers show
Series
  • travis: Build time optimization.
Related show

Commit Message

Ilya Maximets Aug. 6, 2019, 11:46 a.m. UTC
This change enables cache for DPDK build directory, so we'll never
build same version of DPDK again. This speeds up each DPDK related
job by 4-6 minutes effectively saving 30-50 minutes of the total time.
Ex. Full TravisCI run on 'trusty' images:

  Without cache:
    Ran for 1 hr 9 min 29 sec
    Total time 4 hrs 55 min 13 sec

  With populated cache:
    Ran for 1 hr 2 min 18 sec
    Total time 4 hrs 20 min 9 sec

Saved:
  Real time: ~7 minutes.
  Total worker time: ~35 minutes.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 .travis.yml            |  4 ++++
 .travis/linux-build.sh | 28 +++++++++++++++++++++++-----
 2 files changed, 27 insertions(+), 5 deletions(-)

Patch
diff mbox series

diff --git a/.travis.yml b/.travis.yml
index 782f72fea..7fe4bfacf 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,6 +6,10 @@  compiler:
 os:
   - linux
 
+cache:
+  directories:
+    - dpdk-dir
+
 addons:
   apt:
     packages:
diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh
index 17428fa6b..98aa12b22 100755
--- a/.travis/linux-build.sh
+++ b/.travis/linux-build.sh
@@ -65,16 +65,33 @@  function install_kernel()
 
 function install_dpdk()
 {
-    if [ "${1##refs/*/}" != "${1}" ]; then
+    local DPDK_VER=$1
+    local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
+
+    if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
+        # Avoid using cache for git tree build.
+        rm -rf dpdk-dir
+
         DPDK_GIT=${DPDK_GIT:-https://dpdk.org/git/dpdk}
-        git clone --single-branch $DPDK_GIT dpdk-git -b "${1##refs/*/}"
-        cd dpdk-git
+        git clone --single-branch $DPDK_GIT dpdk-dir -b "${DPDK_VER##refs/*/}"
+        pushd dpdk-dir
         git log -1 --oneline
     else
+        if [ -f "${VERSION_FILE}" ]; then
+            VER=$(cat ${VERSION_FILE})
+            if [ "${VER}" = "${DPDK_VER}" ]; then
+                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-dir/build"
+                echo "Found cached DPDK ${VER} build in $(pwd)/dpdk-dir"
+                return
+            fi
+        fi
+        # No cache or version mismatch.
+        rm -rf dpdk-dir
         wget https://fast.dpdk.org/rel/dpdk-$1.tar.xz
         tar xvf dpdk-$1.tar.xz > /dev/null
         DIR_NAME=$(tar -tf dpdk-$1.tar.xz | head -1 | cut -f1 -d"/")
-        cd $DIR_NAME
+        mv ${DIR_NAME} dpdk-dir
+        pushd dpdk-dir
     fi
 
     make config CC=gcc T=$TARGET
@@ -91,7 +108,8 @@  function install_dpdk()
     make -j4 CC=gcc EXTRA_CFLAGS='-fPIC'
     EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/build"
     echo "Installed DPDK source in $(pwd)"
-    cd ..
+    popd
+    echo "${DPDK_VER}" > ${VERSION_FILE}
 }
 
 function configure_ovs()