From 5a46e2396e2af1b8b1b825f3df60eeda3513cb51 Mon Sep 17 00:00:00 2001 From: AKhozya Date: Thu, 25 Dec 2025 18:48:30 +0000 Subject: [PATCH] Add -C option for CPU quota limit on build containers Similar to the existing -M option for memory limits, this adds a -C option to set a CPU quota on the systemd-nspawn build containers. This is useful for rebuilderd setups where you want to limit CPU usage to prevent resource contention with other services on the same machine. Usage: repro -C 500% package.pkg.tar.zst # Limit to 5 CPU cores repro -C 1200% -M 24G package.pkg.tar.zst # 12 cores, 24GB RAM The CPU quota is passed to systemd-nspawn via --property="CPUQuota=...", which sets the cgroup cpu.max limit on the container. Environment variable MAX_CPU can also be used (e.g., in systemd service files): Environment=MAX_CPU=500% --- repro.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/repro.in b/repro.in index 11f8eea..9886d16 100755 --- a/repro.in +++ b/repro.in @@ -220,6 +220,7 @@ function exec_nspawn(){ ${EPHEMERAL:+--ephemeral} \ ${ISSYSTEMD242:+--pipe} \ ${MAX_MEMORY:+--property="MemoryMax=${MAX_MEMORY}"} \ + ${MAX_CPU:+--property="CPUQuota=${MAX_CPU}"} \ -E "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin" \ -D "$BUILDDIRECTORY/$container" "${@:2}" if ((EPHEMERAL)); then @@ -583,6 +584,7 @@ General Options: -d Run diffoscope if packages are not reproducible -f Use the local PKGBUILD for building -n Run makepkg with --nocheck + -C Set a CPU quota for the build container (e.g. 500% for 5 cores) -M Set an upper limit for RAM use on the build container (e.g. 12G) -V Print version information -o Set the output directory (default: ./build) @@ -594,13 +596,14 @@ function print_version() { } function parse_args() { - while getopts :hdnfM:Vo: arg; do + while getopts :hdnfC:M:Vo: arg; do case $arg in h) print_help; exit 0;; V) print_version; exit 0;; f) pkgbuild_file=1;; d) run_diffoscope=1;; n) NOCHECK=1;; + C) MAX_CPU="$OPTARG";; M) MAX_MEMORY="$OPTARG";; o) OUTDIR="$OPTARG";; *) error "unknown argument ${OPTARG}" ; print_help; exit 1;;