fgprof
fgprof copied to clipboard
The flame graph is incorrect when using go 1.23.
package main
import (
"fmt"
"github.com/felixge/fgprof"
"net/http"
"os"
"time"
)
func main() {
cpuf, err := os.Create("fgprof.out")
if err != nil {
return
}
stop := fgprof.Start(cpuf, fgprof.FormatPprof)
defer stop()
for range 30 {
networkTask()
cpuTask()
}
}
func networkTask() {
resp, err := http.Get("http://google.com")
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
}
func cpuTask() {
start := time.Now()
for time.Since(start) < 100*time.Millisecond {
for i := 0; i < 10000; i++ {
_ = i
}
}
}
As shown in the image, cputask and networkTask should be at the same level, but now cpuTask is below networkTask.
As a comparison, this is for Go 1.22.
Thanks for reporting this. This might be an upstream regression, potentially in some patches submitted by my colleague and me for the go1.23 release. I'll investigate.
I can confirm that this is a regression I introduced upstream, sorry about that.
I've submitted a fix and will ask for getting it back-ported to a go1.23.x release.
Meanwhile I've created a workaround and tagged a new v0.9.5 release that contains it. Upgrading should fix the issue on your end.