Run task build under a nice/memory-capped systemd scope

Repeated builds were getting SIGTERM'd or thrashing into swap when
competing with other heavy concurrent builds on the same machine.
Wraps the build in `systemd-run --user --scope` with a low CPU/IO
weight and a soft memory cap (throttles rather than kills), and caps
GOMAXPROCS so cgo doesn't spawn as many parallel cc1plus processes
compiling the vendored Qt6 binding layer.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Philip Peterson 2026-09-30 05:31:27 -08:00
parent 3c859abdc4
commit 9341a75806
2 changed files with 11 additions and 1 deletions

View file

@ -19,7 +19,16 @@ tasks:
# (Not using --ccache: its lock file went stale after an interrupted build
# and hung a subsequent one indefinitely; GOCACHE alone already caches the
# compiled cgo/C++ objects, so it's redundant anyway.)
- flatpak run --command=flatpak-builder org.flatpak.Builder --force-clean build-dir org.mozsync.App.yml
#
# Wrapped in a low-priority, memory-capped systemd scope so this doesn't
# fight other heavy builds (e.g. a concurrent Ladybird/WebKit build) for
# RAM and get OOM-killed or thrash into swap. CPUWeight/IOWeight=10 is a
# low *share* (yields under contention, still gets full speed if idle);
# MemoryHigh=3G is a soft cap Go/cgo get throttled against rather than
# killed for. GOMAXPROCS=2 (below) also caps how many parallel cc1plus
# processes cgo spawns compiling the vendored Qt6 binding layer, which is
# the main memory hog.
- systemd-run --user --scope --collect -p CPUWeight=10 -p IOWeight=10 -p MemoryHigh=3G -- flatpak run --command=flatpak-builder org.flatpak.Builder --force-clean build-dir org.mozsync.App.yml
- cp build-dir/files/bin/mozsync ./mozsync
- echo "Built ./mozsync - runs directly against the host's Qt6 runtime libs, no flatpak needed."

View file

@ -21,6 +21,7 @@ build-options:
GOFLAGS: -mod=vendor
GOCACHE: /run/build/mozsync/.gocache
CGO_ENABLED: "1"
GOMAXPROCS: "2"
PKG_CONFIG_PATH: /app/lib/x86_64-linux-gnu/pkgconfig:/app/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig
modules: