-
Notifications
You must be signed in to change notification settings - Fork 18k
go test -race adds 1 second execution time to every package tested #20364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Same on tip ( I could not find a previous issue for this, and I'm surprised I never noticed this extra second. I agree that it looks like a wait/sleep, and not just extra CPU work. In the last second of my I would hope this is on purpose and supposed to catch some things in |
@mvdan's intuition is correct. You can set the sleep time to zero using an environment variable:
@dvyukov gave the reasoning for the 1s default here: https://groups.google.com/d/msg/golang-nuts/HBJQaijCwGo/P1NNQN7wyMAJ |
Thanks @cespare - having this issue in the tracker with all the info for posterity should help other people in similar situations. |
For those landing in this issue in the future, like I did just now six years later ( 😱 ), see the docs at https://go.dev/doc/articles/race_detector for the list of options accepted by |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go1.8
What operating system and processor architecture are you using (
go env
)?linux/amd64
What did you do?
creating a simple test
And then running it with
go test -race .
will add an extra second to the execution time compared to running without race. This happens for every single package tested.Ultimately this means for a test runner that runs many tests over many packages it takes much longer to run the test suite with -race than without, with every package added adding another second to the execution time
This extra second per package seems unrelated to cpu/memory/disk performance and seems uniformly one second over every machine we test with. Trom high powered machines to low powered machines.
Obviously some aspect of performance loss is expected with the race detector running but this seems unrelated to that and more related to an artificial wait being introduced before running the tests in a package. I've never seen it add less or more than one second to a test regardless of the machine.
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: