-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/build/cmd/coordinator: TestForeachLineAllocs fails after builders deployed #33949
Comments
I can't reproduce locally on
I understand it's intentional. It's a check that there are absolutely zero allocations. The 0.1 value is an arbitrary number that's greater than 0. See https://github.com/bradfitz/iter/blob/33e6a9893b0c090a6ba5a4227a98c4145c61d09a/iter_test.go#L25-L34 for another example. /cc @bradfitz |
That was old defensive style prior to this: https://golang.org/doc/go1.2#minor_library_changes ...
|
Interestingly, it only fails the first few iterations:
Same behavior with Go 1.12. I think there's a goroutine running concurrently with this test and that goroutine is allocating, confusing AllocsPerRun. |
Yeah, @dmitshur's https://go-review.googlesource.com/c/build/+/185981 starts up a goroutine that HTTP fetches tip.golang.org in init, even during tests. |
🤦♂ Nice find, Brad. Good news is that it's not a regression in |
Change https://golang.org/cl/192377 mentions this issue: |
Change https://golang.org/cl/192680 mentions this issue: |
Adding health checks at init is inflexible and earlier than neccessary. It can cause problems for tests that run at the same time. It also reduces code readability because it's harder to tell the relative order of events during program initialization. Instead, make it happen in main and inside relevant tests only. Also pass a context through to help with cleaning up resources after tests are done. Updates golang/go#33949 Change-Id: Ib5ff6d93d200c273f2d344f6dd9179a7ad8e5db7 Reviewed-on: https://go-review.googlesource.com/c/build/+/192377 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alexander Rakoczy <alex@golang.org>
It's a good idea to have an allocation test for the foreachLine helpers to ensure their zero-allocation property isn't accidentally compromised. Such tests turned out not to be compatible with large packages that have many existing high-level tests, some of which start HTTP servers and/or clients and miscellenous goroutines, and in turn leak goroutines beyond test execution that may cause allocations in the background, leading to inaccurate reports from testing.AllocsPerRun. In general, a best practice is to write tests that clean up all their resources after completion, but cmd/coordinator is large and optimized for a single execution. Future changes may be done in a way that will cause TestForeachLineAllocs to fail intermittently again. As a future-proof and simple solution, just factor out the foreachLine helpers into a small, dedicated internal package. Fixes golang/go#33949 Change-Id: I664ec27f2b97c47a1cc88e5428152046187dbc36 Reviewed-on: https://go-review.googlesource.com/c/build/+/192680 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alexander Rakoczy <alex@golang.org>
Adding health checks at init is inflexible and earlier than neccessary. It can cause problems for tests that run at the same time. It also reduces code readability because it's harder to tell the relative order of events during program initialization. Instead, make it happen in main and inside relevant tests only. Also pass a context through to help with cleaning up resources after tests are done. Updates golang/go#33949 Change-Id: Ib5ff6d93d200c273f2d344f6dd9179a7ad8e5db7 Reviewed-on: https://go-review.googlesource.com/c/build/+/192377 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alexander Rakoczy <alex@golang.org>
While testing if #33928 was resolved, the
cmd/coordinator/status_test.go:TestForEachLineAllocs
test started failing with significantly more allocs than the threshold.From: https://go-review.googlesource.com/c/build/+/192103/1#message-cfc755e443676448b10e0301816edb916bd386ac
Failing test:
The test in question was introduced in https://go-review.googlesource.com/c/build/+/185981. It looks like it is mistakenly expecting a non-integral value from
testing.AllocsPerRun
, which returns afloat64
that is actually always an integral value.It's still surprising that allocs would be as high as 220, as locally testing.AllocsPerRun returns 0 when I run this test on linux-amd64 go1.13rc2. I also tested on older releases of Go, and cannot reproduce this failure localy.
The text was updated successfully, but these errors were encountered: