Skip to content

tracking(serve): Bound multi-workspace daemon resource usage #8051

Description

@doudouOUC

What would you like to be added?

Track and deliver bounded resource usage for the production qwen serve multi-workspace daemon.

The daemon currently limits registered workspaces and per-workspace sessions, but count-only limits do not bound bytes held by request bodies, WebSocket assembly, outbound delivery, replay buffers, session restore, background work, child-process output, or generation-scoped caches.

The work is split into three phases:

  1. Phase 1 adds a daemon-owned, non-waiting resource budget; bounded HTTP, WebSocket, NDJSON, event, replay, session restore, export, and process-output paths; fair heavy/spawn/process scheduling; generation-scoped workspace resource disposal; observe-only process-tree/cgroup memory status; and writer-safe, process-tree-aware shutdown.
  2. Phase 2 may add explicitly enabled aggregate RSS/cgroup admission and enforcement.
  3. Phase 3 may add opt-in idle session or runtime reclamation.

Phase 1 acceptance criteria:

  • Every production qwen serve root and managed restore path has an explicit resource owner, admission point, and release point.
  • Daemon-owned variable buffers, queues, caches, readers, and buffered child-process output have both count and byte limits.
  • Dynamic workspace removal and failed initialization release generation-scoped resources without allowing late asynchronous work to recreate them.
  • Oversized work fails with stable REST and ACP errors while the daemon remains responsive and other workspace generations remain isolated.
  • Memory observation reports process-tree and cgroup signals without triggering GC, LRU, session close, channel reclamation, or process termination.
  • Shutdown drains or aborts writers before terminating root-owned process groups and reports an unclean non-zero exit when resources cannot be verified as released.

Explicit non-goals for Phase 1 are workspace/session capacity LRU, active-session eviction, RSS-triggered destructive remediation, and a generic exactly-once operation receipt service.

Why is this needed?

A maximum workspace or session count is not a memory-safety boundary. One abnormal transcript, slow client, oversized response, unbounded child-process output, or repeated workspace register/remove churn can still exhaust the daemon and affect unrelated workspaces. Phase 1 establishes deterministic admission and failure semantics before any destructive pressure policy is considered.

Additional context

Status

Delivery tracker: #8091. Phase 1 is not complete. #8091 is the authoritative workstream checklist; this section is a concise snapshot as of 2026-08-19.

Landed

In flight

Remaining Phase 1 work

  • Complete process-tree observation for hung children, channel workers, MCP descendants, and separate cgroup current usage.
  • Finish the remaining HTTP, WebSocket, SSE, child-RPC, IPC, and other daemon-owned transport/container bounds.
  • Bound event, replay, prompt, persistence, session restore/export, workspace-supplied inputs, and buffered external-process output.
  • Add narrow per-workspace and process-wide retained-byte quotas at actual container insertion/removal points.
  • Close the remaining generation-scoped initialization, replacement, removal, cache, and background-work lifecycle gaps.
  • Finish writer-safe, process-tree-aware shutdown and unclean-exit reporting.

Phase 2 aggregate RSS/cgroup enforcement and Phase 3 opt-in idle session/runtime reclamation remain future optional work and have not started.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions