Skip to content

Commit 9f57f3a

Browse files
arkqXToripuruCopilot
authored
Enable ccache reusing between apps on some CI workflows (project-chip#41503)
* Configure ccache for a greater hit ratio (project-chip#40724) * Disable reusing cache in global env setup * Enable ccache reuse on some CI workflows * Update scripts/setup/bootstrap.sh Co-authored-by: Copilot <[email protected]> * Simplify prefix script so it will run faster * Show ccache stats in post action * Use ccache as PW launcher * Do not use ccache with i.MX builds - there is not enough benefit: Overall workflow time: 48m 15s Cacheable calls: 2951 / 2951 (100.0%) Hits: 144 / 2951 ( 4.88%) Direct: 30 / 144 (20.83%) Preprocessed: 114 / 144 (79.17%) Misses: 2807 / 2951 (95.12%) Local storage: Cache size (GiB): 0.5 / 5.0 (10.83%) Hits: 144 / 2951 ( 4.88%) Misses: 2807 / 2951 (95.12%) Without ccache time was ~40 min. So, such caching does not make sense here. --------- Co-authored-by: Miłosz Tomkiel <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent c87ece5 commit 9f57f3a

File tree

6 files changed

+39
-17
lines changed

6 files changed

+39
-17
lines changed

.github/actions/setup-ccache/action.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,21 @@ runs:
2323
using: "composite"
2424
steps:
2525
- name: Configure ccache
26-
shell: bash
27-
run: |
28-
mkdir -p .ccache
29-
echo "CCACHE_BASEDIR=${{ github.workspace }}" >> $GITHUB_ENV
30-
echo "CCACHE_SLOPPINESS=time_macros" >> $GITHUB_ENV
31-
echo "CCACHE_DIR=${{ github.workspace }}/.ccache" >> $GITHUB_ENV
32-
echo "CCACHE_COMPILERCHECK=content" >> $GITHUB_ENV
33-
echo "CCACHE_MAXSIZE=5G" >> $GITHUB_ENV
34-
echo "CCACHE_COMPRESS=1" >> $GITHUB_ENV
35-
echo "CCACHE_COMPRESSLEVEL=6" >> $GITHUB_ENV
26+
uses: pyTooling/Actions/[email protected]
27+
with:
28+
main: |
29+
mkdir -p .ccache
30+
echo "CCACHE_NOHASHDIR=1" >> $GITHUB_ENV
31+
echo "CCACHE_BASEDIR=${{ github.workspace }}" >> $GITHUB_ENV
32+
echo "CCACHE_SLOPPINESS=time_macros" >> $GITHUB_ENV
33+
echo "CCACHE_DIR=${{ github.workspace }}/.ccache" >> $GITHUB_ENV
34+
echo "CCACHE_COMPILERCHECK=content" >> $GITHUB_ENV
35+
echo "CCACHE_MAXSIZE=5G" >> $GITHUB_ENV
36+
echo "CCACHE_COMPRESS=1" >> $GITHUB_ENV
37+
echo "CCACHE_COMPRESSLEVEL=6" >> $GITHUB_ENV
38+
echo "CHIP_PW_COMMAND_LAUNCHER=ccache" >> $GITHUB_ENV
39+
post: |
40+
ccache --show-stats
3641
- name: Optionally disable ccache
3742
if: ${{ inputs.disable == 'true' }}
3843
shell: bash

.github/workflows/examples-linux-arm.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ concurrency:
2727
cancel-in-progress: true
2828

2929
env:
30+
CCACHE_NOHASHDIR: 1
3031
CHIP_NO_LOG_TIMESTAMPS: true
32+
CHIP_PW_COMMAND_LAUNCHER: ccache
3133

3234
jobs:
3335
arm_crosscompile:
@@ -67,3 +69,6 @@ jobs:
6769
--target linux-arm64-camera-clang \
6870
build \
6971
"
72+
73+
- name: CCache statistics
74+
run: ccache --show-stats

.github/workflows/examples-linux-standalone.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ concurrency:
2727
cancel-in-progress: true
2828

2929
env:
30+
CCACHE_NOHASHDIR: 1
3031
CHIP_NO_LOG_TIMESTAMPS: true
32+
CHIP_PW_COMMAND_LAUNCHER: ccache
3133

3234
jobs:
3335
linux_standalone:
@@ -179,3 +181,6 @@ jobs:
179181
"./scripts/build/build_examples.py \
180182
--target linux-x64-closure \
181183
build"
184+
185+
- name: CCache statistics
186+
run: ccache --show-stats

.github/workflows/tests.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,6 @@ jobs:
318318
--copy-artifacts-to objdir-clone \
319319
"
320320
321-
- name: ccache stats
322-
run: ccache -s
323-
324321
- name: Run Tests using the python parser sending commands to chip-tool
325322
run: |
326323
./scripts/run_in_build_env.sh \
@@ -824,9 +821,6 @@ jobs:
824821
--pw-command-launcher=ccache build --copy-artifacts-to objdir-clone
825822
&& rm -rf out/linux-x64-water-leak-detector-${BUILD_VARIANT}-tsan-clang-test"
826823
827-
- name: ccache stats
828-
run: ccache -s
829-
830824
- name: Install push_av_server dependencies
831825
run: >-
832826
./scripts/run_in_python_env.sh out/venv \
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
# Add -P flag to get rid of #line directives which break caching
3+
exec "$@" -P

scripts/setup/bootstrap.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ _submodules_need_updating() {
6868
)
6969

7070
for submodule_path in "${_SUBMODULE_PATHS[@]}"; do
71-
if git submodule status "$submodule_path" | grep -E '^-' >/dev/null 2>&1; then
71+
if git submodule status "$submodule_path" | grep -E '^-' >/dev/null 2>&1; then
7272
echo "git shows that $submodule_path has changes"
7373
unset _SUBMODULE_PATHS
7474
return 0 # Success
@@ -204,6 +204,16 @@ if [ -n "$ZSH_VERSION" ]; then
204204
. "$_CHIP_ROOT/scripts/helpers/zsh-completion.zsh"
205205
fi
206206

207+
# Set ccache environment variables
208+
# TODO: For now, the no-hash-dir is not enabled globally, however, anyone can
209+
# enable it in the local environment, so apps build in different output
210+
# directories can reuse cache. In order to enable it globally we need
211+
# to figure out why NRF builds do not work when sharing cache between
212+
# applications.
213+
#export CCACHE_NOHASHDIR=1
214+
export CCACHE_PREFIX_CPP="$_CHIP_ROOT/scripts/helpers/ccache-prefix-cpp.sh"
215+
export CCACHE_BASEDIR="$_CHIP_ROOT"
216+
207217
unset -f _bootstrap_or_activate
208218
unset -f _install_additional_pip_requirements
209219

0 commit comments

Comments
 (0)