Description
Proposal Details
tl;dr: Can we show something more descriptive than go.shape.*uint8
for generic methods invoked on a struct pointer Maybe go.shape.uintptr
or the element type?
While profiling is primarily seen as a performance tool, we often see it used for understanding the control flow of Go applications at runtime. In particular, profiling can be very useful to reveal which concrete types are being invoked behind an interface or a generic function call.
In one particular case @g-talbot recently tried to figure out the concrete type parameter for a generic function call, and to our surprise we saw the type being called go.shape.*uint8
which was confusing since it doesn't correspond to any of the types satisfying the type constraints of the generic functions. We would have expected to see something more like *SomeStruct
instead.
After a bit of digging, my colleague @nsrip-dd discovered that this output is probably intentional (source), but we're wondering if it could be made more user-friendly. Either by clarifying that the type is an unknown pointer type (go.shape.uintptr
) or by showing the actual type.
Below is a minimal example that shows how to end up with a go.shape.*uint8
inside of a CPU profile:
package main
import "testing"
func BenchmarkContainer(b *testing.B) {
d := &Container[*Node]{}
for i := 0; i < b.N; i++ {
d.Add(nil)
}
}
type Container[T any] struct{}
//go:noinline to make this frame shows up in the cpu profile.
func (d *Container[T]) Add(a T) {}
type Node struct{}
$ go test -bench . -cpuprofile cpu.pprof
$ go tool pprof -http=: cpu.pprof.
We understand that the current displayed type probably makes a lot of sense from the compiler's perspective, but seeing a uint8
type as a placeholder for a pointer type on a 64 bit system was confusing to us.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Todo