From b24513e79507103b54ead46baa8ee76017f463e5 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Tue, 10 Nov 2026 16:40:36 +0100 Subject: [PATCH] fix(freebsd): cap the VM's ZFS ARC so big test crates aren't OOM-killed (#190) * fix(freebsd): give the VM a swap file and cap the ZFS ARC photocraft's FreeBSD job was SIGKILLed compiling photocraft-ui-egui's lib tests late in the run (release run 42609972735, dispatch 42805955303). Add an 8 GB swap file when the guest has none, cap the ARC at 2 GB when the image uses ZFS, and print disk, swap and memory so the next OOM is diagnosable. * fix(freebsd): only touch swap and the ARC inside a FreeBSD guest The workflow tests run the prepare script on Linux under sh -eu, where swapctl doesn't exist. Run the ARC cap, swap file and diagnostics only when uname is FreeBSD, and don't let the diagnostics fail the step. * fix(freebsd): add the swap file only with room to spare, and remove a partial one Per review: a dd that runs out of space must not leave a partial /var/swap0 that then starves the build. Require 16 GB free on /var first and delete the file if any step fails. * fix(freebsd): keep only the ZFS ARC cap; drop the swap-file fallback Per review: swap on a ZFS-backed file can hang FreeBSD under memory pressure, and today's image already has a swap partition, so the fallback never ran. The verified run passed on the ARC cap alone. --- .github/workflows/freebsd.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index 9840cbb..fe308b1 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -106,6 +106,19 @@ jobs: prepare: | # Keep rustup/proxies outside the Cargo data cache. unset CARGO_HOME CARGO_TARGET_DIR + # A large test crate's rustc (photocraft-ui-egui's lib tests) was SIGKILLed when the + # 12 GB guest ran out of memory late in a run: the image's root is ZFS with no ARC + # limit, so the ARC kept the target dir's pages. Cap it. (No swap file: swap on a + # ZFS-backed file can hang FreeBSD under memory pressure; the image has a 1 GB swap + # partition.) Print disk, swap and memory so the next OOM is easy to diagnose. + if [ "$(uname -s)" = FreeBSD ]; then + if sysctl -n vfs.zfs.arc_max >/dev/null 2>&1; then + sysctl vfs.zfs.arc_max=2147483648 || echo "::warning::could not cap the ZFS ARC" + fi + df -h / /var/tmp || true + swapctl -l || true + sysctl -n hw.physmem || true + fi if [ "${{ matrix.arch }}" = aarch64 ]; then # The host compiler and the aarch64 standard library come from the amd64 and # aarch64 lang/rust packages, which must be the same build. "latest" can build