Files
magpie/internal
yetone d2e0ea393d pii: pf-serve starts with ggml's Metal residency heartbeat off (#3185)
macOS's Energy Impact puts magpie at the top while CPU stays at ~6%
(#3185). Energy Impact counts wakeups, and an idle pf-serve (the
privacy filter's llama.cpp child) woke 134-146 times a second: ggml's
Metal backend keeps a residency set alive with a heartbeat. pf-serve
stays up for 10 minutes after each masked request, so any masking user
pays that most of the day. GGML_METAL_NO_RESIDENCY=1 turns the residency
set off.

Measured with proc_pid_rusage (ri_interrupt_wkups, ri_energy_nj) on an
M4 Pro, idle pf-serve, 20s windows:
- before, pf-serve pf-v1 as magpie starts it today: 140.0 and 138.5
  wakeups/s, 2.67 mW; the user's live v0.1.1370 pf-serve child read
  134-142/s
- after, pf-serve started through pii.Find at this commit: 0.4, 0.3,
  0.3 wakeups/s, 0.02 mW
- GGML_METAL_RESIDENCY_KEEP_ALIVE_S=0 or 1 instead: 143-146/s, no help
- latency: hot requests 51-78ms either way; the first request after a
  5-60s idle spell 57-77ms before, 105-518ms after; 90s idle through
  pii.Find at this commit 56-183ms

Run at this commit:
- go test -count=1 ./internal/pii/ ok;
  TestServeStartsWithoutResidencyHeartbeat red with the env line put
  back to os.Environ() ("residency " on both starts), green with it
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/pii/ ok,
  gofmt -l clean

Also measured: current main in a sandbox HOME with clones of the real
Claude/Codex sessions and magpie cache (no logins), window open, after
warm-up: main process 1.1-2.2 wakeups/s, 0.9-1.9 mW; its WebContent
0.5/s and GPU 0.3/s. The app.js intervals and the Go tickers were read
and are already held while the document is hidden or cheap.

Not tried: the full suite (an env-only change to one package); a
logged-in instance. The user's live v0.1.1370 main process reads 69-217
wakeups/s and 25-120 mW, which the sandbox at main (no logins) doesn't
reproduce, so its source is still unknown; Vulkan/Linux pf-serve (the
variable is Metal's only and ignored there).
2026-10-25 18:40:25 +08:00
..
…
…
…
…
…