diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d440b296d2753..6f5867aad90dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,6 +117,9 @@ jobs: with: fetch-depth: 2 + - name: remount root filesystem + run: src/ci/scripts/tune-rootfs.sh + # Free up disk space on Linux by removing preinstalled components that # we do not need. We do this to enable some of the less resource # intensive jobs to run on free runners, which however also have diff --git a/src/ci/scripts/free-disk-space-linux.sh b/src/ci/scripts/free-disk-space-linux.sh index ac3c9cfb28b87..b20d19cbb5f58 100755 --- a/src/ci/scripts/free-disk-space-linux.sh +++ b/src/ci/scripts/free-disk-space-linux.sh @@ -173,8 +173,11 @@ removeUnusedFilesAndDirs() { fi done - # Remove all files and directories at once to save time. - sudo rm -rf "${to_remove[@]}" + # GHA has high read latencies for uncached data + # so we traverse directories in parallel and feed the output to rm + printf '%s\n' "${to_remove[@]}" | \ + (xargs -P 6 -I{} -- find {} -type f -printf '%p\n\c' || true) | \ + sudo xargs -r -P 8 -n 100 -- rm -rf } execAndMeasureSpaceChange() { @@ -253,11 +256,16 @@ AVAILABLE_INITIAL=$(getAvailableSpace) printDF "BEFORE CLEAN-UP:" echo "" + +iostat -x 20 & + execAndMeasureSpaceChange cleanPackages "Unused packages" execAndMeasureSpaceChange cleanDocker "Docker images" execAndMeasureSpaceChange cleanSwap "Swap storage" execAndMeasureSpaceChange removeUnusedFilesAndDirs "Unused files and directories" +kill %1 + # Output saved space statistic echo "" printDF "AFTER CLEAN-UP:" diff --git a/src/ci/scripts/tune-rootfs.sh b/src/ci/scripts/tune-rootfs.sh new file mode 100755 index 0000000000000..6ac8d96c27dcc --- /dev/null +++ b/src/ci/scripts/tune-rootfs.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -euo pipefail +IFS=$'\n\t' + +source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" + +if isLinux && [[ $(findmnt -n /) =~ "ext4" ]] ; then + # noauto_da_alloc since auto_da_alloc causes sync IO for some common file creation patterns + # lazytime avoids sync IO when (rel)atime updates are applied + # barrier=0 disables write cache flushing, which can reduce latency at the cost of durability, + # but CI machines are ephemeral, so we don't need to be crash-proof. + # + # Ideally we'd set additional options, but those would require + # a reboot or unmounting the rootfs. + sudo mount -oremount,delalloc,lazytime,barrier=0,noauto_da_alloc / + sudo bash -c 'echo "write through" > /sys/block/sda/queue/write_cache' || true + sudo bash -c 'echo "write through" > /sys/block/sdb/queue/write_cache' || true + + ionice -c 3 fstrim / & + + lsblk + + mount +fi