Skip to content

perf(cli): Optimize serve daemon startup - #5785

Merged
doudouOUC merged 18 commits into
QwenLM:mainfrom
doudouOUC:codex/daemon-startup-fast-path
Jun 24, 2026
Merged

doudouOUC merged 18 commits into
QwenLM:mainfrom
doudouOUC:codex/daemon-startup-fast-path

Conversation

@doudouOUC

Copy link
Copy Markdown
Collaborator

What this PR does

This PR makes qwen serve reach the HTTP listener earlier by adding a slim serve fast path, deferring interactive UI, React/Ink, full settings, web-shell, and ACP runtime work until after the listener is ready or until the relevant mode needs it. It also adds daemon startup observability so /daemon/status and stderr report process-to-listen timing, runQwenServe-to-listen timing, and ACP preheat state without changing the stdout listening contract.

Why it's needed

Cold-start latency for qwen serve was dominated by modules that are not needed before the daemon can bind a port, including interactive UI and full runtime setup. Moving those imports and runtime work off the pre-listen path improves daemon responsiveness while keeping the deeper first-session ACP initialization out of scope. The added timing fields make future regressions diagnosable from both local logs and /daemon/status.

Reviewer Test Plan

How to verify

Run cd packages/cli && npx vitest run src/serve/fast-path.test.ts src/serve/run-qwen-serve.test.ts src/serve/daemon-status.test.ts src/commands/serve.test.ts src/serve/daemon-logger.test.ts and expect all 137 tests to pass. Run cd packages/cli && npx prettier --check src/serve/daemon-logger.ts src/serve/run-qwen-serve.ts src/serve/fast-path-settings.ts src/serve/run-qwen-serve.test.ts src/serve/fast-path.test.ts src/gemini.tsx src/ui/startInteractiveUI.tsx src/config/settings.ts src/config/environment.ts src/config/default-theme-names.ts and expect Prettier to report all matched files use the configured style. Run git diff --cached --check before commit, or git diff HEAD^..HEAD --check after commit, and expect no whitespace errors. Optionally run node scripts/dev.js serve --port 0 --hostname 127.0.0.1 --no-open --no-web repeatedly and confirm the stdout line remains qwen serve listening on ... while stderr includes startup timing.

Evidence (Before & After)

Earlier local baseline for external command to listener ready was approximately 3.55s p50. After this change, a local 5-run sample of node scripts/dev.js serve --port 0 --hostname 127.0.0.1 --no-open --no-web produced runs [1068, 1246, 1092, 2364, 2729]ms, p50 1246ms; daemon stderr reported process-to-listen p50 around 383ms and runQwenServe-to-listen p50 around 68ms.

Tested on

OS Status
🍏 macOS ✅ tested
🪟 Windows ⚠️ not tested
🐧 Linux ⚠️ not tested

Environment (optional)

macOS Darwin 25.4.0 arm64, Node v22.22.3, npm 10.9.8.

Risk & Scope

  • Main risk or tradeoff: the serve path now has a lightweight bootstrap app that delegates to the full runtime after listen, so the most important risk is preserving compatibility for embedded runQwenServe callers and for settings/runtime directory resolution.
  • Not validated / out of scope: full npm run typecheck is still blocked by an existing unrelated BaseTextInput.tsx issue where ink/dom and ink/components/CursorContext cannot be resolved and cursorCtx is inferred as unknown; this PR does not fix that TUI build blocker. First POST /session ACP deep optimization is also out of scope.
  • Breaking changes / migration notes: no intentional breaking changes. The stdout listening line is preserved; new startup data is additive in stderr and /daemon/status.

Linked Issues

N/A

中文说明

What this PR does

这个 PR 通过增加轻量的 serve fast path,让 qwen serve 更早到达 HTTP listener;交互 UI、React/Ink、完整 settings、web-shell 和 ACP runtime 工作会延迟到 listener ready 之后或对应模式真正需要时再加载。同时补齐 daemon 启动观测,让 /daemon/status 和 stderr 暴露 process-to-listen、runQwenServe-to-listen 以及 ACP preheat 状态,并保持 stdout listening 行不变。

Why it's needed

qwen serve 冷启动耗时主要被 listen 前不需要的模块拖慢,包括交互 UI 和完整 runtime 初始化。把这些 import 与 runtime 工作移出 pre-listen 路径,可以提升 daemon 绑定端口的响应速度,同时不把更深的首个 session ACP 初始化混入本 PR。新增 timing 字段也让后续启动回退可以从本地日志和 /daemon/status 直接定位。

Reviewer Test Plan

How to verify

运行 cd packages/cli && npx vitest run src/serve/fast-path.test.ts src/serve/run-qwen-serve.test.ts src/serve/daemon-status.test.ts src/commands/serve.test.ts src/serve/daemon-logger.test.ts,预期 137 个测试全部通过。运行 cd packages/cli && npx prettier --check src/serve/daemon-logger.ts src/serve/run-qwen-serve.ts src/serve/fast-path-settings.ts src/serve/run-qwen-serve.test.ts src/serve/fast-path.test.ts src/gemini.tsx src/ui/startInteractiveUI.tsx src/config/settings.ts src/config/environment.ts src/config/default-theme-names.ts,预期 Prettier 报告所有匹配文件符合格式。提交前运行 git diff --cached --check,或提交后运行 git diff HEAD^..HEAD --check,预期没有 whitespace 错误。也可以重复运行 node scripts/dev.js serve --port 0 --hostname 127.0.0.1 --no-open --no-web,确认 stdout 仍输出 qwen serve listening on ...,stderr 包含 startup timing。

Evidence (Before & After)

此前本地 external command 到 listener ready 的基线约为 3.55s p50。变更后,本地 5 次运行 node scripts/dev.js serve --port 0 --hostname 127.0.0.1 --no-open --no-web 得到 [1068, 1246, 1092, 2364, 2729]ms,p50 为 1246ms;daemon stderr 自报 process-to-listen p50 约 383ms,runQwenServe-to-listen p50 约 68ms。

Tested on

OS Status
🍏 macOS ✅ tested
🪟 Windows ⚠️ not tested
🐧 Linux ⚠️ not tested

Environment (optional)

macOS Darwin 25.4.0 arm64,Node v22.22.3,npm 10.9.8。

Risk & Scope

  • Main risk or tradeoff: serve 路径现在有一个轻量 bootstrap app,并在 listen 后委托给完整 runtime,因此主要风险是保持嵌入式 runQwenServe 调用方以及 settings/runtime 目录解析的兼容性。
  • Not validated / out of scope: 完整 npm run typecheck 仍被既有且无关的 BaseTextInput.tsx 问题阻塞:ink/dom 和 ink/components/CursorContext 无法解析,cursorCtx 被推断为 unknown;本 PR 不修复该 TUI build blocker。首个 POST /session 的 ACP 深度优化也不在本 PR 范围内。
  • Breaking changes / migration notes: 没有预期的 breaking change。stdout listening 行保持兼容;新增启动信息只以 additive 方式出现在 stderr 和 /daemon/status。

Linked Issues

N/A

doudouOUC and others added 3 commits June 24, 2026 01:30
Slim the qwen serve startup path by deferring interactive UI, runtime, web-shell, and settings-heavy imports until after the listener is ready.

Add daemon startup timing, preheat status reporting, fast-path settings/env loading, and regression coverage for import boundaries and runtime directory behavior.

Co-authored-by: Qwen-Coder <[email protected]>
Resolve runQwenServe conflicts after upstream serve and LSP changes while preserving the fast-path runtime split.

Co-authored-by: Qwen-Coder <[email protected]>
Comment thread packages/cli/src/serve/fast-path.ts Resolved
Comment thread packages/cli/index.ts Resolved
Comment thread packages/cli/src/serve/fast-path.ts Resolved
Comment thread packages/cli/src/serve/fast-path.ts Resolved
@wenshao
wenshao marked this pull request as ready for review June 23, 2026 23:03
Copilot AI review requested due to automatic review settings June 23, 2026 23:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@wenshao

wenshao commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

This PR currently has merge conflicts against main — GitHub reports it as CONFLICTING / DIRTY, so it can't be merged as-is. Could you please rebase onto the latest main, resolve the conflicts, and push the update? Once it's mergeable again we can move forward. Thanks!

中文

这个 PR 目前与 main 分支存在合并冲突(GitHub 显示为 CONFLICTING / DIRTY),当前状态无法合并。能否请你 rebase 到最新的 main、解决冲突后再 push 更新?恢复到可合并状态后我们就能继续推进。谢谢!

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up review at 4fc1429 (model: claude-opus-4-8). I re-checked the 11 earlier /review findings against current HEAD: the Critical (fast path not observing runtimeReady) and the bridge-proxy prefer-const lint are confirmed fixed, and the env-key / qwen-dir duplication is genuinely deduped. 3 new suggestions inline below; no blockers.

跟进 review(HEAD 4fc1429):已对照当前 HEAD 复核之前 11 条 /review 意见——Critical(快路径未观察 runtimeReady)与 bridge-proxy prefer-const lint 均已修复,env-key / qwen-dir 重复也已正确去重。下方 3 条新建议,无阻断项。

Comment thread packages/cli/src/serve/fast-path.ts Resolved

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new high-confidence findings on re-review at 41e268e. Downgraded from Approve to Comment: CI failing (review-pr, Test (windows-latest, Node 22.x), Test (ubuntu-latest, Node 22.x), CodeQL). All 15 R2 findings are low-confidence (terminal-only, not posted as inline comments). R1 inline comments (11) are on stale commits. 125/125 PR tests pass locally; full CLI suite 9,369/9,369 passes.

— qwen3.7-max via Qwen Code /review

Comment thread packages/cli/src/serve/fast-path.ts Resolved
Comment thread packages/cli/src/serve/fast-path.ts Resolved
@doudouOUC
doudouOUC requested a review from wenshao June 24, 2026 00:33
@wenshao

wenshao commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

🔬 Local build & runtime verification — PR #5785 @ 4fc1429

Built real CLIs from source for both this PR head and origin/main, then measured qwen serve cold-start head-to-head and exercised the daemon end-to-end. This is a runtime/perf verification (complementary to the earlier code reviews), intended as a merge reference.

Environment: macOS arm64 (Darwin 25.5.0), Node v22.22.2. Each worktree: clean npm ci + node scripts/build.js --cli-only (both exit 0). Latency measured on the tsc-built packages/cli/dist/index.js with a fresh temp workspace per run, 2 warm-up + 12 measured runs, sequential on a quiet CPU.

TL;DR — ✅ the startup-perf claim reproduces, no runtime regressions found.

1. Cold-start A/B (built dist/index.js, 12 runs each)

Metric main (a234860) PR-5785 (4fc1429) Δ
external cmd → listening p50 1708 ms 409 ms −76% · 4.2× faster
external min / max 1695 / 2041 ms 399 / 425 ms
self-reported processToListenMs p50 (field absent) 112 ms new
self-reported runQwenServeToListenMs p50 (field absent) 34 ms new

Variance is tiny on both sides (PR 399–425 ms). The ratio is even larger than the PR's own dev.js figures because the dist run removes the constant tsx transpile overhead that diluted them — same direction, stronger signal.

2. Functional equivalence (PR head)

  • stdout contract preserved: qwen serve listening on http://127.0.0.1:<port> (mode=http-bridge, workspace=…)
  • New observability works — GET /daemon/status now returns a startup block:
    "startup": { "processStartedAt": "…", "listenerReadyAt": "…",
                 "processToListenMs": 159, "runQwenServeToListenMs": 46,
                 "preheat": { "status": "running" } }
    and stderr emits startup timing: processToListenMs=… runQwenServeToListenMs=…. The preheat state confirms ACP runtime is deferred and reported, not blocking listen.
  • GET /capabilities → HTTP 200.

3. Tests / format

  • Test-plan suites (fast-path, run-qwen-serve, daemon-status, commands/serve, daemon-logger): 146/146 passed (plan cited 137; head has more, all green).
  • prettier --check on the listed files: all match. git diff --check: no whitespace errors.

4. Notes for merge

  • Typecheck blocker is pre-existing & out of scope — confirmed: BaseTextInput.tsx (ink/dom, CursorContext) is identical on main and not touched by this PR. Not a regression.
  • CI was still pending at verification time (macOS/ubuntu/windows tests + CodeQL running) — let it go green before merge.
  • Methodology caveat: I measured the tsc dist (unbundled), not the esbuild production bundle — bundling is blocked in this env for both branches alike by @qwen-code/channel-qqbot (not a workspace package; only a lazy dynamic import, never hit by serve) and missing web-templates generated files. The A/B is apples-to-apples; the shipped single-file bundle should be at least as fast.

Verdict: runtime verification PASS — the ~4× faster pre-listen path reproduces cleanly, the new /daemon/status startup telemetry is correct, the stdout listening contract is intact, and the test/format gates are green. The only merge gates are CI completion and the documented pre-existing TUI typecheck blocker.

🇨🇳 中文版(完整对应)

🔬 本地构建与运行时验证 — PR #5785 @ 4fc1429

对本 PR head 与 origin/main 分别从源码构建出真实 CLI,再对 qwen serve 冷启动做了 A/B 实测,并端到端验证了 daemon。这是一份运行时/性能验证(与此前的代码评审互补),用作合并参考。

环境: macOS arm64(Darwin 25.5.0),Node v22.22.2。每个 worktree:干净 npm ci + node scripts/build.js --cli-only(均 exit 0)。延迟测量基于 tsc 构建出的 packages/cli/dist/index.js,每次用全新临时 workspace,2 次预热 + 12 次正式,安静 CPU 下顺序执行。

结论 — ✅ 启动性能改进可复现,未发现运行时回归。

1. 冷启动 A/B(构建后的 dist/index.js,各 12 次)

指标 main(a234860) PR-5785(4fc1429) Δ
外部命令 → listening p50 1708 ms 409 ms −76% · 快 4.2×
外部 min / max 1695 / 2041 ms 399 / 425 ms
自报 processToListenMs p50 (无此字段) 112 ms 新增
自报 runQwenServeToListenMs p50 (无此字段) 34 ms 新增

两侧方差都很小(PR 399–425 ms)。比值比 PR 自己的 dev.js 数据更大,因为 dist 运行去掉了 tsx 转译这一恒定开销(它稀释了原始比值)——方向一致,信号更强。

2. 功能等价性(PR head)

  • stdout 契约保持不变: qwen serve listening on http://127.0.0.1:<port> (mode=http-bridge, workspace=…)
  • 新观测能力可用 —— GET /daemon/status 现在返回 startup 块:
    "startup": { "processStartedAt": "…", "listenerReadyAt": "…",
                 "processToListenMs": 159, "runQwenServeToListenMs": 46,
                 "preheat": { "status": "running" } }
    且 stderr 输出 startup timing: processToListenMs=… runQwenServeToListenMs=…。preheat 状态印证了 ACP runtime 被延后且被上报,不阻塞 listen。
  • GET /capabilities → HTTP 200。

3. 测试 / 格式

  • 测试计划里的套件(fast-path、run-qwen-serve、daemon-status、commands/serve、daemon-logger):146/146 通过(计划写的是 137,当前 head 更多,全绿)。
  • 对列出文件 prettier --check:全部符合;git diff --check:无空白错误。

4. 合并注意事项

  • typecheck 阻塞是既有问题、且不在本 PR 范围内 —— 已确认:BaseTextInput.tsx(ink/dom、CursorContext)在 main 上完全相同,且本 PR 未改动它。不是回归。
  • CI 在验证时仍pending(macOS/ubuntu/windows 测试 + CodeQL 在跑)—— 合并前等其转绿。
  • 方法学说明: 我测的是 tsc 的 dist(未打包),不是 esbuild 生产 bundle —— 在本环境里 bundle 对两个分支同样被 @qwen-code/channel-qqbot(非 workspace 包;只是个惰性 dynamic import,serve 永不触发)和缺失的 web-templates 生成文件挡住。A/B 是同口径对比;最终单文件 bundle 只会更快或持平。

结论:运行时验证通过 —— pre-listen 路径约 4× 提速可干净复现,新的 /daemon/status 启动遥测正确,stdout listening 契约完好,测试/格式门禁全绿。唯一的合并前置项是 CI 跑完,以及那个有文档记录的、既有的 TUI typecheck 阻塞。

Verified locally by building real CLIs from source on both branches; A/B on built dist. — claude-opus-4-8 via Claude Code

@wenshao

wenshao commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

@qwen-code /triage

Comment thread packages/cli/src/serve/fast-path.ts Resolved
Comment thread packages/cli/index.ts Resolved
@doudouOUC
doudouOUC dismissed a stale review via 79fb09b June 24, 2026 01:59
@wenshao

wenshao commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Build failure root cause — it's a main regression (SDK bundle over its size cap), not this PR

The failing Test legs on all three platforms (run 28069937514) die at the Install dependencies step. npm ci runs the prepare/build lifecycle (husky && npm run build && npm run bundle), and the build throws:

Error: Browser daemon SDK bundle is 128651 bytes; expected <= 128000
npm error workspace @qwen-code/[email protected]
npm error command sh -c node scripts/build.js

packages/sdk-typescript/scripts/build.js enforces a hard cap MAX_DAEMON_BROWSER_BUNDLE_BYTES = 125 * 1024 = 128000. The browser daemon bundle is now 128651 bytes — 651 over the limit, so the build aborts on every platform and npm ci fails.

Why this is not your PR:

The fix belongs on main, not in this PR: either trim the daemon browser bundle back under 128000, or bump MAX_DAEMON_BROWSER_BUNDLE_BYTES (e.g. to 126 * 1024) in packages/sdk-typescript/scripts/build.js. Once main is green again, rebasing this PR will clear the failure — there is nothing to change here for it.

中文

构建失败根因 —— 是 main 分支的回归(SDK bundle 超过体积上限),不是本 PR

三个平台失败的 Test 都挂在 Install dependencies 步骤(run 28069937514)。npm ci 会跑 prepare/build 生命周期(husky && npm run build && npm run bundle),构建抛错:

Error: Browser daemon SDK bundle is 128651 bytes; expected <= 128000
npm error workspace @qwen-code/[email protected]
npm error command sh -c node scripts/build.js

packages/sdk-typescript/scripts/build.js 里有硬上限 MAX_DAEMON_BROWSER_BUNDLE_BYTES = 125 * 1024 = 128000。现在 browser daemon bundle 是 128651 字节,超了 651 字节,于是构建在每个平台都中止,npm ci 失败。

为什么判定与本 PR 无关:

修复应该在 main,不在本 PR: 要么把 daemon browser bundle 压回 128000 以内,要么在 packages/sdk-typescript/scripts/build.js 里上调 MAX_DAEMON_BROWSER_BUNDLE_BYTES(例如调到 126 * 1024)。等 main 重新变绿后,把本 PR rebase 一下就能消除这个失败 —— 本 PR 自身不需要改动。

Comment thread packages/cli/src/serve/fast-path.ts Resolved
Comment thread packages/cli/src/config/environment.ts Resolved

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up review of the latest changes (HEAD 095188d0) with claude-opus-4-8. The earlier Critical findings look addressed in 97bb0d29/095188d0 (fast path now awaits runtimeReady via waitForServeRuntimeOrExit; --experimental-lsp parsed; prefer-const lint clear; path-helper dedup into path-comparison.ts; trust-rule caching). Locally ESLint, tsc, and the serve/config test suites are all green here — the red Test legs appear to be the known unrelated main SDK-bundle-size regression rather than this PR. Two minor follow-up notes inline.

— claude-opus-4-8[1m] via Qwen Code /qreview

Comment thread packages/cli/src/serve/fast-path.ts Resolved

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No review findings on this incremental commit. Downgraded from Approve to Comment: CI failing (Test (macos-latest, Node 22.x), Test (windows-latest, Node 22.x), Test (ubuntu-latest, Node 22.x)).

R5 (095188d) addresses 4 prior R4 suggestions:

  • failRuntimeStartup now writes to daemonLog.error() (observability)
  • resolveRuntimeStartupTimeoutMs env var parsing is now tested (6 parametrized cases)
  • Bootstrap catch-all 503 handler for unknown routes is now tested
  • Rate limit env var activation and discard paths are now tested
  • Trust-rule evaluation refactored to pre-compute path variants (CachedTrustRule), avoiding redundant getPathComparisonVariants/fs.realpathSync calls per check

Two low-confidence suggestions for human review (terminal-only):

  1. buildTrustedFolderRules TRUST_PARENT branch has no fast-path-specific test (logic unchanged from pre-existing code tested in trustedFolders.test.ts)
  2. resolveRuntimeStartupTimeoutMs direct-override branches (positive, zero, negative, Infinity, NaN) are untested — only the env-var fallback path is covered

— qwen3.7-max via Qwen Code /review

wenshao
wenshao previously approved these changes Jun 24, 2026
@doudouOUC

Copy link
Copy Markdown
Collaborator Author

@qwen-code /triage

@doudouOUC
doudouOUC requested a review from wenshao June 24, 2026 06:34
@doudouOUC
doudouOUC dismissed a stale review via 3b1604d June 24, 2026 08:07
@wenshao

wenshao commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

✅ Local build + real-daemon verification — PR #5785

Verified at commit 3b1604da on macOS (Darwin 25.5.0), Node v22.22.2 / npm 10.9.7. Built the workspace from source and exercised the fast-path startup against a real qwen serve daemon (built binary). All green.

Results

Check Result
npm run build (all packages incl. SDK browser bundle) ✅ exit 0
npm run typecheck (6 workspaces) ✅ clean, no errors
Reviewer-plan suites (fast-path / run-qwen-serve / daemon-status / serve / daemon-logger) ✅ 169 passed
Real-daemon startup E2E (built binary, 5 runs) ✅ 8/8 assertions

Real-daemon startup E2E (built dist/index.js serve)

  • stdout listening contract preserved — qwen serve listening on http://127.0.0.1:<port> … is emitted on stdout, and startup timing is kept off stdout, so embedded callers that parse the listen line are unaffected.

  • stderr startup timing — qwen serve: startup timing: processToListenMs=… runQwenServeToListenMs=… is emitted as designed.

  • /daemon/status observability (token-gated even on loopback ✔) exposes the new snapshot under daemon.startup: processToListenMs, runQwenServeToListenMs, preheat.status, plus processStartedAt / listenerReadyAt.

  • Fast path engaged / perf holds (median of 5 local runs):

    metric median
    runQwenServeToListenMs 52 ms
    processToListenMs 179 ms
    external wall (spawn → listening) 492 ms

    The listener comes up well before the full runtime mounts (preheat.status: running at listen time) — which is the point of the change. Numbers are in line with / better than the PR's cited baseline (~68 ms runQwenServe→listen p50, ~383 ms process→listen p50).

Notes for the maintainer

  • The earlier CI build red was a stale SDK bundle budget — now fixed in-branch. A prior revision (677d6a9e) failed npm run build with Browser daemon SDK bundle is 128651 bytes; expected <= 128000 (125 KB). That bundle (packages/sdk-typescript) is untouched by this PR (the diff is packages/cli-only) and is self-contained. origin/main had already raised the budget to 127 KB in 06549daa9 (#5797); the branch's merge of main (8642f76ac) picked that up, so the build now passes at 3b1604da (verified exit 0). No action needed — just flagging in case you saw the earlier red.
  • One timing-sensitive test to watch for CI flake. serve.test.ts › "serve startup import boundary › reaches listening through the dev entrypoint" spawns a real child process and flaked once in 4 combined runs at the earlier revision (file-level timeout under parallel CPU load); it passed at 3b1604da and passes in isolation / on rerun (its duration swings ~1.8–2.9 s). A longer per-test timeout or a retry would harden it. Not a product bug.

Verdict

Build, typecheck, the serve test suites, and real end-to-end daemon startup (stdout contract preserved + new observability fields + fast listener) all pass at 3b1604da. From a build-and-behavior standpoint this is good to merge. (Functional verification, not a design review.)

🇨🇳 中文版(完整对应)

✅ 本地构建 + 真实 daemon 验证 — PR #5785

验证 commit:3b1604da,环境:macOS(Darwin 25.5.0),Node v22.22.2 / npm 10.9.7。从源码完整构建,并用真实的 qwen serve daemon(构建出的真实二进制)跑通了 fast-path 启动。全绿。

结果

检查项 结果
npm run build(所有包,含 SDK 浏览器 bundle) ✅ exit 0
npm run typecheck(6 个 workspace) ✅ 干净,无 error
Reviewer plan 套件(fast-path / run-qwen-serve / daemon-status / serve / daemon-logger) ✅ 169 通过
真实 daemon 启动 E2E(真实二进制,5 次) ✅ 8/8 断言

真实 daemon 启动 E2E(构建出的 dist/index.js serve)

  • stdout listening 契约保持 —— qwen serve listening on http://127.0.0.1:<port> … 输出在 stdout,启动 timing 不混入 stdout,因此解析 listen 行的嵌入式调用方不受影响。

  • stderr 启动 timing —— 按设计输出 qwen serve: startup timing: processToListenMs=… runQwenServeToListenMs=…。

  • /daemon/status 观测(loopback 上也需要 token ✔)在 daemon.startup 下暴露新快照:processToListenMs、runQwenServeToListenMs、preheat.status,以及 processStartedAt / listenerReadyAt。

  • fast path 生效 / 性能达标(5 次本地运行中位数):

    指标 中位数
    runQwenServeToListenMs 52 ms
    processToListenMs 179 ms
    外部 wall(spawn → listening) 492 ms

    listener 在完整 runtime 挂载之前就起来了(listen 时 preheat.status: running)—— 这正是本次改动的目的。数字与 PR 给的基线相当或更好(runQwenServe→listen p50 ~68 ms,process→listen p50 ~383 ms)。

给维护者的说明

  • 此前 CI 构建报红是一个陈旧的 SDK bundle 预算问题 —— 现已在分支内修复。 早先的版本(677d6a9e)npm run build 失败:Browser daemon SDK bundle is 128651 bytes; expected <= 128000(125 KB)。那个 bundle(packages/sdk-typescript)本 PR 完全没动(diff 只在 packages/cli),而且它自包含。origin/main 已经在 06549daa9(#5797)把预算提到 127 KB;分支 merge main(8642f76ac)拿到了这个提升,所以在 3b1604da 上构建已通过(实测 exit 0)。无需处理——只是说明一下,以防你看到之前的红。
  • 有一个对时序敏感的测试,CI 可能偶发 flake。 serve.test.ts › "serve startup import boundary › reaches listening through the dev entrypoint" 会 spawn 真实子进程,在早先版本的组合运行里 flake 过 1/4(并行 CPU 负载下文件级超时);在 3b1604da 上通过,单独跑/重跑也通过(耗时在 ~1.8–2.9 秒波动)。给它更长的单测 timeout 或 retry 可加固。不是产品 bug。

结论

构建、typecheck、serve 测试套件、以及真实端到端 daemon 启动(stdout 契约保持 + 新观测字段 + 快速 listener)在 3b1604da 上全部通过。从构建与行为角度看,可以合并。(功能验证,非设计评审。)

— verified with claude-opus-4-8 · local build + real daemon E2E (Node v22.22.2, macOS)

@doudouOUC

Copy link
Copy Markdown
Collaborator Author

@qwen-code /triage

@doudouOUC
doudouOUC requested a review from yiliang114 June 24, 2026 09:32
@doudouOUC
doudouOUC merged commit 0787543 into QwenLM:main Jun 24, 2026
22 of 23 checks passed

@yiliang114 yiliang114 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All review threads resolved and CI green (macOS test still in flight). The two-phase listen-then-mount keeps the stdout listening contract additive-only, and the earlier criticals — NaN env coercion via ??=, the shutdown-during-build bridge leak, force-close timer gating, and the fast path awaiting runtimeReady — are addressed at 3b1604da. LGTM, ready to ship. ✅

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.

4 participants