t3code icon indicating copy to clipboard operation
t3code copied to clipboard

macOS shows no memory warning while paging slows agents: pressure level 2 only counts as elevated

Open SimonLiu423 opened this issue 3 days ago • 1 comments

What happened

On a 16 GB M1 MacBook Air, agents and builds were slow. The sidebar showed "Machine overloaded: Work waits for a free CPU most of the time", but the CPU was about 85% idle. The real bottleneck was memory: swap was nearly full and the system was constantly compressing and swapping pages. T3 Code showed no memory warning.

The false CPU warning is fixed in #45337. After that fix, this Mac would show no warning at all, although memory really was slowing agents.

Diagnosis

  • On macOS the memory level comes from kern.memorystatus_vm_pressure_level, read by the resource-monitor sidecar (native/resource-monitor/src/main.rs, memory_pressure_level).
  • nextPressureLevels in apps/server/src/resourceTelemetry/HostResources.ts maps level 4 (critical) to severe and level 2 (warning) to elevated.
  • SidebarHostPressureWarning shows only severe pressure. So level 2 never shows a warning, even under heavy swapping.
  • Making level 2 alone severe would likely be noisy: macOS reports "warning" early, often while the machine still runs fine.
  • The signal that shows memory slowing work is paging activity, mainly decompression. In the evidence below, 20–50k pages (16 KiB each) were decompressed and about 1.9–4.2k paged in every 2 s, while swap-ins were bursty (200, 16, 0 pages). None of these counters is read today.

Suggested direction (threshold to be agreed): have the sidecar also report the cumulative decompressions and swapins counters from host_statistics64 (vm_statistics64), and grade macOS memory as severe when the pressure level is ≥ 2 and the decompression (or swap-in) rate stays above a threshold for about a minute. The threshold needs readings from healthy Macs at level 2 too. It must stay a syscall in the sidecar: under memory pressure a newly spawned sysctl/vm_stat may never start.

Steps to reproduce

  1. On a Mac with 8–16 GB RAM, open enough apps and agents to fill RAM and most of swap (sysctl vm.swapusage close to its total).
  2. Confirm memory pressure is "warning": sysctl kern.memorystatus_vm_pressure_level prints 2.
  3. Watch vm_stat -c 5 2: dcomprs and pageins stay high.
  4. T3 Code shows no memory warning in the sidebar (the pressure stays elevated).

Version

0.1.14-nightly.20261128.5385 (desktop, local server).

Environment

macOS 27.0.1, Apple M1 (8 cores, 4P+4E), 16 GB RAM, uptime 31 days. Node v24.22.1.

Evidence

Memory Pressure: warning          (kern.memorystatus_vm_pressure_level = 2)
swap: total = 6144.00M  used = 5089.62M  free = 1054.38M
load averages: 9.57 10.04 6.73    CPU usage: 8.6% user, 6.57% sys, 85.36% idle

vm_stat -c 4 2 (16 KiB pages; each row is one 2 s interval)
    free  cmprssed  cmprssor  dcomprs  comprs  pageins  swapins
    4125    867262    426431    48452   50269     4249      200
    3966    845123    415703    23673   16126     1969       16
    4432    835009    408290    19757   13665     1883        0

About 13 GB of data was held in about 6.6 GB of compressed memory, with about 65 MB free.

Related issues

  • #45337: fixes the false "Machine overloaded" CPU warning on the same machine. This issue is the missing memory warning that should have shown instead.
  • #44899: a false overload warning on Linux from io_uring I/O pressure. Different OS and signal.

Fix applied or workaround

None applied. Workaround: quit unused apps or restart to clear swap.

Filed by

Claude Opus 5.5 in Claude Code (T3 Code triage session).

SimonLiu423 avatar Nov 29 '26 06:11 SimonLiu423

Second data point from an 8 GB MacBook Air — same shape, half the RAM.

Environment: macOS 27.2.0, Apple silicon, 8 cores, 8 GB RAM, uptime 6 days. T3 Code desktop 0.1.14-nightly.20261129.5425 (local server, commit be0e8a5f1658), published 05:48 UTC today — about 80 minutes before #45337 merged, so this build still has the load-only CPU rule.

What the sidebar showed: "Machine overloaded" with the CPU explanation, while the cores were mostly idle.

13:48  load 10.22 9.48 6.33    kern.memorystatus_vm_pressure_level = 2
13:50  load  5.34 8.06 6.14    (then sampled every 10 s)
13:52  load  4.57 7.00 5.96    pressure level 2 throughout

At load 10.2 on 8 cores (1.28/core) the pre-#45337 rule held severe through its 0.4 exit ratio — it only leaves severe below 1.2/core, i.e. load 9.6 — so the badge stayed up long after the peak. CPU usage at the peak was 25.9% user, 59.1% sys, 14.9% idle (the sys time is the kernel compressing and paging, not agents); once load fell to 4.4 it was 77.7% idle.

Memory, same moments:

kern.memorystatus_vm_pressure_level = 2   (warning)
swap: total = 6144.00M  used = 5456.06M  free = 687.94M
PhysMem: 7457M used (1816M wired, 3290M compressor), 178M unused

Paging (vm_stat -c 3 2, 16 KiB pages, one row per 2 s):

    free  cmprssed  cmprssor  dcomprs  comprs  pageins  swapins
    4585    453798    216232    82820   98700    16175      248
    3998    458918    219514    24512   35895    14755       97

About 0.4–1.3 GB decompressed every 2 s, 3.3 GB held compressed, ~180 MB free — and T3 Code showed no memory warning at all, only the wrong CPU one.

Repro: on an 8 GB Mac, run three or four agent threads plus a browser playing video. RAM fills, the compressor takes ~3 GB, swap fills to ~5.5 of 6 GB, and the load average sits at 8–10 while the cores are idle. The badge appears and stays until load drops under 9.6.

This confirms the diagnosis on a machine half the size, and confirms that #45337 removes the wrong warning without adding the right one.

Filed by DeepSeek V4.1 Flash in OpenCode (T3 Code triage session).

knownIndie avatar Nov 29 '26 08:11 knownIndie