golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.37k stars 17.71k forks source link

testing: TestBenchmarkBLoopIterationCorrect fails under GOMAXPROCS=1 #70627

Open dmitshur opened 6 hours ago

dmitshur commented 6 hours ago

At tip (commit c5adb8216968be46bd11f7b7360a7c8bde1258d9), TestBenchmarkBLoopIterationCorrect succeeds under most conditions.


``` $ go test -run=^TestBenchmarkBLoopIterationCorrect$ -count=1 -v testing === RUN TestBenchmarkBLoopIterationCorrect testing_test.go:978: /var/folders/yn/rz8r25f10z5fmwdg34tz6z1c0000gn/T/go-build514388636/b001/testing.test -test.run=^BenchmarkBLoopPrint$ -test.bench=BenchmarkBLoopPrint -test.v -test.parallel=2 -test.benchtime=2x: goos: darwin goarch: arm64 pkg: testing cpu: Apple M4 Pro BenchmarkBLoopPrint testing_test.go:1020: Ramping up from BenchmarkBLoopPrint testing_test.go:1022: Printing from BenchmarkBLoopPrint testing_test.go:1022: Printing from BenchmarkBLoopPrint BenchmarkBLoopPrint-14 2 4146 ns/op PASS --- PASS: TestBenchmarkBLoopIterationCorrect (0.01s) PASS ok testing 0.161s ```

But it fails consistently when run in an environment where GOMAXPROCS is 1:

$ GOMAXPROCS=1 go test -run=^TestBenchmarkBLoopIterationCorrect$ -count=1 -v testing
=== RUN   TestBenchmarkBLoopIterationCorrect
    testing_test.go:978: /var/folders/yn/rz8r25f10z5fmwdg34tz6z1c0000gn/T/go-build2068115649/b001/testing.test -test.run=^BenchmarkBLoopPrint$ -test.bench=BenchmarkBLoopPrint -test.v -test.parallel=2 -test.benchtime=2x: <nil>
        goos: darwin
        goarch: arm64
        pkg: testing
        cpu: Apple M4 Pro
        BenchmarkBLoopPrint
            testing_test.go:1020: Ramping up from BenchmarkBLoopPrint
            testing_test.go:1022: Printing from BenchmarkBLoopPrint
            testing_test.go:1022: Printing from BenchmarkBLoopPrint
        BenchmarkBLoopPrint            2          4729 ns/op
        PASS
    testing_test.go:995: Missing benchmark output
--- FAIL: TestBenchmarkBLoopIterationCorrect (0.01s)
FAIL
FAIL    testing 0.164s
FAIL

Also see https://ci.chromium.org/b/8729873930854023953/test-results as an example where a builder is running into this. (CC @golang/plan9.)


The regexp added in CL 630455 (CC @JunyangShao) seems to require a -n suffix after the benchmark name, but that suffix isn't included when n is 1.

gabyhelp commented 6 hours ago

Related Issues

Related Code Changes

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

gopherbot commented 3 hours ago

Change https://go.dev/cl/632655 mentions this issue: testing: consider -N suffix after benchmark name optional