macOS: setStableProcessTitle() runs every 5 s → one LaunchServices check-in per session every 5 s (launchservicesd CPU)
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, macos, node.js
- 领域
- cli, performance
调研方向
阅读 issue 中展示的 writeTitle() 和 setStableProcessTitle() 代码,然后追踪 useTerminalTitle 在哪里安排 reassertTerminalTitle()。在 macOS 上检查最小 Node 复现,以确认重复赋值会触发 check-in。完成标准是:无需重复赋值进程标题,仍可每 5 秒重新设置终端标题,并且复现中不再出现周期性 check-in。
由索引模型根据 Issue 内容生成。
描述
Summary
Since the fix for #764 (v1.50.1), the process title is stable (command-code) — thanks.
But writeTitle() calls setStableProcessTitle() on every call, and
useTerminalTitle re-asserts the terminal title every 5 s:
function setStableProcessTitle(){process.title="command-code"}
function writeTitle(e){setStableProcessTitle(),process.stderr.isTTY&&process.stderr.write(SN(e))}
function reassertTerminalTitle(){null!==wN&&writeTitle(wN)}
// useTerminalTitle:
const e=setInterval(reassertTerminalTitle,5e3)
On macOS, every process.title assignment goes through libuv's darwin
proctitle code, which checks the process in with LaunchServices. lsd logs
pid N registering self and the check-in is rejected with -10811
(kLSNotAnApplicationErr), but launchservicesd still does the work (code
signature validation) each time. So every interactive session costs one
LaunchServices check-in every 5 s, forever, idle or not, even though the
value never changes.
Impact (measured)
macOS 26.6 (25G72), Apple Silicon (M5 Max, 18 cores), Node v24.21.0 arm64,
Command Code 1.79.1, ~20–30 interactive sessions open in a terminal multiplexer:
- 12 check-ins / min per session, constant (10-min idle window: 119–120 per session).
- 45-min audit:
launchservicesdwas the #1 CPU consumer of the machine:
353 % average, 433 % p95 (≈3.5 cores); 84 of 87registering self
events per probe window came from Command Code processes. - Controlled experiment with throw-away sessions (
--no-session, no prompt sent):
baseline 257 % → +4 sessions 316 % → +8 sessions 362 %launchservicesdCPU
(≈12–15 % of a core per session, ≈0.7 s oflaunchservicesdCPU per check-in).
Those throw-away sessions ran Node x86_64 under Rosetta; arm64 sessions show
the same 12 / min cadence.
Minimal repro (no Command Code needed)
node -e 'setInterval(()=>{process.title="command-code"},5000)' & A=$! # rewrite every 5 s
node -e 'process.title="command-code"; setInterval(()=>{},5000)' & B=$! # write once
sleep 42
log show --last 40s --style compact \
--predicate 'process == "lsd" AND eventMessage CONTAINS "registering self"' > lsd.txt
grep -c "pid $A registering self" lsd.txt # → 8
grep -c "pid $B registering self" lsd.txt # → 0
kill $A $B
With Command Code itself: start one session in a terminal, then
log stream --predicate 'process == "lsd" AND eventMessage CONTAINS "registering self"'
shows its pid every 5.000 s.
Suggested fix
Only write the process title when it changes, e.g.
function setStableProcessTitle(){ if (process.title !== "command-code") process.title = "command-code" }
or call it once at startup instead of inside writeTitle(). The OSC terminal
title write can stay on the 5 s interval — it does not touch LaunchServices.
Local workaround (until a release)
A user mod in ~/.commandcode/mods/ that performs the native write once and
then backs process.title with a plain JS property removes the check-ins
(same loop: 8 → 0 per 40 s; ps still shows command-code). It only takes
effect after a session's first message (mods load with the harness).
- 主要语言
- 没有语言数据
- 星标
- 4.1k
- 派生
- 363
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
CommandCodeAI/command-code 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
CommandCodeAI/command-code#992 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
CommandCodeAI/command-code#933 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
CommandCodeAI/command-code#855 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
CommandCodeAI/command-code#841 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
CommandCodeAI/command-code#655 · 1 条评论 ·
查看 CommandCodeAI/command-code 的全部 Issue
相似的 Issue
-
command: monitor command: update info: steamcmd reproducible: always severity: medium type: bug
难度 2/5 1-3 小时 新手友好度 82/100
GameServerManagers/LinuxGSM#4997 ·
维护者通常 1 天内回复
-
good first issue track:code
难度 1/5 1 小时以内 新手友好度 88/100
Sara-Managed-Projects/space-radar#781 ·
维护者通常 1 天内回复
-
area: google drive enhancement good first issue
难度 2/5 1-3 小时 新手友好度 66/100
bilalkumrani/sirgal#21 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
Textualize/textual#6732 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 62/100
Sendspin/sendspin-python-cli#291 ·
维护者通常 6 天内回复