已合并
perf(pool): parallelize network slot cleanup on shutdown #171
jing-rui创建于 8月18日
perf(pool): parallelize network slot cleanup on shutdown #171
已合并
jing-rui创建于 8月18日
jing-rui
8月18日

Was This PR authored or co-authored using generative AI tooling?

[] No

[x] Yes
__1. AI Agent : Codex:GPT-5.6-sol
__2. AI Model : GPT-5.6-sol
__3. Prompt :

Reference: openEuler Community Generative AI Use and Open Source Contribution Policy

What this PR does / why we need it:

Which issue this PR fixes

(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

likedislike
Pull Request已成功合入, 合并人@openeuler-ci-bot
(感谢 jing-rui 的贡献)
Jjing-rui
8月18日 创建了 pull request,commit 1891ae6a
atomgit-bot
atomgit-bot
8月18日 评论:

变更摘要

本 PR 旨在提升 Pool.Close() 关闭时的性能:将原先逐个串行销毁 warm 网络槽位的逻辑改为并行清理。改动先一次性从 warmSlots 队列中弹出所有 Slot 并关闭队列,再启动多个 worker goroutine 通过缓冲 channel jobs 并发调用 destroyNetworkSlot 完成销毁,最后等待所有 worker 结束。并行度受 runtime.NumCPU()、prefillWorkers 及槽位数量共同约束。此外,Makefile 中同步调整了构建目标,将 build-offline 替换为 static。

主要改动

  • Pool.Close() 并行清理网络槽:在 internal/netstack/pool.go 中,将原本循环内逐个 destroyNetworkSlot 的串行清理改为先批量取出全部槽位、再通过缓冲 channel jobs 分发给多个 worker goroutine 并发销毁,并以 workerWg.Wait() 等待全部完成后继续后续流程。
  • 并行 worker 数量控制:worker 数量取 min(runtime.NumCPU(), prefillWorkers),并以实际槽位数 len(slots) 为上界,避免空队列或无谓的协程开销。
  • 新增 runtime 导入:internal/netstack/pool.go 引入 runtime 包以获取 NumCPU() 用于并行度计算。
  • Makefile 构建目标调整:删除 build-offline 目标(含从镜像备份同步 go.mod/go.sum 的逻辑),新增 static 目标,以 CGO_ENABLED=0、-tags "netgo,osusergo" 和静态链接参数一次性构建全部二进制到 $(BIN_DIR)/。
likedislike
不准确?
atomgit-bot
atomgit-bot
8月18日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
openeuler-ci-botopeneuler-ci-bot成员
8月18日 将weibaohui,yangzhao_kl,jimmieme,duguhaotian,wonleing,zmr_2020,gaodaweiky,lu-wei-army,zhaoyifan28设为审查人
openeuler-ci-botopeneuler-ci-bot成员
8月18日 添加了label:sig/sig-CloudNative
此处折叠了45条消息 查看更多
openeuler-ci-bot
openeuler-ci-bot成员
19 天前 评论:

Label Command Feedback

  • Thanks for your review, your opinion is very important to us. The maintainers will consider your advice carefully.
  • The label(s) lgtm permission is outside.
likedislike
zhaoyifan28成员
18 天前 评论:

/lgtm
/approve

likedislike
openeuler-ci-botopeneuler-ci-bot成员
18 天前 添加了label:approvedlgtm
openeuler-ci-bot
openeuler-ci-bot成员
18 天前 评论:

Review Code Feedback

  • The label lgtm, approved was added to this pull request. It means that zhaoyifan28 reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
openeuler-ci-botopeneuler-ci-bot成员
18 天前 合入了pull request,合并节点 SHA:a83e40fc3bf29792eeeafbd61585afad86426e36