Skip to content

Heavy builds queue for two machine-wide slots; idle worktree builds can be listed - #302

Merged
Mpdreamz merged 1 commit into
mainfrom
ci/build-slots
Nov 19, 2026
Merged

Mpdreamz merged 1 commit into
mainfrom
ci/build-slots

Conversation

@Mpdreamz

Copy link
Copy Markdown
Contributor

The local half of the build-speed work (#300 and #301 are CI's). With several agents building at once, each swift build starts a compiler per core. The machine here (8 cores, 16 GB) sat at a load of 20 to 60 with 5 of 6 GB of swap used while four or five agents compiled.

Changes

  • scripts/slot.sh CMD... runs a command in one of two slots shared by every worktree. A slot is a directory holding its owner's pid (no flock on macOS's bash 3.2). A waiter prints who is building; a killed owner's slot is taken over, including one that died before writing its pid. HEED_BUILD_SLOTS=N sets the count and 0 turns it off. mise run test | check | build | bundle | bench | live, text-check and ghostty go through it. The test run itself (about 25 s) does not take a slot.
  • scripts/prune-worktree-builds.sh [DAYS] lists worktrees whose .build is idle with sizes, skipping the main checkout and any worktree building right now. It deletes only with --delete.

Findings that shaped it

  • Seeding a new worktree with a copy-on-write clone of another's .build does not work: the clone took 587 s and 77 build steps at a different path, a full rebuild. Swift Build ties its state to the absolute path, so there is nothing to share between worktrees and the only lever is not keeping idle ones.
  • This machine: 35 worktrees are idle 3 days or more and hold 90 GB of .build (listed, not deleted).

Verified

  • slot.sh, with HEED_SLOT_DIR pointed at a scratch directory: with two slots a third job waited for one to free (6 s) and said so; the command's exit status passes through (7); after kill -9 on both holders a new job took a slot at once; HEED_BUILD_SLOTS=0 runs directly. mise run test goes through a slot (no-op build plus the filtered tests, 19 s).
  • Not verified: the count of 2 is a judgement for this machine, and I have not measured total throughput with several agents queued. The pid-less dead-owner path (freed after a minute) was written but not exercised.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the chore Maintenance label Nov 19, 2026
…ds can be listed

Every `swift build` assumes it owns the machine and starts a compiler per core. With several agents building at once an
8-core, 16 GB machine sat at a load of 20 to 60 with 5 of 6 GB of swap used, and each build took several times longer
than it would alone.

- scripts/slot.sh runs a command in one of two slots shared by every worktree (a directory per slot holding its owner's
  pid, no flock on macOS's bash 3.2). A waiter says who is building; a killed owner's slot is taken over, including one
  that died before it wrote its pid. `HEED_BUILD_SLOTS=0` turns it off. test, check, build, bundle, bench, live, text-check
  and ghostty go through it.
- scripts/prune-worktree-builds.sh lists worktrees whose .build is idle (default 3 days) with their sizes, and deletes only
  with --delete. Swift Build ties its state to the absolute path (a cloned .build in another worktree rebuilt in full:
  587 s), so an idle .build cannot be shared or moved, only not kept.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@Mpdreamz
Mpdreamz merged commit 8c2ffc7 into main Nov 19, 2026
5 checks passed
@Mpdreamz
Mpdreamz deleted the ci/build-slots branch November 19, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant