Skip to content

Commit a9be0f9

Browse files
committed
kernel-build: make workspace tmpfs on codebuild runners
AWS CodeBuild runners have lots of mostly unused memory. And the kernel build jobs do quite a bit of disk writes, which are never actually read. This unnecessarily slows down the execution. When running on CodeBuild, before executing the build, make sure GITHUB_WORKSPACE directory is a tmpfs filesystem, to make use of available memory and avoid unnecessary IO operations. Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
1 parent 417a5bd commit a9be0f9

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -x -euo pipefail
4+
5+
TMPFS_SIZE=20 # GB
6+
MEM_TOTAL=$(awk '/MemTotal/ {print int($2/1024)}' /proc/meminfo)
7+
8+
# sanity check: total mem is at least double TMPFS_SIZE
9+
if [ $MEM_TOTAL -lt $(($TMPFS_SIZE*1024*2)) ]; then
10+
echo "tmpfsify-workspace.sh: will not allocate tmpfs, total memory is too low (${MEM_TOTAL}MB)"
11+
exit 0
12+
fi
13+
14+
dir="$(basename "$GITHUB_WORKSPACE")"
15+
cd "$(dirname "$GITHUB_WORKSPACE")"
16+
mv "${dir}" "${dir}.backup"
17+
mkdir "${dir}"
18+
sudo mount -t tmpfs -o size=${TMPFS_SIZE}G tmpfs "${dir}"
19+
rsync -a "${dir}.backup/" "${dir}"
20+
cd -
21+

.github/workflows/kernel-build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ jobs:
6666
- uses: actions/checkout@v4
6767
with:
6868
fetch-depth: ${{ inputs.download_sources && 1 || env.BPF_NEXT_FETCH_DEPTH }}
69+
70+
- if: ${{ env.RUNNER_TYPE == 'codebuild' }}
71+
shell: bash
72+
run: .github/scripts/tmpfsify-workspace.sh
73+
6974
- if: ${{ inputs.download_sources }}
7075
name: Download bpf-next tree
7176
env:

0 commit comments

Comments
 (0)