parsing profile: unrecognized profile format under MacOs Sierra 10.12.5
nsitbon opened this issue · comments
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
$ go version
go version go1.8.3 darwin/amd64
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
(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.
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
% 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.
Ok thank you Dave.