Perf regression: golang/rescan wall +34% (1d523d30, #1403)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 55/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 領域
- backend, performance
研究方向
Start in patch/redirect/mod.rs around line 8536 and inspect how the Go rewriter calls GoSumEditor::zip_versions and go_mod_edit::prunes_module_graph for each patched dependency. Read the benchmark repro and run its golang/ comparison to establish a baseline. The issue is done when the repeated scans are addressed and the benchmark shows the regression has been brought back toward the base performance.
由索引模型根據 Issue 內容生成。
描述
[agent] Bench: golang/rescan wall time is +34% and golang/hosted +23% on today's main (17793173), compared with f3c6313a (the previous bench run, 2026-10-09). Request counts are unchanged (64).
Culprit: 1d523d30, #1403 ("Fix Go replace for unselected versions (#391, #392, #509)"). Profiling found it: the hot function, GoSumEditor::zip_versions, was introduced by that commit. It was not bisected with builds.
Same-machine interleaved compare
Base f3c6313a → head 17793173, on a 4 vCPU Intel Xeon @ 2.10GHz cloud sandbox. An A/A run on the same machine was clean (golang/rescan +2.6%, ≈).
| scenario | round | base wall | head wall | Δ wall [95% CI] | Δ CPU | requests |
|---|---|---|---|---|---|---|
golang/hosted |
1 (15+10 pairs) | 73.0 ms | 94.5 ms | +27.3% [+18.5, +36.3] | +26.8% | 64 |
golang/hosted |
2 (20+10 pairs) | 70.6 ms | 87.2 ms | +23.4% [+14.6, +32.1] | +27.7% | 64 |
golang/rescan |
1 | 67.1 ms | 95.2 ms | +45.5% [+33.9, +51.1] | +37.2% | 64 |
golang/rescan |
2 | 67.0 ms | 88.2 ms | +34.3% [+26.4, +39.0] | +31.0% | 64 |
Hot spot
Callgrind on the head binary, golang/rescan (1200 modules, 30 patched), inclusive instructions:
68.3% patch::redirect::rewriter_groups::{{closure}}
30.4% vendor::go_sum_edit::GoSumEditor::zip_versions
29.0% <SplitWhitespace as Iterator>::next
15.9% vendor::go_mod_edit::scan_hosted_replace
10.3% go_mod_edit::strip_comment
The golang rewriter (patch/redirect/mod.rs, around line 8536) calls go_sum.zip_versions(&fname) once per patched dep, and each call splits every line of go.sum. That makes it O(patched deps × go.sum lines). go_mod_edit::prunes_module_graph(&go_mod) is also evaluated per dep. One pass over go.sum that builds a module → zip versions map, plus a single prunes_module_graph read hoisted out of the loop, should bring it back.
Repro
export CARGO_PROFILE_PERF_INHERITS=release CARGO_PROFILE_PERF_LTO=thin CARGO_PROFILE_PERF_STRIP=none
git worktree add /tmp/base f3c6313a && (cd /tmp/base && CARGO_TARGET_DIR=/tmp/tb cargo build --locked --profile perf -p socket-patch-cli)
CARGO_TARGET_DIR=/tmp/th cargo build --locked --profile perf -p socket-patch-cli -p socket-patch-bench
/tmp/th/perf/socket-patch-bench compare --base /tmp/tb/perf/socket-patch --head /tmp/th/perf/socket-patch -f '^golang/' --runs 20
Runner: nproc 4, Intel(R) Xeon(R) Processor @ 2.10GHz.
Generated by Claude Code
- 主要語言
- Rust
- 星號
- 8
- 分支
- 1
- 平均合併
- 19 小時 1 分鐘
- 30 天內合併 PR
- 473
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged bug pm:go priority:p2
難度 2/5 1-3 小時 新手友好度 76/100
SocketDev/socket-patch#1409 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:npm priority:p3 ux
難度 2/5 1-3 小時 新手友好度 75/100
SocketDev/socket-patch#1072 · 2 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:yarn-berry priority:p1
難度 2/5 1-3 小時 新手友好度 73/100
SocketDev/socket-patch#783 · 1 則留言 ·
維護者通常 1 天內回覆
-
Vendored cargo warns cargo_multi_version_old_cargo ("declares no rust-version") when the root package inherits rust-version from [workspace.package]可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉agent:triaged bug bughunt pm:cargo priority:p2
難度 2/5 1-3 小時 新手友好度 84/100
SocketDev/socket-patch#651 · 3 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bench perf-regression pm:nuget priority:p3
難度 4/5 3-5 天 新手友好度 45/100
SocketDev/socket-patch#1425 · 1 則留言 ·
維護者通常 1 天內回覆
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 75/100
RustCrypto/SSH#596 ·
-
proxy: SQL-over-HTTP turns empty arrays into [""] or [false], or HTTP 500 for int and float arrays未關閉
難度 2/5 1-3 小時 新手友好度 83/100
neondatabase/neon#12965 ·
-
難度 2/5 1-3 小時 新手友好度 78/100
goauthentik/authentik#26867 ·
維護者通常 1 天內回覆
-
api bug macos maintainer-needed p2 triaged
難度 2/5 1-3 小時 新手友好度 66/100
維護者通常 1 天內回覆
-
area::tern difficulty::easy good first issue kind::cleanup triage::ready
難度 1/5 1-3 小時 新手友好度 88/100