Skip to contentSkip to conversation

gitlab-ci: add cache to decrease build times

PATCH In review Q. Gylstorff 2 participants 3 messages Oct 26, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gitlab-ci: add cache to decrease build times

From: Quirin Gylstorff <[email protected]>

Add the variable CCACHE_DIR to the build to move the ccache from ~/.ccache to the current directory and upload the cache from each build.

Each job uses a separate cache.

---

You can find an example build at:
https://gitlab.com/Quirin.Gy/xenomai/-/pipelines/207559342/builds
On this setup the build time is decrease from 2h to 20min. Each build has 0.5 cores available.

Changes V2:
- Move ccache dir to $(pwd)/.ccache instead of .ccache in each build dir.

 .gitlab-ci.yml | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
.gitlab-ci.yml +7 -6
index 59bd1d355..d76c9e25e 100644
@@ -56,14 +56,12 @@ variables:
       export CONFIGURE_OPTS="--enable-dlopen-libs --enable-lazy-setsched"
       ;;
       esac
-    - mkdir ~/ccache
-    - ln -s /usr/bin/ccache ~/ccache/aarch64-linux-gnu-gcc
-    - ln -s /usr/bin/ccache ~/ccache/arm-linux-gnueabihf-gcc
-    - ln -s /usr/bin/ccache ~/ccache/powerpc-linux-gnu-gcc
-    - export PATH=~/ccache:$PATH
+    - ln -s /usr/lib/ccache/${CROSS_COMPILE}gcc-8 /usr/lib/ccache/${CROSS_COMPILE}gcc
+    - export PATH=/usr/lib/ccache:$PATH
     - ${CROSS_COMPILE}gcc --version
 
   script:
+    - export CCACHE_DIR=$(pwd)/.ccache
     - pushd ${KDIR}
     - make -j $(nproc) ${KERNEL_DEFCONFIG}
     # Generic settings
@@ -162,7 +160,10 @@ variables:
     - ./configure --enable-smp ${CONFIGURE_OPTS}
     - make -j $(nproc)
     - ccache -s
-
+  cache:
+    key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
+    paths:
+      - .ccache
 
 arm-4.19-release:
   extends: .build
Signature · 1 line
2.20.1
#1 lore raw
Quoted 46 lines · Q. Gylstorff

From: Quirin Gylstorff <[email protected]>

Add the variable CCACHE_DIR to the build to move the ccache from ~/.ccache to the current directory and upload the cache from each build.

Each job uses a separate cache.

---

You can find an example build at:
https://gitlab.com/Quirin.Gy/xenomai/-/pipelines/207559342/builds
On this setup the build time is decrease from 2h to 20min. Each build has 0.5 cores available.

Changes V2:
- Move ccache dir to $(pwd)/.ccache instead of .ccache in each build dir.

 .gitlab-ci.yml | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
.gitlab-ci.yml +3 -5
index 59bd1d355..d76c9e25e 100644
@@ -56,14 +56,12 @@ variables:
       export CONFIGURE_OPTS="--enable-dlopen-libs --enable-lazy-setsched"
       ;;
       esac
-    - mkdir ~/ccache
-    - ln -s /usr/bin/ccache ~/ccache/aarch64-linux-gnu-gcc
-    - ln -s /usr/bin/ccache ~/ccache/arm-linux-gnueabihf-gcc
-    - ln -s /usr/bin/ccache ~/ccache/powerpc-linux-gnu-gcc
-    - export PATH=~/ccache:$PATH
+    - ln -s /usr/lib/ccache/${CROSS_COMPILE}gcc-8 /usr/lib/ccache/${CROSS_COMPILE}gcc
+    - export PATH=/usr/lib/ccache:$PATH
     - ${CROSS_COMPILE}gcc --version
 
   script:
+    - export CCACHE_DIR=$(pwd)/.ccache
     - pushd ${KDIR}
     - make -j $(nproc) ${KERNEL_DEFCONFIG}
     # Generic settings
@@ -162,7 +160,10 @@ variables:
     - ./configure --enable-smp ${CONFIGURE_OPTS}

.gitlab-ci.yml variables: · line 169

Quoted 10 lines
.gitlab-ci.yml +4 -1
     - make -j $(nproc)
     - ccache -s
-
+  cache:
+    key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
+    paths:
+      - .ccache
 
 arm-4.19-release:
   extends: .build

Does this still apply to master? I merged your previous change this morning by accident. If not, please rebase.

Thanks,
Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#2 lore raw
Quoted 61 lines · Jan Kiszka via Xenomai
Quoted 46 lines · Q. Gylstorff

From: Quirin Gylstorff <[email protected]>

Add the variable CCACHE_DIR to the build to move the ccache from ~/.ccache to the current directory and upload the cache from each build.

Each job uses a separate cache.

---

You can find an example build at:
https://gitlab.com/Quirin.Gy/xenomai/-/pipelines/207559342/builds
On this setup the build time is decrease from 2h to 20min. Each build has 0.5 cores available.

Changes V2:
- Move ccache dir to $(pwd)/.ccache instead of .ccache in each build dir.

 .gitlab-ci.yml | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
.gitlab-ci.yml +3 -5
index 59bd1d355..d76c9e25e 100644
@@ -56,14 +56,12 @@ variables:
       export CONFIGURE_OPTS="--enable-dlopen-libs --enable-lazy-setsched"
       ;;
       esac
-    - mkdir ~/ccache
-    - ln -s /usr/bin/ccache ~/ccache/aarch64-linux-gnu-gcc
-    - ln -s /usr/bin/ccache ~/ccache/arm-linux-gnueabihf-gcc
-    - ln -s /usr/bin/ccache ~/ccache/powerpc-linux-gnu-gcc
-    - export PATH=~/ccache:$PATH
+    - ln -s /usr/lib/ccache/${CROSS_COMPILE}gcc-8 /usr/lib/ccache/${CROSS_COMPILE}gcc
+    - export PATH=/usr/lib/ccache:$PATH
     - ${CROSS_COMPILE}gcc --version
 
   script:
+    - export CCACHE_DIR=$(pwd)/.ccache
     - pushd ${KDIR}
     - make -j $(nproc) ${KERNEL_DEFCONFIG}
     # Generic settings
@@ -162,7 +160,10 @@ variables:
     - ./configure --enable-smp ${CONFIGURE_OPTS}

.gitlab-ci.yml variables: · line 169

Quoted 10 lines
.gitlab-ci.yml +4 -1
     - make -j $(nproc)
     - ccache -s
-
+  cache:
+    key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
+    paths:
+      - .ccache
 
 arm-4.19-release:
   extends: .build

Does this still apply to master? I merged your previous change this morning by accident. If not, please rebase.

Quoted 3 lines

Thanks,
Jan

Applies fine, taken to next.

Thanks,
Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux