pkg / profile

Simple profiling for Go
BSD 2-Clause "Simplified" License
2k stars 122 forks source link

parsing profile: unrecognized profile format under MacOs Sierra 10.12.5 #41

Closed nsitbon closed 7 years ago

nsitbon commented 7 years ago

Hi, I'm trying to profile my application using your package following the documentation. I have a cpu.pprof non empty file generated but pprof is unable to read it

$ go tool pprof —pdf ./app /var/folders/x7/wnp2zjn563j2dr45dsfpvdz80000gn/T/profile464041113/cpu.pprof > out.pdf              nsitbon@mac-ns
parsing profile: unrecognized profile format

I've tried multiple configuration from the default one defer profile.Start().Stop() to a more elaborated defer profile.Start(profile.BlockProfile, profile.MemProfile, profile.CPUProfile).Stop() but pprof is still unable to parse it. Any ideas?

FYI

$ go version                                                                                                                  
go version go1.8.3 darwin/amd64

Thanks

davecheney commented 7 years ago

Which version of Go?

On Tue, 4 Jul 2017, 19:10 Sitbon notifications@github.com wrote:

Hi, I'm trying to profile my application using your package following the documentation. I have a cpu.pprof non empty file generated but pprof is unable to read it

go tool pprof —pdf ./app /var/folders/x7/wnp2zjn563j2dr45dsfpvdz80000gn/T/profile464041113/cpu.pprof > out.pdf nsitbon@mac-ns parsing profile: unrecognized profile format

I've tried multiple configuration from the default one defer profile.Start().Stop() to a more elaborated defer profile.Start(profile.BlockProfile, profile.MemProfile, profile.CPUProfile).Stop() but pprof is still unable to parse it. Any ideas?

Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pkg/profile/issues/41, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcA7rEoKNfqur-2ZNzOBbGL-pSZDlgks5sKgGYgaJpZM4ONFsh .

nsitbon commented 7 years ago
$ go version                                                                                                                  
go version go1.8.3 darwin/amd64
davecheney commented 7 years ago

Can you please double check the versino of Go that built ./app.

https://dave.cheney.net/2017/06/20/how-to-find-out-which-go-version-built-your-binary

If that's as expected, please try this set of commands and see if it they work

go test bytes -bench=String -cpuprofile=/tmp/c.p 
go tool pprof ./bytes.test /tmp/c.p
davecheney commented 7 years ago

Also please reread the advice in the package not to enable multiple profiles at one time. It won't do what you want.

On Tue, Jul 4, 2017 at 7:56 PM, Sitbon notifications@github.com wrote:

$ go version go version go1.8.3 darwin/amd64

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pkg/profile/issues/41#issuecomment-312837013, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcA5tx7--KJhum7s_2CXz2F5Trn7RZks5sKgxegaJpZM4ONFsh .

nsitbon commented 7 years ago
(lldb) run
Process 48238 launched: './app' (x86_64)
Process 48238 stopped
* thread #6, stop reason = breakpoint 1.1
    frame #0: 0x00000000013a6714 app`main.main at main.go:16
   13   )
   14
   15   func main() {
-> 16       defer profile.Start(profile.BlockProfile, profile.MemProfile, profile.CPUProfile).Stop()
   17       suffixRepo := suffixRepository.New()
   18       sequenceRepo := sequenceRepository.New(getSequenceFilePath())
   19       defer sequenceRepo.Close()
(lldb) p runtime.buildVersion
(string) runtime.buildVersion = "go1.8.3"

I tried the two commands above and it works this time.

davecheney commented 7 years ago

Can you share the source of ./app with me, perhaps the profile is not being written properly.

On Tue, 4 Jul 2017, 22:31 Sitbon notifications@github.com wrote:

(lldb) run Process 48238 launched: './app' (x86_64) Process 48238 stopped

  • thread #6, stop reason = breakpoint 1.1 frame #0: 0x00000000013a6714 app`main.main at main.go:16 13 ) 14 15 func main() { -> 16 defer profile.Start(profile.BlockProfile, profile.MemProfile, profile.CPUProfile).Stop() 17 suffixRepo := suffixRepository.New() 18 sequenceRepo := sequenceRepository.New(getSequenceFilePath()) 19 defer sequenceRepo.Close() (lldb) p runtime.buildVersion (string) runtime.buildVersion = "go1.8.3"

I tried the two commands above and it works this time.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/pkg/profile/issues/41#issuecomment-312866141, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcAzjLhDcsy9zD21J_T7LXvVTDPUBpks5sKjCzgaJpZM4ONFsh .

nsitbon commented 7 years ago

Yep sure I was able to reproduce the bug with this pruned code:

package main

import (
    "github.com/pkg/profile"
    "github.com/gin-gonic/gin"
)
func main() {
    defer profile.Start().Stop()
    r := newHttpServer()
    r.Run(":8080")
}

func newHttpServer() *gin.Engine {
    r := gin.Default()
    r.GET("/admin/isHealthy", func(c *gin.Context){c.Status(200)})
    return r
}
% ~/go/bin/godep go build -o app ./main2.go
±|master ✘| identifier-generator-hp
% ./app
profile: cpu profiling enabled, /var/folders/x7/wnp2zjn563j2dr45dsfpvdz80000gn/T/profile467765493/cpu.pprof
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /admin/isHealthy          --> main.newHttpServer.func1 (3 handlers)
[GIN-debug] Listening and serving HTTP on :8080
^Cprofile: caught interrupt, stopping profiles
profile: cpu profiling disabled, /var/folders/x7/wnp2zjn563j2dr45dsfpvdz80000gn/T/profile467765493/cpu.pprof
±|master ✘| identifier-generator-hp
% go tool pprof —text ./app /var/folders/x7/wnp2zjn563j2dr45dsfpvdz80000gn/T/profile467765493/cpu.pprof > out.txt
parsing profile: unrecognized profile format
davecheney commented 7 years ago

Does it work with just straight

Go tool pprof ./app /tmp/.../profile?

On Tue, 4 Jul 2017, 22:53 Sitbon notifications@github.com wrote:

Yep sure I was able to reproduce the bug with this pruned code:

package main import ( "github.com/pkg/profile" "github.com/gin-gonic/gin" )func main() { defer profile.Start().Stop() r := newHttpServer() r.Run(":8080") } func newHttpServer() gin.Engine { r := gin.Default() r.GET("/admin/isHealthy", func(c gin.Context){c.Status(200)}) return r }

% ~/go/bin/godep go build -o app ./main2.go±|master ✘| identifier-generator-hp % ./appprofile: cpu profiling enabled, /var/folders/x7/wnp2zjn563j2dr45dsfpvdz80000gn/T/profile467765493/cpu.pprof[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) [GIN-debug] GET /admin/isHealthy --> main.newHttpServer.func1 (3 handlers)[GIN-debug] Listening and serving HTTP on :8080^Cprofile: caught interrupt, stopping profilesprofile: cpu profiling disabled, /var/folders/x7/wnp2zjn563j2dr45dsfpvdz80000gn/T/profile467765493/cpu.pprof±|master ✘| identifier-generator-hp % go tool pprof —text ./app /var/folders/x7/wnp2zjn563j2dr45dsfpvdz80000gn/T/profile467765493 > out.txt

parsing profile: unrecognized profile format

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/pkg/profile/issues/41#issuecomment-312870531, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcA_OZUZOMcbUXdQM__sdtFKOg1vg2ks5sKjWxgaJpZM4ONFsh .

nsitbon commented 7 years ago
% go tool pprof ./app /var/folders/x7/wnp2zjn563j2dr45dsfpvdz80000gn/T/profile467765493/cpu.pprof                             nsitbon@mac-ns
Entering interactive mode (type "help" for commands)
(pprof)

but I don't know what to do. When I said your version above (with the 2 commands) worked I mean I got the same thing as now.

davecheney commented 7 years ago

Ok, it looks like nothing is wrong with the profile generated by this package or go test, so maybe the go team broke something with pprof in 1.8.

Please raise a bug on golang/go

On Tue, 4 Jul 2017, 22:57 Sitbon notifications@github.com wrote:

% go tool pprof ./app /var/folders/x7/wnp2zjn563j2dr45dsfpvdz80000gn/T/profile467765493/cpu.pprof nsitbon@mac-nsEntering interactive mode (type "help" for commands)(pprof)

but I don't know what to do. When I said your versions above (with the 2 commands) worked I mean I got the same thing as now.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/pkg/profile/issues/41#issuecomment-312871527, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcAwbHVyHVcCpXONH2AWuJhiR2tlH7ks5sKjbSgaJpZM4ONFsh .

nsitbon commented 7 years ago

Ok thank you Dave.