Skip to content

Commit 725ee05

Browse files
committed
Claim pool builds with noclobber instead of mkdir
Create the claim file with set -C, which the shell opens with O_EXCL. Ubuntu 26.04 ships uutils coreutils 0.8.0, whose mkdir can exit 0 when the kernel returns EEXIST build. uutils/coreutils#13970 uutils/coreutils#13986 The Rust kids rewrote a 50-year-old wheel and it came back square; mkdir as a mutex is older than most of them.
1 parent 1f6b99b commit 725ee05

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎build/buildTasks.nims‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ proc findSrc(g: string): tuple[files:seq[string],dirs:seq[string]] =
176176
result = (files: fs.mapIt("." / it.relativePath(d)).deduplicate,
177177
dirs: ds.mapIt("." / it.relativePath(d)).deduplicate)
178178

179-
# Worker k compiles in cache job-k and claims queued builds in order with mkdir.
179+
# Worker k compiles in cache job-k and claims queued builds in order by creating
180+
# $d/$i with noclobber (O_EXCL); uutils mkdir 0.8 can report success on EEXIST.
180181
# After a failure, workers finish their current build and claim no more.
181182
# Ctrl-C fails the running builds; the shell ignores it to wait for the workers,
182183
# so they stop writing to $d before runBuilds removes it.
@@ -189,7 +190,7 @@ while [ "$k" -lt "$n" ]; do
189190
for c in "$@"; do
190191
[ -e "$d/failed" ] && break
191192
i=$((i + 1))
192-
mkdir "$d/$i" 2>/dev/null || continue
193+
(set -C; : > "$d/$i") 2>/dev/null || continue
193194
printf 'running: %s\n' "$c"
194195
eval "$c" || printf '%s\n' "$c" >> "$d/failed"
195196
done

0 commit comments

Comments
 (0)