Answer prose round 1: 0 🔴, 9 🟡; reword the decision, the rule's help, run-heavy's help and the reviewer's step 4, and drop -h from the light flags

This commit is contained in:
2026-10-23 11:45:53 +02:00
parent 2d2371766d
commit 203049f4c3
12 changed files with 22 additions and 25 deletions
+5 -8
View File
@@ -3,11 +3,11 @@
usage: run-heavy <command> [<arg>...]
A heavy command is one that loads the machine for minutes: a full gate, mutation tests, an e2e run,
a docker build. The machine has one heavy slot per 4 CPUs it may run on, and at least one, shared by every
a docker build. The machine has one heavy slot for every 4 CPUs that run-heavy may use, and at least one, shared by every
session that runs run-heavy. Each slot is a file locked with flock, under
$XDG_STATE_HOME/run-heavy (default ~/.local/state/run-heavy). While every slot is held, run-heavy
says so once on stderr and waits. It then runs the command in its place, which holds the slot until
it and every process that inherited the lock exit. Its exit code is the command's.
says so once on stderr and waits. It then replaces itself with the command. The slot's lock stays held
until the command, and every process that inherited the lock, exits. Its exit code is the command's.
A command it runs carries the slot's number in RUN_HEAVY_SLOT, and run-heavy called with that set
runs its command at once, so a gate that wraps its own steps cannot wait on itself.
@@ -23,11 +23,9 @@ import typing
from failure import Failure
from machine_load.slots import slot_count, slot_folder, waited_slot
# Exit codes for a command run-heavy never ran, apart from any the command exits with, as GNU env, nice and timeout use them.
OWN_FAILURE = 125
CANNOT_RUN = 126
NOT_FOUND = 127
# Names the slot a command runs in, so a heavy command it runs does not wait for a second slot.
HELD = "RUN_HEAVY_SLOT"
USAGE = "usage: run-heavy <command> [<arg>...]"
@@ -52,16 +50,15 @@ def held_slot(folder: pathlib.Path, slots: int) -> int | Failure:
"""The number of the slot this call holds, its lock left for the command to inherit, or why no slot could be taken."""
try:
folder.mkdir(parents=True, exist_ok=True)
slot, fd = waited_slot(folder, slots, lambda: print(f"run-heavy: waiting for one of the machine's {slots} heavy slots in {folder}; `fuser {folder}/slot-*` names the processes that hold them", file=sys.stderr, flush=True))
slot, fd = waited_slot(folder, slots, lambda: print(f"run-heavy: waiting for a heavy slot, of {slots} on this machine, in {folder}; `fuser {folder}/slot-*` names the processes that hold them", file=sys.stderr, flush=True))
except OSError as failure:
return Failure(f"cannot take a heavy slot in {folder}: {failure.strerror}")
# The command inherits the locked file, so the slot stays held until it exits.
os.set_inheritable(fd, True)
return slot
def run(argv: list[str], env: typing.Mapping[str, str]) -> int:
"""Runs the command in run-heavy's place; returns only where it cannot start."""
"""Replaces this process with the command; returns only where the command cannot start."""
try:
os.execvpe(argv[0], argv, env)
except FileNotFoundError: