fix(apple): pin C locale for perf ps reads on macOS

PC
6h ago
+51-4

Summary

perf on macOS reads CPU and memory from ps -axo pid=,%cpu=,rss=,command=. BSD ps formats %cpu with the host LC_NUMERIC, so under de_DE, fr_FR or es_ES it prints 12,5. parseApplePsOutput only accepts a . decimal, so every row is dropped and the app process is never found.

The host ps reads in perf-target.ts now pass envOverrides: { LC_ALL: 'C.UTF-8' }, the same pin host-process.ts already uses for its ps reads (and the same fix #4682 applied to lstart). The parser also accepts a comma decimal, for reads that cannot be pinned, such as simctl spawn ps.

Before / after

ps row under LANG=de_DE.UTF-8: 123 12,5 45678 /Applications/Test.app/Contents/MacOS/Test

before: parseApplePsOutput -> []   (perf finds no process)
after:  parseApplePsOutput -> [{ pid: 123, cpuPercent: 12.5, rssKb: 45678, ... }]

Validation

  • Tested at 41ac39e. Two new tests in perf-target.test.ts: comma-decimal parsing, and the locale pin on the macOS ps call. Both fail on main and pass with the fix.
  • vitest run on perf-target.test.ts and perf.test.ts passes (27 tests). oxfmt --check and tsc --noEmit are clean.
  • No macOS device run; the change only affects the ps environment and parsing.

This change was prepared with AI assistance.


Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.