已合并
perf(pool): parallelize network slot cleanup on shutdown #171
jing-rui创建于 8月18日
perf(pool): parallelize network slot cleanup on shutdown #171
已合并
Pull Request已成功合入, 合并人@openeuler-ci-bot
(感谢 jing-rui 的贡献)atomgit-bot
8月18日 评论:
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的串行清理改为先批量取出全部槽位、再通过缓冲 channeljobs分发给多个 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)/。


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


18 天前 添加了label:approvedlgtm
openeuler-ci-bot
18 天前 评论:
18 天前 评论:
18 天前 合入了pull request,合并节点 SHA:a83e40fc3bf29792eeeafbd61585afad86426e36
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: