Skip to content

runtime/pprof: fix TestGoroutineProfileDebug3Creators on linux/amd64 - #18

Merged
dt merged 1 commit into
cockroachdb:cockroach-go1.25.5from
dt:fix-goroutine-profile-debug3-creators-test
Mar 12, 2026
Merged

runtime/pprof: fix TestGoroutineProfileDebug3Creators on linux/amd64#18
dt merged 1 commit into
cockroachdb:cockroach-go1.25.5from
dt:fix-goroutine-profile-debug3-creators-test

Conversation

@dt

@dt dt commented Mar 12, 2026

Copy link
Copy Markdown

The debug=3 protobuf profile unconditionally emits go::goroutine_created_by from parentGoid, while debug=2 text output only prints "created by" when the creating function passes showframe. Allow debug=3 to be a superset of debug=2's created_by data instead of requiring an exact match.

The debug=3 protobuf profile unconditionally emits
go::goroutine_created_by from parentGoid, while debug=2 text
output only prints "created by" when the creating function passes
showframe. Allow debug=3 to be a superset of debug=2's created_by
data instead of requiring an exact match.

Fixes cockroachdb/cockroach#165528.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the goroutine profile test expectations so that debug=3 protobuf output can include additional go::goroutine_created_by labels beyond what debug=2 text output reports (due to showframe filtering), and re-enables the previously skipped test.

Changes:

  • Removed the unconditional skip for TestGoroutineProfileDebug3Creators.
  • Relaxed the assertion so debug=3 may emit created_by labels even when debug=2 did not.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1986 to 1994
if createdBy[id] == "" {
if len(got) != 0 {
t.Fatalf("goroutine %s: got created_by %q, want none", id, got)
}
// debug=3 may report created_by for goroutines whose
// creating function is filtered by showframe in debug=2
// (e.g. runtime-internal goroutines). This is expected:
// debug=3 provides a superset of debug=2's created_by data.
continue
} else {
if e := createdBy[id]; len(got) != 1 || strconv.Itoa(int(got[0])) != e {
t.Fatalf("goroutine %s: got created_by %q, want %q", id, got, e)

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if createdBy[id] == "" { continue } conflates “no entry in createdBy” with an (unexpected) empty creator value, which could hide parsing/format regressions. Consider using the map presence (e, ok := createdBy[id]) to decide whether to skip, and then compare against e.

If you want the test to more directly assert that debug=3 is a superset of debug=2, it’s also more robust to verify every createdBy entry exists in the parsed debug=3 samples (e.g., index samples by goroutine id and then iterate over createdBy), rather than iterating only over parsed.Sample.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh, I think treating empty as missing is perfectly fine for the test's purposes and a shorter, more concise test is easier to read.

@tbg tbg left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let you decide on the fate of the Copilot comment.

@dt
dt merged commit 1e00378 into cockroachdb:cockroach-go1.25.5 Mar 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants