testing: Benchmark calls during benchmarks deadlock #29727
Labels
Comments
Are calls to |
Current doc states
Should this be corrected to something that specifies it should only be used for those cases that do not use "go test" or it is clear enough and I just misread it? |
What is the proper way to compare speeds of functions as a part of go test? If I want to average a bunch of separate benchmarks together for example of different file sizes what would be the proper way to do it? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Called testing.Benchmark in a Benchmark. The reason for this is that I wanted to check during benchmarks which one of two possible implementations would be faster on the current machine and for a set of given inputs.
Here is a minimal repro that should be run as a benchmark to crash (must be in *_test.go and should be run with
go test -bench=.
)What did you expect to see?
"Difference between executions is ~1ns
What did you see instead?
Probable cause
During the first iteration of
benchFunc
run1
is executed.run1
invokesrunN
which will runrun1
. The issue is thatrunN
tries to acquire a global lock while holding it, causing the deadlock.Source for
runN
:Source for
run1
:The text was updated successfully, but these errors were encountered: