Kill full process groups and report resource usage on macOS workers - #2634
Open
erneestoc wants to merge 1 commit into
Open
Kill full process groups and report resource usage on macOS workers#2634erneestoc wants to merge 1 commit into
erneestoc wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
macOS workers previously killed only the direct child on timeout or scheduler kill, so helper processes spawned by the action (compiler daemons, simulators, test runners) survived as orphans and slowly degraded the worker. The action is now its own process-group leader on all unix platforms (on macOS this maps to posix_spawn's POSIX_SPAWN_SETPGROUP attribute, so the fast spawn path is preserved; the standard library only falls back to fork/exec for uid/gid/pre_exec/groups/chroot), and every kill path additionally signals the whole group via kill(-pgid). The resource-usage sampler gains a macOS implementation with parity to the Linux /proc sampler: proc_listpids(PROC_PGRP_ONLY) enumerates the group and proc_pid_rusage sums resident memory per tick, keeping the per-pid latest cumulative CPU observation (converted from mach absolute time units to nanoseconds via mach_timebase_info) so already-exited members retain their CPU in the totals. ActionResourceUsage gains additive cpu_user_ns/cpu_system_ns fields, populated on macOS. Verified fails-without-fix: the new group-kill regression test leaves a backgrounded grandchild alive when the group signal is disabled and passes with it; the rusage test asserts sampled peak memory and plausible CPU time for a CPU-burning helper. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UXVtatcR9YMecBiu9RjwpC
erneestoc
force-pushed
the
ec/macos-process-group-rusage
branch
from
July 27, 2026 06:33
06cec20 to
d6f44df
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.
Problem
On macOS, NativeLink kills only the direct child of an action on timeout or
scheduler kill. Anything the action spawned below that — compiler daemons,
simulator processes, test runners — survives as an orphan, retains CPU/RAM,
and accumulates until the worker degrades. macOS workers also report no
per-action resource usage, while Linux samples peak memory (#2409).
Mechanism
macOS this maps to posix_spawn's
POSIX_SPAWN_SETPGROUPattribute — thestandard library only falls back to fork/exec for uid/gid/
pre_exec/groups/chroot, so the fast spawn path is preserved (
pre_execis onlyused under Linux namespaces).
signals the entire group via
kill(-pgid, SIGKILL)on macOS. Linuxbehavior is unchanged (namespaces already contain descendants there;
non-namespaced Linux remains issue Workers that spawn child processeses may cause zombies #225).
the Linux
/procsampler:proc_listpids(PROC_PGRP_ONLY)+proc_pid_rusagesum resident memory per tick and keep each pid'slatest cumulative CPU (converted from mach absolute time units via
mach_timebase_info), so members that exit between ticks retain theirCPU in the totals.
ActionResourceUsagegains additivecpu_user_ns/cpu_system_nsfields (populated on macOS; zero elsewhere).Verification
The group-kill regression test backgrounds a grandchild with a pgrep-able
marker, kills the action, and asserts the grandchild dies — it fails when
the group signal is disabled and passes with it. The rusage test runs a
CPU-burning helper through the full action pipeline and asserts sampled
peak memory and plausible CPU time. Suites: worker integration 37/37;
cargo check --tests --workspaceclean; bazel worker+util+proto+scheduler41/41 with clippy pedantic + nightly rustfmt aspects.
This change is