[go: up one dir, main page]

102
I Use This!
Very High Activity

Commits : Individual Commit

Analyzed about 8 hours ago. based on code collected 2 days ago.

Commit ID bae9486d07706bcc216961f504e75d1fb5c5aec8

Contributor: thepudds Files Modified 4
Date: 23-January-2026 at 20:59 Lines Added: 140
Repository: https://go.googlesource.com/go master Lines Removed: 2
Commit Comment: cmd/compile/internal/bloop: avoid extraneous heap allocs in b.Loop body due to autotmp variable scope The motivating example I created for #73137 still seems to heap allocate in go1.26rc2 when used in a b.Loop body. │ go1.25 │ go1.26rc2 │ │ allocs/op │ allocs/op vs base │ NewX/b.Loop-basic-4 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ I suspect it is because the temps are by default declared outside the loop body, which escape analysis will determine is an escaping value and result in a heap allocation. (I've seen this problem before, including in my older CL 546023 that attempts to help PGO with a similar issue.) This is an attempt to address that by placing ODCLs within the b.Loop body for the temps that are created so that they can be marked keepalive. There are two cases handled in the CL: function return values and function arguments. The first case is what affects my example from #73137, and is also illustrated via the NewX test case in the new test/escape_bloop.go file. Without this CL, the NewX call in the BenchmarkBloop test is inlined, which is an improvement over Go 1.25, but the slice still escapes because the temporary used for the return value is declared outside the loop body. With this CL, the slice does not escape. The second case is illustrated via the new BenchmarkBLoopFunctionArg test, which shows a function argument that escapes without this CL but does not escape with this CL. We can also make the two new b.Loop tests in testing/benchmark_test.go individually pass or fail as expected based on individually reverting the two changes in this CL. While we are here, we add a note to typecheck.TempAt to help make people aware of this behavior. Updates #73137 Fixes #77339 Change-Id: I69abe978367a8d3a931430aec5d85c9c54b42c1f Reviewed-on: https://go-review.googlesource.com/c/go/+/738822 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Junyang Shao <[email protected]>

Changes by Language

Language Code Added Code Removed Comments Added Comments Removed Blanks Added Blanks Removed
  Go 85 1 31 1 24 0

Changes by File

File Language Code Added Code Removed Comments Added Comments Removed Blanks Added Blanks Removed
src/cmd/compile/internal/bloop/bloop.go Go 7 1 2 0 0 0
src/cmd/compile/internal/typecheck/dcl.go Go 0 0 6 1 0 0
src/testing/benchmark_test.go Go 46 0 7 0 8 0
test/escape_bloop.go Go 32 0 16 0 16 0