borellini
borellini

Reputation: 422

Go CPU profile is lacking function call information

I have been trying to dive in to Go (golang) performance analysis, based on articles like https://software.intel.com/en-us/blogs/2014/05/10/debugging-performance-issues-in-go-programs .

However, in the actual profiled programs, the generated CPU profiles have very little information. The go tool either tells that the profile is empty or it has no information about any function calls. This happens on both OS X and Linux.

I generated a minimal example of this situation - I am gathering the profile in a similar manner and facing the same issues in actual programs, too.

Here's the source code for miniprofile/main.go:

package main

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

func do_something(prev string, limit int) {
    if len(prev) < limit {
        do_something(prev+"a", limit)
    }
}

func main() {
    f, err := os.Create("./prof")
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
    pprof.StartCPUProfile(f)
    defer pprof.StopCPUProfile()

    do_something("", 100000)
}

I am expecting to see a CPU profile that tells that almost all the time has been spent on different recursive calls to do_something.

However, this happens (the minimal app above is called miniprofile) - not very useful:

$ go version
go version go1.6.2 darwin/amd64
$ go install .
$ miniprofile
$ go tool pprof --text prof
1.91s of 1.91s total (  100%)
      flat  flat%   sum%        cum   cum%
     1.91s   100%   100%      1.91s   100%

Am I doing something in a horribly wrong way?

Upvotes: 0

Views: 749

Answers (1)

Mr_Pink
Mr_Pink

Reputation: 109357

You're missing the binary argument to pprof:

go tool pprof --text miniprofile prof

Upvotes: 1

Related Questions