testing: completed parallel subtests leak goroutines until earlier subtests finish #45127
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Looking at the goroutine dump in https://build.golang.org/log/a70cdaaff0171cc2515eac00f3e909829c7309c2, there is a huge amount of useless noise from blocked goroutines.
Many of the goroutines are blocked on
t.Parallel()
, for which I may file a separate issue. However, many of them are blocked — for many minutes at a time! — waiting to notify the parent that the subtest is complete.~279 copies in the linked test output:
~123 copies:
The blocked channel send for both of those traces is here:
go/src/testing/testing.go
Lines 1163 to 1166 in 9289c12
The purpose of the channel seems to be to keep the parent test blocked until the subtest either finishes or calls
t.Parallel
:go/src/testing/testing.go
Line 1086 in 9289c12
If the subtest calls
t.Parallel
, the subtest is added to thesub
field for the parent test:go/src/testing/testing.go
Lines 1045 to 1046 in 3979fb9
The parent later waits for the parallel subtests to complete:
go/src/testing/testing.go
Lines 1158 to 1161 in 3979fb9
It is not at all obvious to me why the
t.signal
channel is unbuffered. The sender does not appear to care whether the parent has actually received the signal, and does not appear to do any additional work after the send that would require synchronizing on it.For tests with a lot of parallel subtests, such as
cmd/go.TestScript
, the amount of noise introduced by this (temporary) leak can be quite significant.The text was updated successfully, but these errors were encountered: