perf(core): reduce Git snapshot processes - #6784
Conversation
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
Thanks for the PR, @dexhunter!
The body has solid technical content — good measurement table, correctness gates, and clear motivation. However, it's missing several required sections from the PR template:
- Reviewer Test Plan — no "How to verify" steps, no Before/After evidence, no "Tested on" OS table. This is the most important missing section; it's what lets reviewers actually confirm the change works.
- Risk & Scope — no risk/tradeoff, out-of-scope, or breaking-change notes.
- Linked Issues — "Fixes #6312" appears in the body text but the section itself is absent.
Could you fill in the template sections? The measurement data and correctness gates you already have are great — they just need to live in the right structure so reviewers can find them.
中文说明
感谢 PR,@dexhunter!
正文的技术内容很好——有详细的测量数据、正确性验证和清晰的动机说明。但缺少 PR 模板 中的几个必填部分:
- Reviewer Test Plan — 缺少"如何验证"步骤、Before/After 证据、"测试平台" OS 表格。这是最重要的缺失部分,reviewer 需要它来确认改动有效。
- Risk & Scope — 缺少风险/权衡、不在范围内、破坏性变更的说明。
- Linked Issues — 正文中有"Fixes #6312"但缺少该部分。
能否补充模板部分?你已有的测量数据和正确性验证非常好,只需要放到正确的结构里,方便 reviewer 查找。
— Qwen Code · qwen3.7-max
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
Reviewed — no blockers. Suggestions are inline.
|
Qwen precheck requires maintainer approval before automated triage/review. Head SHA: Reason:
A maintainer with write access can inspect the PR and manually request a run with |
|
The current head only adds the two requested regression tests for malformed branch headers and the |
✅ Local verification report — PR #6784I built and ran this PR locally on real hardware as a merge reference. Result: the change is functionally equivalent to Environment: macOS (darwin-arm64) · Node 1. Static gate — tests · typecheck · lint · format · build
2. Byte-for-byte equivalence (the core claim)I compiled both implementations side by side —
12/12 identical. The 3. Process-count reduction (primary metric)I traced real git child processes via a
Notes for the record
Verdict: LGTM — safe to merge. ✅ 🇨🇳 中文版本(点击展开)✅ 本地验证报告 — PR #6784作为合并参考,我在真实环境本地构建并运行了该 PR。结论:该改动与 环境: macOS (darwin-arm64) · Node 1. 静态门禁 — 测试 · 类型检查 · Lint · 格式化 · 构建
2. 逐字节等价性(核心主张)我将 两个实现并排编译—— 涵盖场景:干净仓库、暂存+未暂存+未跟踪+ 12/12 完全一致。 3. 进程数削减(主指标)我通过
备注
结论:LGTM — 可安全合并。 ✅ |
|
@qwen-code /triage |
|
Thanks for the PR! Template looks good ✓ — all required headings present with detailed evidence. Problem: Observed optimization with metrics. Direction: Aligned. Reducing process spawning on the per-session hot path is a clear performance win. The approach — combining Size: 2 files changed, ~44 production logic lines + ~99 test lines in Approach: Scope is minimal — one function modified, regression tests added for every new edge case (tracking details, VT control stripping, unborn branches, initial commits, detached HEAD, malformed output). No drive-by refactors, no scope creep. This is how a focused perf PR should look. Moving on to code review. 🔍 中文说明感谢贡献! 模板完整 ✓ — 所有必要标题齐全,附有详细证据。 问题:有指标支撑的实际性能优化。 方向:对齐。减少每个会话热路径上的进程创建是明确的性能收益。将 规模:2 个文件变更,约 44 行生产逻辑 + 约 99 行测试,位于 方案:范围最小化——修改一个函数,为每个新的边界情况添加回归测试(跟踪详情、VT 控制剥离、未出生分支、初始提交、detached HEAD、格式异常输出)。无附带重构,无范围蔓延。这是一个聚焦的性能 PR 应有的样子。 进入代码审查 🔍 — Qwen Code · qwen3.7-max Reviewed at |
|
@qwen-code /triage |
Code ReviewFocused two-file change in
No correctness issues found. The only downstream consumer is Reuse check: Test ResultsgitUtils tests — 11/11 passed ✓ client tests — 246/246 passed ✓ (total 257, matching the PR's claim) Build — passed ✓ Typecheck — passed ✓ Real-Scenario TestingThis is a non-UI internal optimization (system prompt construction). The tmux test verifies the CLI starts correctly and the system prompt (including git snapshot) is built without errors. CLI starts, builds the system instruction (which internally calls 中文说明代码审查聚焦的两文件变更,位于
未发现正确性问题。唯一的下游消费者是 复用检查: 测试结果gitUtils 测试 — 11/11 通过 ✓ 真实场景测试这是非 UI 的内部优化(系统提示构建)。tmux 测试验证 CLI 正常启动且系统提示(含 git 快照)构建无误。CLI 正确响应 "1+1" 为 "2",git 快照路径无错误或警告。 — Qwen Code · qwen3.7-max Reviewed at |
|
Confidence: 5/5 — Clean, focused perf PR that does exactly what it says. This is a textbook optimization: reduce 3 synchronous git processes to 2 by combining two of them into a single I independently considered how to eliminate one git process here — combining the branch and status reads is the obvious and correct approach. The PR's implementation matches that expectation and adds All 257 tests pass, build and typecheck are clean, and the CLI runs correctly in tmux. The author has been responsive to review feedback (added regression tests for malformed headers and the Approving. ✅ 中文说明信心度: 5/5 — 干净、聚焦的性能 PR,完全符合其声明。 这是一个教科书式的优化:将两个 git 命令合并为单个 我独立考虑了如何消除一个 git 进程——合并分支和状态读取是显而易见且正确的方案。PR 的实现符合预期,并添加了 全部 257 个测试通过,构建和类型检查正常,CLI 在 tmux 中运行正确。作者积极响应审查反馈。维护者 @wenshao 已在本地验证后批准。 批准。✅ — Qwen Code · qwen3.7-max Reviewed at |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅


What this PR does
This combines the branch and short-status reads used by the main-session system instruction into one
git status --short --branchprocess. It parses only the added branch header, preserves the existing short-status path and color behavior, keepsgit loglive on every session, and fixes the command locale so detached and unborn branch labels are stable.Why it's needed
getRecentGitStatus()runs while building every main-session system instruction. It previously launched three synchronous Git processes per session: branch, status, and log. In a long-livedqwen serveprocess, that work is repeated for each new session on the shared event loop. The new command returns branch and the same short-status remainder together, reducing the deterministic process count from 3 to 2 without caching Git output or reimplementing ref semantics.Reviewer Test Plan
How to verify
npx vitest run packages/core/src/utils/gitUtils.test.ts packages/core/src/core/client.test.ts --pool=threads --poolOptions.threads.minThreads=1 --poolOptions.threads.maxThreads=1; all 255 tests should pass.npm run buildandnpm run typecheck; both commands should complete successfully.getRecentGitStatus()and confirm it invokesgit status --short --branchonce plusgit logonce. The branch header is stripped from the status output, VT controls are removed only for branch parsing, and the status remainder is unchanged.The external strict evaluator imports the built candidate, traces real Git child processes over 31 warm session initializations, and compares the complete generated system instruction byte-for-byte with the prior three-command implementation. It also exercises tracked/index mutations, branch and commit changes, linked worktrees, separate repositories, metadata deletion, working-directory changes, reset, subdirectory renames, forced colors, and detached HEAD.
Evidence (Before & After)
This is not a UI change. The deterministic primary metric and same-machine timing diagnostics were:
The two final candidate runs measured 11.53 ms and 11.20 ms median, and every warm sample executed exactly two Git processes. Timing is hardware-sensitive; the process count is the primary metric. Public autoresearch trajectory: Weco dashboard.
Tested on
Environment (optional)
Ubuntu 24.04, Node.js 22.23.1. Validation included 255 focused tests, the full repository build, full workspace typecheck, changed-file ESLint and Prettier, two final strict evaluator runs at exactly
2.0, andgit diff --check.Risk & Scope
--short --branchheader. The command runs withLC_ALL=C, strips VT controls only from that header, and has regression coverage for tracking, color, unborn, detached, and subdirectory cases.Linked Issues
Fixes #6312