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 52152f7
Browse filesBrowse the repository at this point in the historyBrowse files
fix(skills/bounding-heavy-commands): stop a first measurement from holding the whole queue where the hard cap protects the machine
A measurement with no --memory reserved every slot of the queue, so no other heavy command on the machine could start while it ran. Where the hard cap is usable, that buys no safety: a command that passes its budget is stopped with exit code 137 and the machine does not swap. One observed first measurement held a 20 GiB queue while it used under 1 GiB.
Where the cap is usable, a first measurement, and the largest row of --measure-rows with no --memory, now reserves the slots of the default budget and runs with that budget as its cap. Where there is no cap, it still takes the whole queue. The cap probe runs before this choice, with the default budget, which is the budget of the capped run.
The skill and the README now say which case takes the whole queue, and a first measurement that the cap stopped is measured again at two times the default budget, up to the whole queue.
Fixes#60
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,7 +117,7 @@ A local path also works for development: `/plugin marketplace add /path/to/featu
117
117
118
118
No further setup is required; the skills derive your repo and build commands from context. Optionally, paste [`templates/project-CLAUDE.md`](templates/project-CLAUDE.md) into your project's `CLAUDE.md` to give every session the workflow overview and the operational rules (commit conventions, safe git staging, GitHub-mutation confirmation).
119
119
120
-
Keep project memory on to get the most from `bounding-heavy-commands`. In Claude Code that is auto memory, which is on by default. The skill saves the measured memory budget and the bounded command line of each heavy command there, so a later session starts with them. With memory off, each session measures the commands again, and each first measurement runs alone in the queue, so the sessions wait for each other more often. A command that a session did not measure runs under the default budget, which can be less than the command needs.
120
+
Keep project memory on to get the most from `bounding-heavy-commands`. In Claude Code that is auto memory, which is on by default. The skill saves the measured memory budget and the bounded command line of each heavy command there, so a later session starts with them. With memory off, each session measures the commands again, and each first measurement holds the default budget, or runs alone in the queue where there is no hard cap, so the sessions wait for each other more often. A command that a session did not measure runs under the default budget, which can be less than the command needs.
|`--memory <budget>`| Memory the command may use, such as `6G` or `4096M`. Taken from the record. Without it the wrapper uses its default budget, a quarter of the machine's memory, or the whole queue for a measurement. |
43
+
|`--memory <budget>`| Memory the command may use, such as `6G` or `4096M`. Taken from the record. Without it the wrapper uses its default budget, a quarter of the machine's memory. A measurement without it takes the whole queue where there is no hard cap. |
44
44
|`--cpus <n>`| Processor limit, as a whole number. Taken from the record. |
45
45
|`--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. |
46
-
|`--measure`| Also print a suggested budget. Discovery uses it. With no `--memory`, the command runs alone in the queue. |
47
-
|`--measure-rows <n>,<n>,...`| Measure the command one time at each `--cpus` of the list, one after the other, the largest first. The largest runs with the `--memory` of the call. With no `--memory`, it runs alone in the queue. Each smaller one runs with `--memory` at the suggested budget of the one before it. When the one before it did not exit 0, the smaller one runs with the same `--memory` as that one. Use it in place of `--cpus` and `--measure`. A stop signal ends the list. The exit code is the first exit code of a row that is not 0. |
46
+
|`--measure`| Also print a suggested budget. Discovery uses it. With no `--memory`, the command runs with the default budget where the hard cap is available, and alone in the queue where it is not. |
47
+
|`--measure-rows <n>,<n>,...`| Measure the command one time at each `--cpus` of the list, one after the other, the largest first. The largest runs with the `--memory` of the call. With no `--memory`, it runs with the default budget where the hard cap is available, and alone in the queue where it is not. Each smaller one runs with `--memory` at the suggested budget of the one before it. When the one before it did not exit 0, the smaller one runs with the same `--memory` as that one. Use it in place of `--cpus` and `--measure`. A stop signal ends the list. The exit code is the first exit code of a row that is not 0. |
48
48
|`--label <name>`| A name for the row lines of a measurement, such as `unit-tests`. Use letters, digits, `.`, `_`, and `-`, and start with a letter or a digit. It changes nothing else. |
49
49
|`--check`| Run no command. Print the state of the queue now, and for each `--memory`, whether a command of that budget would start now. It takes only `--memory`, which you can repeat. It holds no slot, and its exit code is 0. §The record says how to choose a row with it. |
50
50
@@ -131,14 +131,14 @@ A part of a recorded command (one test file, one target) uses the bounded comman
5. Record the suggested budget that the wrapper prints, with the peak and the date, as the row at the `--cpus` of the measurement. Record it only from a run in which the command did its full work. The suggested budget is the peak plus a margin, and the margin is larger where the measurement is approximate. A run that stopped early gives a peak that is too small: a suite that stops at its first failure, a command that failed at its start, a run that a signal or the hard cap stopped. Do not record the budget of such a run, and save no record for the command yet. Run the command with `--measure` again each time that you run it, until one run does its full work. A measurement with no `--memory` takes the whole queue, because the peak of the command is not known: it waits until no other bounded command runs, and no other starts while it runs. While it is at the head of the line, the commands behind it wait too (§Rules for the wait). When it waits, tell the user that a first measurement waits for the other bounded commands to end. If the hard cap stopped a measurement with `--memory`, measure again with two times that budget. If it stopped a measurement with no `--memory`, the command needs more memory than the queue has: tell the user, with the budget that the wrapper printed.
134
+
5. Record the suggested budget that the wrapper prints, with the peak and the date, as the row at the `--cpus` of the measurement. Record it only from a run in which the command did its full work. The suggested budget is the peak plus a margin, and the margin is larger where the measurement is approximate. A run that stopped early gives a peak that is too small: a suite that stops at its first failure, a command that failed at its start, a run that a signal or the hard cap stopped. Do not record the budget of such a run, and save no record for the command yet. Run the command with `--measure` again each time that you run it, until one run does its full work. A measurement with no `--memory` does not know the peak of the command. Where the hard cap is available, it runs with the default budget, and the cap stops it when it needs more. Where there is no hard cap, it takes the whole queue: it waits until no other bounded command runs, and no other starts while it runs. While it is at the head of the line, the commands behind it wait too (§Rules for the wait). When it waits for the whole queue, tell the user that a first measurement waits for the other bounded commands to end. If the hard cap stopped a measurement, measure again with `--memory` at two times the budget that the wrapper printed. For a measurement with no `--memory`, that is the default budget. The wrapper lowers a budget that is larger than the queue to the whole queue. If the cap stopped a measurement at the whole queue, the command needs more memory than the queue has: tell the user, with the budget that the wrapper printed.
135
135
6. Save the record.
136
136
137
137
The measured run is a real run of the command. Its result counts, also when the run stopped early, so do not run the command a second time to get the result.
138
138
139
139
### Measure the whole project
140
140
141
-
When the record does not exist (§The record, case 5), do steps 1 to 3 for every heavy command of the project. Then measure them all in one run, in place of steps 4 and 5. Do not measure only the command that you need now. A command that gets its entry later gets its first measurement in the middle of someone's work, and that measurement holds the whole queue while other sessions wait.
141
+
When the record does not exist (§The record, case 5), do steps 1 to 3 for every heavy command of the project. Then measure them all in one run, in place of steps 4 and 5. Do not measure only the command that you need now. A command that gets its entry later gets its first measurement in the middle of someone's work. That measurement holds the default budget, and where there is no hard cap it holds the whole queue while other sessions wait.
142
142
143
143
1. Choose the rows. Measure each command at three `--cpus`: all the machine's processors, half of them, and a quarter of them. Round each one down, use at least 1, and drop a value that is the same as another. A command with `self-bound: none` gets the row at half only: nothing in it reads its `--cpus`, so each row would measure the same command. A command whose next run reuses the output of the run before, such as a build or a generator with a cache, also gets the row at half only: its later rows would do less work and measure a peak that is too small.
144
144
2. Write one command line. For each command, write one call of the wrapper with `--measure-rows` and the rows that step 1 chose for it, a `--label` that names the command and no other command of the line, the `--exclusive` options of the command, and its bounded command line. Join the calls with `;`, so that a measurement that fails does not stop the others. Write the path of the wrapper in full, so that the line runs in any shell. Run it from the root of the project:
@@ -147,7 +147,7 @@ When the record does not exist (§The record, case 5), do steps 1 to 3 for every
147
147
python3 "<path of the wrapper>" --measure-rows 16,8,4 --label unit-tests -- <bounded command> ; python3 "<path of the wrapper>" --measure-rows 16,8,4 --label lint -- <bounded command>
148
148
```
149
149
150
-
3. Ask the user to run the line when the machine is quiet. Do not run it yourself unless the user asks you to. Your message names the commands and the rows that the line measures. It says that the line can take a long time, and that the first row of each command holds the whole queue, so that the heavy commands of the other sessions wait while it runs. It says how to run the line: type `! <the line>` in this session, or run it in a terminal at the root of the project, or tell you to run it.
150
+
3. Ask the user to run the line when the machine is quiet. Do not run it yourself unless the user asks you to. Your message names the commands and the rows that the line measures. It says that the line can take a long time, and that the first row of each command holds the default budget, or the whole queue where there is no hard cap, so that the heavy commands of the other sessions can wait while it runs. It says how to run the line: type `! <the line>` in this session, or run it in a terminal at the root of the project, or tell you to run it.
151
151
4. Act on the answer:
152
152
-**The user ran the line.** Read its output into the record (step 5 of this list). When the user ran it in a terminal, you cannot see the output: ask the user for each line that starts with `bounded-run: row`, and for the end of the output of each command, which shows whether the run did its full work.
153
153
-**The user tells you to run it.** Run it in the background, with no short timeout around it. Continue with work that runs no heavy command. A heavy command that you need before the line ends runs through the wrapper with no `--memory` option. When the line ends, read its output into the record (step 5 of this list).
@@ -224,8 +224,8 @@ When Python is missing or too old, and when the fault is a fault of the machine,
224
224
| "I measured the plain command, the peak is real" | It is the real peak of a command that nothing limits. Bound the command first, then measure the bounded command line at the `--cpus` that you record. |
225
225
| "The new measurement at a different `--cpus` replaces the old entry" | A different `--cpus` is a different command. Add a row and keep the others. Only a measurement at the same `--cpus` replaces a row. |
226
226
| "A smaller `--cpus` is a lower budget by another name" | A lower `--memory` on the same command is a guess. A row at a smaller `--cpus` is a smaller command with a measured budget. Use it to start sooner. |
227
-
| "I only need the unit tests now, the others get entries when an agent needs them" | Each later first measurement holds the whole queue in the middle of someone's work. When the record does not exist, measure every heavy command of the project with one command line. |
228
-
| "I'll run the measurements myself now, it saves the user a step" | The line holds the whole queue for a long time. The user chooses when the machine can give it that time. Ask, and run it only when the user tells you to. |
227
+
| "I only need the unit tests now, the others get entries when an agent needs them" | Each later first measurement holds memory in the middle of someone's work, and without the hard cap it holds the whole queue. When the record does not exist, measure every heavy command of the project with one command line. |
228
+
| "I'll run the measurements myself now, it saves the user a step" | The line holds memory of the queue for a long time, and without the hard cap it holds the whole queue. The user chooses when the machine can give it that time. Ask, and run it only when the user tells you to. |
229
229
| "Four subagents is too many for this machine, I'll dispatch two" | The queue limits the commands. Fewer subagents only makes the work slower. |
230
230
| "Project memory is off, so there is no record to keep" | Discover in this session and keep the result in context. The rule does not depend on the memory. |
231
231
| "The wrapper cannot run here, so none of this applies" | The fallback applies: one heavy command at a time, toolchain parallelism at half or less, and say so. |
log("WARNING: the reserve of %d MiB leaves no memory of the %d MiB of the machine; the queue does not keep the reserve"% (settings.reserve_mib, settings.total_mib))
0 commit comments