From a4440e3d236dc2ca65851c39a51958cc1b3c03fb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20Geisend=C3=B6rfer?= Date: Tue, 2 Apr 2024 10:13:32 +0200 Subject: [PATCH] net/http: speed up go test Optimize the execution speed of go test ./net/http from ~38s to ~28s. This is achieved by shortening the sleep interval utilized for identifying goroutine leaks. This optimization is motivated by noticing significant periods of inactivity in the -trace output. Even after applying this CL, many Off-CPU wait periods seem to remain: $ go test ./net/http ok net/http 27.744s real 0m28.204s user 0m4.991s sys 0m1.797s Change-Id: I6108ebbb715c33900f1506d810c0a8f8ed674d35 Reviewed-on: https://go-review.googlesource.com/c/go/+/575975 Reviewed-by: Damien Neil Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI Auto-Submit: Damien Neil --- src/net/http/main_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net/http/main_test.go b/src/net/http/main_test.go index 9022d4f124..4c18320717 100644 --- a/src/net/http/main_test.go +++ b/src/net/http/main_test.go @@ -142,7 +142,7 @@ func afterTest(t testing.TB) { ").noteClientGone(": "a closenotifier sender", } var stacks string - for i := 0; i < 10; i++ { + for i := 0; i < 2500; i++ { bad = "" stacks = strings.Join(interestingGoroutines(), "\n\n") for substr, what := range badSubstring { @@ -156,7 +156,7 @@ func afterTest(t testing.TB) { } // Bad stuff found, but goroutines might just still be // shutting down, so give it some time. - time.Sleep(250 * time.Millisecond) + time.Sleep(1 * time.Millisecond) } t.Errorf("Test appears to have leaked %s:\n%s", bad, stacks) } -- 2.48.1