Repository navigation
Heavy builds queue for two machine-wide slots; idle worktree builds can be listed - #302
Merged
Merged
Conversation
…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
force-pushed
the
ci/build-slots
branch
from
November 19, 2026 16:23
adf6726 to
9545ec5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The local half of the build-speed work (#300 and #301 are CI's). With several agents building at once, each
swift buildstarts 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 (noflockon 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=Nsets the count and0turns it off.mise run test | check | build | bundle | bench | live,text-checkandghosttygo through it. The test run itself (about 25 s) does not take a slot.scripts/prune-worktree-builds.sh [DAYS]lists worktrees whose.buildis idle with sizes, skipping the main checkout and any worktree building right now. It deletes only with--delete.Findings that shaped it
.builddoes 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..build(listed, not deleted).Verified
slot.sh, withHEED_SLOT_DIRpointed 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); afterkill -9on both holders a new job took a slot at once;HEED_BUILD_SLOTS=0runs directly.mise run testgoes through a slot (no-op build plus the filtered tests, 19 s).🤖 Generated with Claude Code