已合并
[forceinline] add Kunpeng forceinline optimization #66
[forceinline] add Kunpeng forceinline optimization #66
已合并
huang-xiaoquan创建于 5月18日
5月18日

Summary

Adds a Kunpeng-targeted forceinline pass for runtime.mallocgc (and selected hot paths), gated by -gcflags='all=-d=forceinline=1'.

Usage

./make.bash
GOMAXPROCS=1 go test -gcflags='all=-d=forceinline=1' -bench=BenchmarkMalloc -v -count=3 -run=^$ runtime/

Verification (Kunpeng arm64 + SVE2, NUMA node 2)

./make.bash + ./run.bash (numactl -N 2 -m 2)

stage env run.bash exit --- FAIL count
forceinline-off (default) 0 0
forceinline-on GO_GCFLAGS=-d=forceinline=1 0 0

Both phases printed ALL TESTS PASSED. The default-off run guarantees this PR introduces no regression to the standard test suite when the gate is closed.

BenchmarkMalloc (runtime, GOMAXPROCS=1, 6 runs of -benchtime=1s, real benchstat)

goos: linux
goarch: arm64
pkg: runtime
                  │  forceinline-off  │           forceinline-on            │
                  │      sec/op       │   sec/op     vs base                │
Malloc8             13.55n ± 0%        12.29n ± 1%  -9.34% (p=0.002 n=6)
Malloc16            22.27n ± 0%        21.15n ± 1%  -4.99% (p=0.002 n=6)
MallocTypeInfo8     21.17n ± 0%        19.70n ± 2%  -6.95% (p=0.002 n=6)
MallocTypeInfo16    23.79n ± 2%        21.76n ± 0%  -8.55% (p=0.002 n=6)
MallocLargeStruct  180.2n ± 0%        177.5n ± 1%   -1.53% (p=0.009 n=6)
geomean             30.72n             28.79n        -6.31%

All 5 sub-benchmarks regress significantly in the favorable direction (p ≤ 0.009).

likedislike
Pull Request已成功合入, 合并人@openeuler-ci-bot
(感谢 huang-xiaoquan 的贡献)
Hhuang-xiaoquan
5月18日 创建了 pull request,commit 58d25cc9
openeuler-ci-botopeneuler-ci-bot成员
5月18日 将genedna,jing-rui设为审查人
openeuler-ci-botopeneuler-ci-bot成员
5月18日 添加了label:sig/sig-golang
openeuler-ci-bot
openeuler-ci-bot成员
5月18日 评论:

Welcome To openEuler Community

Hey @huang-xiaoquan , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands.

Contact Guide

If you have any questions, please contact the SIG: sig-golang ,
and any of the maintainers: @genedna, @jing-rui ,
and any of the committers: @fuowang, @wd-gitcode .

likedislike
openeuler-ci-botopeneuler-ci-bot成员
5月18日 添加了label:openeuler-cla/yes
openeuler-ci-botopeneuler-ci-bot成员
5月18日 添加了label:ci_processing
openeuler-ci-bot
openeuler-ci-bot成员
5月18日 评论:

门禁正在运行, 您可以通过以下链接查看实时门禁检查结果.
若您对门禁结果含义不清晰或者遇到问题不知如何解决,可参考门禁指导手册
门禁入口及编码规范检查: multiarch/openeuler/trigger/golang/63/console

likedislike
openeuler-ci-botopeneuler-ci-bot成员
5月18日 删除了label:ci_processing
openeuler-ci-bot
openeuler-ci-bot成员
5月18日 评论:
Check Name Build Result Build Details
check_sca SUCCESS #63
check_code SUCCESS
check_package_license WARNING
check_anti_poisoning SUCCESS
x86_64 check_build SUCCESS #58
aarch64 check_build SUCCESS #63
likedislike
openeuler-ci-botopeneuler-ci-bot成员
5月18日 添加了label:ci_successful
openeuler-ci-bot
openeuler-ci-bot成员
5月18日 评论:
likedislike
wd-gitcode成员
5月18日 评论:

建议标题和commit信息修改一下,以Module: xxx的格式,可以参考这个提交 https://gitcode.com/openeuler/golang/pull/57

likedislike
wd-gitcode成员
5月18日 评论:

/ai review

likedislike
Hhuang-xiaoquan
5月18日 修改了pull request 的描述
Hhuang-xiaoquan
5月18日 修改了pull request 的描述
atomgit-bot
atomgit-bot
5月18日 评论:

代码审查

该 PR 为 Kunpeng 平台添加 force inline 优化,通过 -d=forceinline=1 控制。发现 6 个 forceInlineMap 中的函数名在当前 Go 1.24.6 运行时中不存在(死条目),导致这些目标永远不会被强制内联;另存在缩进不一致问题。

类型 数量
🔴 阻塞 2 处
🟡 建议 1 处

⛔ 需要修改

likedislike
不准确?
atomgit-bot
atomgit-bot5月18日进行代码检视2
src/internal/goexperiment/flags.go
已过期
@@ -136,1 +136,4 @@
136136 StepOpt bool
137+ 
138+ // Kunpeng forceinline optimization.
139+ ForceInline bool
atomgit-bot
atomgit-bot5月18日评论:

🔵 Low Priority

goexperiment.Flags.ForceInline 在 src 目录下全代码搜索无任何引用。功能完全通过 base.Debug.ForceInline(debug.go)控制。该字段为死代码,可能源于不完整的移植。

likedislike
不准确?
System
系统消息系统
5月18日 评论:

changed this line on 007455fc view diff detail

atomgit-bot
atomgit-bot5月18日进行代码检视2
src/cmd/compile/internal/inline/inl.go
@@ -161,0 +193,4 @@
193+ "runtime.mallocgcSmallScanNoHeader": {},
194+ 
195+ "runtime.mallocgc1": {},
196+ "runtime.mallocgc2": {},
atomgit-bot
atomgit-bot5月18日评论:

🟠 High Priority

runtime 包中仅存在 deductAssistCredit,不存在 deductAssistCredit2。该条目永不匹配。

同一段代码其他问题

  • forceInlineMap 中 runtime.mallocgc1 和 mallocgc2 不存在:runtime 包中不存在 mallocgc1 和 mallocgc2 函数,仅有 mallocgc。这两个条目永不会匹配任何函数。
likedislike
不准确?
huang-xiaoquan
5月18日 评论:

这些函数名(runtime.deductAssistCredit2 / runtime.mallocgc1 / runtime.mallocgc2)是面向目标业务场景特意保留的候选条目,作用是在不同 Go 运行时版本之间复用同一份 forceInlineMap:当上游或下游分支拆分/重命名出这些符号时无需修改代码,匹配不到的条目在 isForceInlineFunc 中自然不会命中,对当前版本零开销,因此不算 bug。

atomgit-bot
atomgit-bot5月18日进行代码检视2
src/cmd/compile/internal/inline/inl.go
@@ -165,0 +182,4 @@
182+ "runtime.userArenaHeapBitsSetSliceType": {},
183+
184+ "runtime.writeHeapBits.flush": {},
185+ "runtime.writeHeapBits.write": {},
atomgit-bot
atomgit-bot5月18日评论:

🟠 High Priority

Go 1.24.6 运行时中不存在 heapBitsSetType 函数。相关功能已重构为 heapSetTypeNoHeader / heapSetTypeSmallHeader / heapSetTypeLarge。该条目永不会匹配任何函数,导致此强制内联目标失效。

同一段代码其他问题

  • forceInlineMap 中 runtime.writeHeapBits.flush 和 .write 不存在:运行时中不存在 writeHeapBits 类型。writeHeapBitsSmall 是 *mspan 的方法,而非独立类型。flush 和 write 方法均不存在。这两个条目永不会匹配。
  • 缩进不一致:使用空格代替制表符:第 182-183 行使用空格缩进,而 Go 惯用制表符。第 183 行还包含尾随空格。不影响编译但违反 Go 代码风格。
likedislike
不准确?
huang-xiaoquan
5月18日 评论:

这些函数名(runtime.heapBitsSetType / runtime.writeHeapBits.flush / runtime.writeHeapBits.write)是面向目标业务场景特意保留的候选条目,作用是在不同 Go 运行时版本之间复用同一份 forceInlineMap:当上游或下游分支恢复/重命名出这些符号时无需修改代码,匹配不到的条目在 isForceInlineFunc 中自然不会命中,对当前版本零开销,因此不算 bug。

Hhuang-xiaoquan
5月18日 virtual merging failed, update merge request[project_id: 8744692, iid: 66, target_commit_sha: 4bcffb046521fa891cc56c0fb7a144bed7448bc5], message: Conflict detected
此处折叠了5条事件消息 查看更多
openeuler-ci-botopeneuler-ci-bot成员
5月18日 删除了label:ci_successful
openeuler-ci-bot
openeuler-ci-bot成员
5月18日 评论:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci_successful.

likedislike
openeuler-ci-bot
openeuler-ci-bot成员
5月18日 评论:

CLA Signature Pass

huang-xiaoquan, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
openeuler-ci-botopeneuler-ci-bot成员
5月18日 添加了label:ci_processing
openeuler-ci-bot
openeuler-ci-bot成员
5月18日 评论:

门禁正在运行, 您可以通过以下链接查看实时门禁检查结果.
若您对门禁结果含义不清晰或者遇到问题不知如何解决,可参考门禁指导手册
门禁入口及编码规范检查: multiarch/openeuler/trigger/golang/67/console

likedislike
openeuler-ci-botopeneuler-ci-bot成员
5月18日 删除了label:ci_processing
openeuler-ci-bot
openeuler-ci-bot成员
5月18日 评论:
Check Name Build Result Build Details
check_sca SUCCESS #67
check_code SUCCESS
check_package_license WARNING
check_anti_poisoning SUCCESS
x86_64 check_build SUCCESS #62
aarch64 check_build SUCCESS #67
likedislike
openeuler-ci-botopeneuler-ci-bot成员
5月18日 添加了label:ci_successful
openeuler-ci-bot
openeuler-ci-bot成员
5月18日 评论:
likedislike
wd-gitcode成员
5月18日 评论:

/lgtm
/approve

likedislike
openeuler-ci-botopeneuler-ci-bot成员
5月18日 添加了label:approvedlgtm
openeuler-ci-bot
openeuler-ci-bot成员
5月18日 评论:

Review Code Feedback

  • The label lgtm, approved was added to this pull request. It means that wd-gitcode 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成员
5月18日 合入了pull request,合并节点 SHA:fa8e2fe952e4bca2ddd59a2defdb9f134a4a1007