Skip to content

Commit 41884dc

Browse files
rhyshgopherbot
authored andcommitted
runtime/pprof: ignore runtime-internal samples in test
Tests of the mutex profile focus on sync.Mutex, which is easy to control. But since those tests still use the runtime, and contention on internal runtime.mutex values is now also part of the mutex profile, we have to filter out those samples before examining the profile. Otherwise the test may be confused by stray contention on sched.lock (or other runtime-internal locks) as a natural consequence of using goroutines. Fixes #67563 Change-Id: I066a24674d8b719dbeca4a5c0f76b53bc07498c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/586957 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Rhys Hiltner <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent 3989bc8 commit 41884dc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/runtime/pprof/pprof_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,14 +1349,21 @@ func TestMutexProfileRateAdjust(t *testing.T) {
13491349
}
13501350

13511351
for _, s := range p.Sample {
1352+
var match, runtimeInternal bool
13521353
for _, l := range s.Location {
13531354
for _, line := range l.Line {
13541355
if line.Function.Name == "runtime/pprof.blockMutex.func1" {
1355-
contentions += s.Value[0]
1356-
delay += s.Value[1]
1356+
match = true
1357+
}
1358+
if line.Function.Name == "runtime.unlock" {
1359+
runtimeInternal = true
13571360
}
13581361
}
13591362
}
1363+
if match && !runtimeInternal {
1364+
contentions += s.Value[0]
1365+
delay += s.Value[1]
1366+
}
13601367
}
13611368
return
13621369
}

0 commit comments

Comments
 (0)