← Back to lab

22 Type-Checkers Outlived the Job. Load Sat at 136 for 8 Hours.

A timed-out harvest job left 22 tsc processes in an anonymous systemd scope. The user slice sat at MemoryHigh from 00:31 to 08:32 UTC and load hit 136.

22 Type-Checkers Outlived the Job. Load Sat at 136 for 8 Hours.

Model: none | Date: 2026-12-04 | Load: 136 | Status: scopes are named and stopped

A job timeout killed the agent. It did not kill the type-check. One turbo type-check kept running as 22 tsc processes, and the user slice sat at MemoryHigh from 00:31 to 08:32 UTC. Recorded load: 136.

The runner already had a session cap. The comment on that constant says the p99 of real runs is about 72 minutes, and the cap itself is 4 hours. Neither number matters if the compiler is not in the process tree you stop.

The timeout stopped the wrong pid

Agent sessions on this box are started with systemd-run --user --scope. A scope is a cgroup. Kill the scope and every process in it dies, including the compilers and browsers the agent forked. Kill only the agent pid and those children get reparented and keep the cores.

The scope that held this type-check was anonymous. No unit name. When the harvest job hit its timeout, the exit path had nothing to pass to systemctl stop. The agent was gone. turbo and 22 tsc processes were not. The incident note is the source of the 22. I do not have a separate ps snapshot, and I am not going to invent an RSS figure for them.

That is a different failure from a cgroup that is merely over memory.high. Here the throttle was real — the slice stayed at MemoryHigh for 8 hours 1 minute — and the cause was a process tree the timeout could not name.

At 08:28 UTC, while the slice was still at the high line, the janitor log read MemAvailable 4,036 MB and PSI full (10-second average) 89%. Samples from 08:16 to 08:28 sit in a band: available memory 4,036–4,540 MB, PSI full 83–90%. At 08:41, after the slice had left MemoryHigh at 08:32, the same log read 7,707 MB available and PSI full 0. The 11 leftover scopes below were still alive at that 08:41 sample. They are not the stall.

What else the census found

The fix for the runner was to name the scope and stop it. The same morning the janitor learned to reap agent scopes whose CLI is already gone. First pass was a dry run, 08:41:22 UTC. It listed 11 scopes. The real stop, 40 seconds later, listed the same 11. Ages below are from the dry run.

Age

Processes

Left running

845,019 s (9.8 d)

1

bwrap

311,985 s (3.6 d)

1

headless browser

301,127 s (3.5 d)

1

headless browser

299,436 s (3.5 d)

2

headless browser

277,819 s (3.2 d)

1

headless browser

266,781 s (3.1 d)

2

headless browser

235,165 s (2.7 d)

1

headless browser

230,976 s (2.7 d)

1

headless browser

194,249 s (2.2 d)

3

headless browser

13,244 s (3.7 h)

1

headless browser

9,675 s (2.7 h)

1

node

15 processes. Oldest scope 9.8 days. The decision log compressed that to "11 days-old leftovers." The log is the better number: 11 scopes, not an age of 11 days.

Stopping them moved MemAvailable from 7,707 MB to 7,155 MB. About 550 MB. Useful garbage collection. Not an 8-hour stall. The stall was the type-check that had no unit name.

The reaper's rule is narrow on purpose. A scope matches only if its unit is a session scope (cui-*, harvest-*) or an older anonymous run-r* whose description is an agent command. It stops the scope only when no agent binary is still in cgroup.procs and the oldest process is at least 300 seconds old. Render scopes are left alone. Grace of 300 seconds is AGENT_SCOPE_GRACE_SECS.

The stop path

A named scope is stoppable. The runner now wraps every session:

systemd-run --user --scope --quiet --collect \
  --unit="cui-${id}-${ts}.scope" \
  -p MemoryHigh="${SESSION_MEMORY_HIGH:-2G}" \
  -p MemoryMax="${SESSION_MEMORY_MAX:-4G}" \
  -p TimeoutStopSec=15 \
  -- "$agent" "$@"
# CLI exit, including the job timeout:
systemctl --user stop --no-block "$unit"

TimeoutStopSec=15 is the gap between SIGTERM and SIGKILL for everything still in the scope. MemoryMax=4G is the hard cap on that one session. MemoryHigh=2G is the throttle. Defaults, overridable by those two env vars. The harvest dispatcher uses the same shape with a tighter soft line: MemoryHigh=3G, MemoryMax=4G, same 15-second stop timeout, unit name harvest-<job>-<timestamp>.scope.

systemctl stop from the exit path is best-effort. If the user bus is missing, the janitor is the second stop. That is why the reaper exists instead of trusting the exit hook.

The dispatcher also refuses to start work while the box is already stalling:

PSI_FULL_MAX, AVAIL_MIN_MB = 20.0, 3072

if psi_full_avg60 > PSI_FULL_MAX or mem_available_mb < AVAIL_MIN_MB:
    ledger(event="skip_pressure")  # do not dispatch

PSI full avg60 comes from the user slice's memory.pressure. MemAvailable comes from /proc/meminfo. Either gate is enough to skip. On the morning of the incident the 10-second PSI full was 83–90%, so an avg60 above 20% is a low bar. The point of the bar is to stop adding agents while one orphan is already pinning the slice.

One repo's type-check script is now turbo type-check --concurrency=2. That caps fan-out for the next person who runs the whole graph. It does not cap RSS, and it would not have stopped a tree that had already been orphaned.

What the numbers say

Fact

Source value

Orphan

1 turbo type-check, 22 tsc (incident note)

Slice at MemoryHigh

00:31–08:32 UTC (8 h 1 min)

Load

136

PSI full 10s, 08:16–08:28

83–90%

MemAvailable, 08:28 → 08:41

4,036 MB → 7,707 MB

Scopes reaped at 08:42

11 (15 processes, oldest 845,019 s)

MemAvailable after that reap

7,155 MB

Session MemoryHigh / MemoryMax

2G / 4G

Harvest MemoryHigh / MemoryMax

3G / 4G

Stop timeout

15 s

Reap grace

300 s

Dispatch skip

PSI full avg60 > 20, or MemAvailable < 3,072 MB

The 4,036 → 7,707 MB step lines up with the slice leaving MemoryHigh. I am not assigning that 3.7 GB to tsc alone. Other reaps were running in the same window. What the counters do show: PSI full went from ~89% to 0 across that step, and the 11 old scopes were still present when available memory was already 7.7 GB.

What I'd change

MemoryMax on the scope contains the damage to one session. It does nothing for a scope you cannot name, which is the bug that actually fired. The 300-second grace is long for a compiler that forks in the first second and short enough for a browser that is mid-navigation. I would reap a scope with no agent pid and a tsc or turbo in cgroup.procs immediately, and keep the 300 seconds for browsers and dev servers. --concurrency=2 stays. It is a fan-out limit, not a memory limit, and pretending otherwise is how this job got scheduled on a quiet box and died on a loud one.