-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.17beta1 linux/amd64
Does this issue reproduce with the latest release?
Not for go1.16.5 and tip.
What did you do?
package foo
import (
"testing"
)
const N = 8192
var struct3_0 struct{a, b, c int}
func Benchmark_CopyStruct_3_fields(b *testing.B) {
var struct3_1 struct{a, b, c int}
for i := 0; i < b.N; i++ {
for range [N]struct{}{} {
struct3_0 = struct3_1
}
}
}
func Benchmark_xxx(b *testing.B) {
for i := 0; i < b.N; i++ {
}
}
func Benchmark_yyy(b *testing.B) {
for i := 0; i < b.N; i++ {
}
}What did you expect to see?
cpu: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
Benchmark_CopyStruct_3_fields-4 183609 6357 ns/op
Benchmark_xxx-4 1000000000 0.4014 ns/op
Benchmark_yyy-4 1000000000 0.4130 ns/op
What did you see instead?
cpu: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
Benchmark_CopyStruct_3_fields-4 93883 12407 ns/op
Benchmark_xxx-4 1000000000 0.4014 ns/op
Benchmark_yyy-4 1000000000 0.4130 ns/op
It at least one in the Benchmark_xxx or Benchmark_yyy is removed, then the result is normal.
Otherwise, the result is double.
The problem doesn't exist in go1.16.5 and tip. I don't know whether or not it is fixed in the go1.17 release branch.
I didn't find the go1.17 release branch in the repo, so I haven't tested it.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.