spiermar / burn

burn :fire: is a CLI tool to convert performance profiles to hierarchical data structures that can be visualized as flame graphs
Apache License 2.0
84 stars 8 forks source link

Parsing perf_events data fails due to an empy stack in perf.out #12

Closed jvnn closed 4 years ago

jvnn commented 4 years ago

Hi, just ran into this while trying out burn:

It seems that perf can in some cases produce empty stacks like this in perf script output:

         [... previous stack ...]
         8478b48f58948fb [unknown] ([unknown])

nginx 13444 12560.036548:     649918 cycles:ppp:

nginx 13444 12560.036810:     654301 cycles:ppp:
            7fffad2da0f9 __tcp_push_pending_frames ([kernel.kallsyms])
            7fffad2c677b tcp_push ([kernel.kallsyms])
            7fffad2ca098 tcp_sendmsg_locked ([kernel.kallsyms])
            [...]

When trying to convert this (with the latest prebuilt binary), burn fails with a panic:

user@92cdb21822ae:~$ ./burn convert --html --output=/data/flame.html out.perf
panic: Invalid format.

goroutine 1 [running]:
github.com/spiermar/burn/convert.ParsePerf(0xa476e0, 0xc42000c120, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/mspier/Workspace/go/src/github.com/spiermar/burn/convert/perf.go:104 +0xa80
github.com/spiermar/burn/cmd.glob..func1(0xa794c0, 0xc42006fd70, 0x1, 0x3)
    /Users/mspier/Workspace/go/src/github.com/spiermar/burn/cmd/convert.go:80 +0x2a6
github.com/spf13/cobra.(*Command).execute(0xa794c0, 0xc42006fcb0, 0x3, 0x3, 0xa794c0, 0xc42006fcb0)
    /Users/mspier/Workspace/go/src/github.com/spf13/cobra/command.go:653 +0x299
github.com/spf13/cobra.(*Command).ExecuteC(0xa79700, 0xc4200160b8, 0x0, 0xc42008a2d0)
    /Users/mspier/Workspace/go/src/github.com/spf13/cobra/command.go:728 +0x339
github.com/spf13/cobra.(*Command).Execute(0xa79700, 0x0, 0x0)
    /Users/mspier/Workspace/go/src/github.com/spf13/cobra/command.go:687 +0x2b
github.com/spiermar/burn/cmd.Execute()
    /Users/mspier/Workspace/go/src/github.com/spiermar/burn/cmd/root.go:79 +0x31
main.main()
    /Users/mspier/Workspace/go/src/github.com/spiermar/burn/main.go:20 +0x20
jvnn commented 4 years ago

Just saw that you've already made a commit with message "fix: empty perf stack", so that'll likely fix the problem. Unfortunately I can't easily try the go code directly as my go version is 1.6.2 which seems to lack the necessary math/bits package:

user@7b50333ae28f:/gostuff/src/github.com/spiermar/burn$ GOPATH=/gostuff go build
../../../golang.org/x/sys/unix/affinity_linux.go:10:2: cannot find package "math/bits" in any of:
    /usr/lib/go-1.6/src/math/bits (from $GOROOT)
    /gostuff/src/math/bits (from $GOPATH)
jvnn commented 4 years ago

To continue my monologue... :)

It seems ubuntu containers use an ancient version by default, I ran the build in a new container with go 1.12.10 and everything works fine with the newest code. Thus closing the issue.