Skip to content

local-efficiency 0.13.0: host-run lends idle CPU permits and keeps long runs off the CI Mac - #41

Merged
0thernet merged 3 commits into
mainfrom
host-run/lend-idle-permits-1128
Nov 28, 2026
Merged

0thernet merged 3 commits into
mainfrom
host-run/lend-idle-permits-1128

Conversation

@0thernet

Copy link
Copy Markdown
Member

What changes

Idle permits are lent. When every CPU permit is held, a shared or heavy run that has waited 20 seconds may borrow permits from a second pool of the same size. host-run measures the host every 15 seconds and lends only while the cores the run would use, plus 20% of all cores, were idle, and at least 25% of memory is free. A loan admitted in the last 90 seconds counts at its full share until a measurement includes it. Long, mostly idle holders (soaks, emulators, dev loops) no longer keep every other run queued while most cores sit idle.

  • An exclusive run never borrows. A run that takes every CPU permit also takes every borrowed permit before it starts, so it still runs alone.
  • --status shows borrowed=N and marks borrowing holders pool=overflow; telemetry records pool: "overflow".
  • LOCAL_EFFICIENCY_LENDING=off turns lending off for a run.

Long runs stay on this Mac. A forwarded run holds the remote's CI machine lock for its whole run. A heavy run whose --max-hold is over an hour (or none) now runs here with one line saying why, and --remote refuses it with exit 69. Before this, a forwarded soak could hold the lock for hours, and CI steps that need that Mac to themselves timed out waiting for it.

One test fix. The background-priority test compared against normal priority, so the check failed whenever the whole suite ran at background priority, as it does under host-run while the owner is typing. It now compares against the priority the suite inherits.

Checks

  • bun test lending.test.ts (14 tests: the lending decision and its thresholds, the status and telemetry fields, and end-to-end runs that borrow, wait, fall back and drain)
  • bun test compute-forward.test.ts (the hold limit, --remote refused before any ssh, a 9 h run kept here)
  • bun run check under host-run --mode=heavy --local: 302 pass, 0 fail

🤖 Generated with Claude Code

0thernet and others added 3 commits November 28, 2026 02:01
When every CPU permit is held, a shared or heavy run that has waited 20
seconds may borrow permits from a second pool of the same size, while the
cores it would use plus 20% of all cores are idle and at least 25% of
memory is free. It keeps its place in the ordinary queue until a loan
admits it. Exclusive runs never borrow, and a run that takes every CPU
permit takes every borrowed permit before it starts.

On an 18-core workstation, four overnight soak runs held 4 of 6 permits
for hours while using about 1.1 cores between them. The CPU was 61%
idle, and runs on that host had waited 1,556 minutes in the previous 24
hours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A forwarded run holds the remote's CI machine lock for its whole run. A
heavy run with --max-hold over an hour (or none) now stays on this Mac
with one line saying why; --remote refuses it with exit 69. Before this,
a forwarded soak held the lock for hours, so CI steps that need the Mac
alone timed out on their lock wait while the Mac sat mostly idle.

The background-priority test now compares against the priority the suite
inherits, so the check passes when it runs at background priority, as it
does under host-run while the owner is typing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A heavy run forwarded without --max-hold now gets an hour on the remote,
  so no forwarded run holds the remote's CI machine lock for longer.
- A run that takes every CPU permit records that it is waiting, and no new
  loan starts meanwhile, so later runs cannot overtake it by borrowing.
- When the borrowed-permit pool cannot be used, such a run runs on its own
  permits with a warning instead of failing.
- Tests no longer assume six permits: on 2-permit hosts a heavy run takes
  every permit and so also takes every borrowed one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@0thernet

Copy link
Copy Markdown
Member Author

Independent review: two findings fixed in ea98aeb (a forwarded run with no hold now gets an hour there; a run that takes every permit records that it waits, so no new loan overtakes it, and it runs on its own permits when the borrowed pool cannot be used). Accepted as low: two runs sampling in the same 15 s window can both borrow (the pool size still caps borrowing at one extra pool); after a rollback to 0.12.0 its throughput report rejects events carrying pool until they age out, while scheduling is unaffected.

@0thernet
0thernet merged commit 1f4c3f6 into main Nov 28, 2026
7 checks passed
@0thernet
0thernet deleted the host-run/lend-idle-permits-1128 branch November 28, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant