Strange pink flame graphs with Google pprof

114 views Asked by At

The "new" flame graph in Google pprof is uniformly pink on my machine (Mac OS 10). Is this supposed to happen? It's not as nice as the old flame graph, so I wonder if something is not configured right on my end.

Here is the example Go program I used:

package main

import (
    "os"
    "runtime/pprof"
    "time"
)

func main() {
    // Create CPU profile file
    f, err := os.Create("cpu.pprof")
    if err != nil {
        panic(err)
    }
    defer f.Close()

    // Start CPU profiling
    pprof.StartCPUProfile(f)
    defer pprof.StopCPUProfile()

    // Simulated workload
    for i := 0; i < 100; i++ {
        Foo()
        Bar()
    }
}

func Foo() {
    time.Sleep(50 * time.Millisecond)
}

func Bar() {
    time.Sleep(100 * time.Millisecond)
}

I ran the program and started a pprof server on the output:

go run main.go
go tool pprof -http=:8080 cpu.pprof

The dropdown menu in the upper left allows me to select "Flame Graph" and "Flame Graph (new)". The former is the kind I like:

orange

The latter is not as nice:

pink

Versions etc.:

$ go version
go version go1.21.1 darwin/arm64
$ dot -V
dot - graphviz version 9.0.0 (20230911.1827)
1

There are 1 answers

2
ZeissS On

The color in the new flamegraph is determined by the package and since your profiles mainly show the runtime package, thats the single color you see.

I guess due to the sleep calls, your main goroutine is not being seen when scanning the goroutines for the traces. You could try replacing them with some more busy loops (do some floating math, calculate PI etc, build sha256 with as many 0 at the front as possible etc).

I personally nowadays prefer the new graph, as it groups multiple call sites when clicking on a stack frames and lets me see all the callers and downstream things aggregated.