Skip to content

Commit c9cd1dd

Browse files
committed
Serialize simple tests for less scheduling pressure.
1 parent 0546f69 commit c9cd1dd

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/runtime/gc_test.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ func TestGoroutineLeakGC(t *testing.T) {
11081108
// Repetitions are used to amortize flakiness in some tests.
11091109
type testCase struct {
11101110
name string
1111+
simple bool
11111112
expectedLeaks map[*regexp.Regexp]bool
11121113

11131114
// flakyLeaks are goroutine leaks that are too flaky to be reliably detected.
@@ -1235,6 +1236,13 @@ func TestGoroutineLeakGC(t *testing.T) {
12351236
makeTest("NoLeakGlobal"),
12361237
}
12371238

1239+
// Set all micro tests to simple so that they are executed serially.
1240+
// This reduces scheduling pressure on the test runner, and improves
1241+
// reliability.
1242+
for i := range microTests {
1243+
microTests[i].simple = true
1244+
}
1245+
12381246
// Common goroutine leak patterns.
12391247
// Extracted from "Unveiling and Vanquishing Goroutine Leaks in Enterprise Microservices: A Dynamic Analysis Approach"
12401248
// doi:10.1109/CGO57630.2024.10444835
@@ -1255,6 +1263,13 @@ func TestGoroutineLeakGC(t *testing.T) {
12551263
`timeout\.func1.* \[chan send\]`),
12561264
}
12571265

1266+
// Set all pattern tests to simple so that they are executed serially.
1267+
// This reduces scheduling pressure on the test runner, and improves
1268+
// reliability.
1269+
for i := range patternTestCases {
1270+
patternTestCases[i].simple = true
1271+
}
1272+
12581273
// GoKer tests from "GoBench: A Benchmark Suite of Real-World Go Concurrency Bugs".
12591274
// White paper found at https://lujie.ac.cn/files/papers/GoBench.pdf
12601275
// doi:10.1109/CGO51591.2021.9370317.
@@ -1518,8 +1533,11 @@ func TestGoroutineLeakGC(t *testing.T) {
15181533

15191534
for _, tcase := range testCases {
15201535
t.Run(tcase.name, func(t *testing.T) {
1521-
// Run tests in parallel.
1522-
t.Parallel()
1536+
if !tcase.simple {
1537+
// Run complex tests in parallel. Do this because such tests
1538+
// are flaky and we do not necessarily care about their output.
1539+
t.Parallel()
1540+
}
15231541

15241542
// Run program and get output trace.
15251543
output := runBuiltTestProg(t, exe, tcase.name, "GODEBUG=asyncpreemptoff=1")

0 commit comments

Comments
 (0)