Skip to content

feat(worker-budget): idleSuspendMode=always 闲置即挂起,支持 per-bot 覆盖#184

Open
baicaicc wants to merge 2 commits into
fix/worker-budget-multi-daemonfrom
feat/idle-suspend-always
Open

feat(worker-budget): idleSuspendMode=always 闲置即挂起,支持 per-bot 覆盖#184
baicaicc wants to merge 2 commits into
fix/worker-budget-multi-daemonfrom
feat/idle-suspend-always

Conversation

@baicaicc

Copy link
Copy Markdown
Collaborator

预算模式(默认)只在 live worker 超过 maxLiveWorkers 时修剪超额部分,
一次性场景(如报警归因 bot:每条报警开一个话题/进程,出结论后基本
不再活跃)会让闲置进程在预算内无限驻留。新增 idleSuspendMode:

  • 'budget'(默认):维持原行为,仅超预算时挂起最久闲置的 worker
  • 'always':闲置 ≥ idleSuspendMs 即挂起、不看预算;会话保持 active, 话题里来新消息走 worker-null resume 路径自动带上下文复活

配置面:

  • 全局:botmux worker-budget set --idle-suspend-mode always|budget, status 显示当前模式
  • per-bot:bots.json 条目加 worker 字段逐项覆盖全局(一 bot 一 daemon, 天然只影响该 bot),如归因 bot 配 always + 短阈值,常驻 bot 不受影响
  • sweeper 的挂起 reason 区分为 idle_suspend_always / idle_worker_budget

zhubowen.cc added 2 commits June 11, 2026 16:22
多 daemon 部署(一 bot 一进程)下,每个 daemon 都按整机 cpu/内存独立推导
maxLiveWorkers(如 56C/110G 机器 6 bot = 6×32=192),机器级上限被静默放大
N 倍,idle sweeper 形同虚设。改为机器预算 ÷ bots.json bot 数后再 clamp:

- autoMaxLiveWorkers/resolveWorkerBudget 增加 daemonCount 参数(默认 1,
  单 bot 行为不变)
- bot-registry 新增 countConfiguredBots():mtime 缓存读共享 bots.json,
  CLI 一次性进程无注册表时回退 registry 大小
- idle sweeper 与 worker-budget status/set 传入实际 bot 数;status 的
  auto baseline 行展示 daemons 分母
预算模式(默认)只在 live worker 超过 maxLiveWorkers 时修剪超额部分,
一次性场景(如报警归因 bot:每条报警开一个话题/进程,出结论后基本
不再活跃)会让闲置进程在预算内无限驻留。新增 idleSuspendMode:

- 'budget'(默认):维持原行为,仅超预算时挂起最久闲置的 worker
- 'always':闲置 ≥ idleSuspendMs 即挂起、不看预算;会话保持 active,
  话题里来新消息走 worker-null resume 路径自动带上下文复活

配置面:
- 全局:botmux worker-budget set --idle-suspend-mode always|budget,
  status 显示当前模式
- per-bot:bots.json 条目加 worker 字段逐项覆盖全局(一 bot 一 daemon,
  天然只影响该 bot),如归因 bot 配 always + 短阈值,常驻 bot 不受影响
- sweeper 的挂起 reason 区分为 idle_suspend_always / idle_worker_budget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant