Repository navigation
perf(memory): read macOS footprints with a bundled helper instead of top - #34053
Conversation
…lper instead of top top costs ~263 ms of CPU per sample, so the memory panel only refreshed footprints every 10 s. The new orca-process-footprint helper reads phys_footprint for every same-user process in ~3 ms, so footprints now refresh on the panel's 2 s poll. top stays as the fallback when the helper is missing or fails.
Walkthrough
Priority: Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
0edb372a-80ea-4011-9dca-be9a27e0059f
Files selected for processing: 11-
config/electron-builder.config.cjsconfig/scripts/build-keyboard-layout-macos.mjsconfig/scripts/build-native-for-platform.mjsconfig/scripts/build-native-for-platform.test.mjsconfig/scripts/build-process-footprint-macos.mjsconfig/scripts/run-electron-vite-dev.mjsconfig/scripts/swift-cli-helper-macos.mjsnative/process-footprint-macos/main.swiftpackage.jsonsrc/main/memory/collector-darwin-footprint.test.tssrc/main/memory/darwin-process-footprint.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
| if (cache) { | ||
| return cache.footprints |
There was a problem hiding this comment.
Fall back after repeated helper failures.
If the helper succeeds once and then fails on every sample, this branch returns the same cached footprints forever. The helper remains selected, so the collector never tries top and the memory reading stops updating. Keep the cached sample for a transient failure, but switch to top after repeated failures or a bounded stale period.
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
上游 v1.4.243(stablyai#34053)新增 macOS helper orca-process-footprint,fork 的 Makefile computer-use target 沒建它;ad-hoc 的 PR 建置缺 helper 不會紅,只有 Developer ID 正式建置會丟錯,v1.4.243-fork.1 因此發版失敗。新增 fork-mac-helpers.mjs(進 fork-check-lint):上游 build:mac:release 跑的每個 build:*-macos,computer-use target 都要有,下次上游再加 helper 會在本機閘門與 PR CI 就紅。
Summary
Follow-up to #33901. The memory panel's macOS footprint now comes from a small bundled Swift helper (
orca-process-footprint) that callsproc_pid_rusagefor every same-user process. Previously it came from/usr/bin/top.topdoes a system-wide sample that costs about a quarter-second of CPU no matter which PIDs are asked for, so #33901 had to cache it for 10 s. The helper is about 90× cheaper per sample. Memory figures now refresh on the panel's normal 2 s poll, and the panel uses about 18× less CPU overall.Data (M4 Air, ~460 same-user processes, ~770 total)
Per sample, 50 helper runs and 10
topruns, child CPU taken fromgetrusage(RUSAGE_CHILDREN):top -l 1 -stats pid,mem(before)orca-process-footprint(after)topto our own PIDs (-pid …), or adding-F,-Ror-n 0, made no difference; its cost is fixed.app.getAppMetrics()reports RSS on macOS, not footprint, so it can't replace this.top(for example 454070088 B vstop's 433M for the same PID), and it still works when signed with the hardened runtime.How it ships
The helper follows the
orca-keyboard-layoutpattern:build:process-footprint-macos. That script runs frombuild:native(which the release, daily and hourly macOS workflows use) and frombuild:mac/build:mac:release.extraFilesputs it atContents/MacOS/orca-process-footprint, andafterPacksigns it withsignMacStandaloneHelper. A release build without it fails, just like the keyboard helper.swift-cli-helper-macos.mjs. The output is the same as before; this also keeps the dev runner under its line limit.Fallbacks
topwith the existing 10 s cache.toppermanently.topalready followed.topalso unavailable: RSS, unchanged from before.Merge risk
Low to medium. The runtime change is small and every failure path falls back to today's behavior. The risk is in packaging: a new signed binary goes into
Contents/MacOS, so the first release or notarization run with it is the real check. If signing is wrong, the release fails loudly instead of shipping silently.User-facing trade-offs
None. Memory figures are fresher (2 s instead of up to 10 s old) and the panel uses less CPU.
Tests
collector-darwin-footprint.test.ts: the helper is preferred andtopis not run when the helper is present; a failing helper falls back totop. The existingtopand RSS cases are kept.build-native-for-platform.test.mjs: now expects four parallel macOS native builds.pnpm check:changedpasses with all 36 checks.