Skip to content
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

testing: allocs not reset for single-cycle runs #20590

Closed
josharian opened this issue Jun 6, 2017 · 2 comments
Closed

testing: allocs not reset for single-cycle runs #20590

josharian opened this issue Jun 6, 2017 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@josharian
Copy link
Contributor

$ go test -bench=NewEmptyMap -benchtime=5us -run=NONE runtime
BenchmarkNewEmptyMap-8   	     100	        69.9 ns/op	       0 B/op	       0 allocs/op
$ go test -bench=NewEmptyMap -benchtime=2us -run=NONE runtime
BenchmarkNewEmptyMap-8   	       1	      3490 ns/op	  266824 B/op	    1168 allocs/op

Observe that it's not just a question of getting enough iterations for the division to work: 1168 allocs / 100 iterations = 11 allocs/op, but it is correctly reported as 0 in the first run. Something somewhere is not getting reset correctly. (The iterations does explain the variance in ns/op, but not allocs/op.)

I noticed this with tiny benchtimes and the runtime, but this could also impact benchmarks that run for longer than a second.

Reproduces with 1.8, although it is much less extreme:

$ go test -bench=NewEmptyMap -benchtime=6us -run=NONE runtime
BenchmarkNewEmptyMap-8   	     200	        52.7 ns/op	       0 B/op	       0 allocs/op
$ go test -bench=NewEmptyMap -benchtime=2us -run=NONE runtime
BenchmarkNewEmptyMap-8   	       1	      4804 ns/op	    2112 B/op	       4 allocs/op

Unclear whether this counts as a regression or not.

cc @mpvl

@josharian josharian added this to the Go1.9Maybe milestone Jun 6, 2017
@gopherbot
Copy link

CL https://golang.org/cl/46612 mentions this issue.

@bradfitz bradfitz modified the milestones: Go1.9, Go1.9Maybe Jun 28, 2017
@bradfitz
Copy link
Contributor

Has a CL, so promoting to non-maybe.

@bradfitz bradfitz added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 28, 2017
@golang golang locked and limited conversation to collaborators Jun 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants