fgprof icon indicating copy to clipboard operation
fgprof copied to clipboard

The flame graph is incorrect when using go 1.23.

Open manchurio opened this issue 6 months ago • 1 comments

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.

image

As a comparison, this is for Go 1.22.

image

manchurio avatar Aug 20 '24 08:08 manchurio