You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e81ae76
Browse filesBrowse the repository at this point in the historyBrowse files
fix(skills/bounding-heavy-commands): count unused budgets and never start on a full machine
The wait for free memory compared the free memory now with the new budget. It ignored the part of their budgets that running bounded commands had not used yet, it trusted a reserve fixed at the start, and after BOUNDED_RUN_MEMORY_WAIT_SECONDS it started the command anyway. Together these let the queue give out more memory than the machine had (#55).
- The cap probe now prints its own cgroup. Every scope that systemd-run makes for this user with no slice option lands in the same slice, so the probe finds the siblings with no state file. The wait subtracts the sum of memory.max - memory.current over the bounded-run scopes there, skipping probe scopes, the new unit, the scope the wrapper runs in, and scopes with no limit. Without a cap or cgroup v2 nothing is subtracted, and the log says so.
- The wait also keeps a headroom of max(1 GiB, a tenth of the memory) for the programs outside the queue.
- The wait has no time limit. BOUNDED_RUN_MEMORY_WAIT_SECONDS is now the time between two "still waiting" lines. A machine whose free memory cannot be read still starts the command.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|`--exclusive <name>`| A resource that only one command may hold at a time, such as a fixed port. You choose the name. The wrapper keeps the names of each repository apart, and all worktrees of one repository share them. Repeat the option for each resource. |
42
42
|`--measure`| Also print a suggested budget. Discovery uses it. With no `--memory`, the command runs alone in the queue. |
43
43
44
-
The wrapper does four things in sequence. It waits for its turn in the queue. It waits until the memory of its budget is free. It runs the command. It prints the budget and the measured peak on the error stream. Each line that the wrapper prints starts with `bounded-run:`. Its exit code is the command's exit code. Exit code 125, with a `bounded-run:` line that names a fault and with no line for the budget and the peak, means that the wrapper itself failed (see §When the wrapper cannot run).
44
+
The wrapper does four things in sequence. It waits for its turn in the queue. It waits until the memory of its budget is free. It runs the command. It prints the budget and the measured peak on the error stream. For the wait, the free memory is the memory that the machine has free now, less the part of their budgets that the running bounded commands do not use yet, less a headroom for the programs outside the queue. The headroom is a tenth of the memory of the machine, and at least 1 GiB. The wait has no time limit: the command does not start before its memory is free, and the wrapper prints a line at intervals while it waits. Each line that the wrapper prints starts with `bounded-run:`. Its exit code is the command's exit code. Exit code 125, with a `bounded-run:` line that names a fault and with no line for the budget and the peak, means that the wrapper itself failed (see §When the wrapper cannot run).
45
45
46
46
The wrapper sets `BOUNDED_RUN_CPUS` and `BOUNDED_RUN_MEMORY_MIB` in the environment of the command, from `--cpus` and `--memory`. A recorded command line can read them and hand them to the toolchain's own parallelism and memory settings. You do not set them: you change them with the two options.
47
47
48
-
On Linux the wrapper also puts a hard cap on the command where the system allows it: a command that passes its budget is stopped with exit code 137, and the machine does not swap. Elsewhere there is no hard cap, the wrapper says so in its output, and the queue and the wait are the whole protection. When a recorded command ends with exit code 137 and the wrapper reports a peak near the budget, the cap stopped it: the command grew. Measure it again with `--measure` and `--memory` at two times the budget, and correct the record.
48
+
On Linux the wrapper also puts a hard cap on the command where the system allows it: a command that passes its budget is stopped with exit code 137, and the machine does not swap. Elsewhere there is no hard cap, the wrapper says so in its output, and the queue and the wait are the whole protection. Without the cap, the wait does not count the unused budgets of the running commands. When a recorded command ends with exit code 137 and the wrapper reports a peak near the budget, the cap stopped it: the command grew. Measure it again with `--measure` and `--memory` at two times the budget, and correct the record.
0 commit comments