Expand description
What a runner’s process tree uses right now: resident memory and CPU time summed over a root process and every descendant (coordinator stage 4, job weight statistics).
One call is one cheap look, taken every few seconds by the daemon off its reconcile loop:
- Linux reads
/proc/<pid>/statfor every process (parent, CPU ticks, resident pages). A native runner does not get a cgroup of its own, so the tree is the unit. - macOS lists every PID (
proc_listallpids), reads each parent (PROC_PIDT_SHORTBSDINFO, which any account may read, so asudostep keeps its place in the tree) and, for the tree,PROC_PIDTASKINFO(resident size, user and system time in Mach ticks). - Windows takes one Toolhelp snapshot for the parent links and, for
the tree,
GetProcessMemoryInfo(working set) andGetProcessTimes. A native runner is not started inside a Job Object, so there is no job accounting to read. Toolhelp keeps a dead parent’s PID, which Windows soon hands to another process, so a child created before its supposed parent is not counted as its child.
The CPU total of a tree drops when a descendant exits (except on Linux,
which folds a reaped child into its parent’s cutime/cstime); the
caller adds up the increases between looks, so at most a look’s worth of
an exiting process’s time is lost. A process this account may not
inspect counts as using nothing. Work that leaves the tree is not seen:
containers run by dockerd, and daemons that detach (a Gradle daemon, a
nohup server) and are re-parented to init.
Structs§
- Tree
Usage - One look at a process tree.
Functions§
- sample_
tree - The tree under
root,rootincluded, orNonewhenrootis gone. - sample_
trees - The trees under each of
roots, from one look at the process table: a root that is gone has no entry.