google / pprof

pprof is a tool for visualization and analysis of profiling data
Apache License 2.0
7.98k stars 607 forks source link

Don't work -source_path flag in go tool pprof #472

Closed ilya-korotya closed 5 years ago

ilya-korotya commented 5 years ago

I try make profiling application via go tool pprof. I have profile.out from docker container. And I try run pprof locally:

go tool pprof -source_path=/home/korotya-ilya highloadcup_2018 profile.out

But when I try run list command I got error:

(pprof) list changeSymbol 
Total: 1.73s
ROUTINE ======================== github.com/ilya-korotya/highloadcup_2018/postgres.changeSymbol in /go/src/github.com/ilya-korotya/highloadcup_2018/postgres/init.go
         0      640ms (flat, cum) 36.99% of Total
 Error: open /go/src/github.com/ilya-korotya/highloadcup_2018/postgres/init.go: no such file or directory

Locally path to project: ~/go/src/github.com/ilya-korotya/highloadcup_2018

Local go env:

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/korotya-ilya/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/korotya-ilya/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build654244657=/tmp/go-build -gno-record-gcc-switches"

System:

Linux korotya-ilya 4.15.0-50-generic #54-Ubuntu SMP Mon May 6 18:46:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
aalexand commented 5 years ago

Does pprof included in the Go version you use support the -trim-path option? If not, locating absolute paths won't work, you'll have to make sure the paths inside and outside the container match exactly (which is the easiest thing to do anyway, I think). Or use pprof from head of this repo.

If you do use pprof that supports the -trim-path option, try something like -source-path=/home/korotya-ilya/go/src, that should be enough to set -trim-path to a good default using the basename heuristic. Or be more explicit as -trim-path=/go/src/ -source-path=/home/korotya-ilya/go/src/.

ilya-korotya commented 5 years ago

Sorry. That's my fault. I did not notice that I have a missing -trim-path flag. I close the issue.

jordy1024 commented 2 years ago

@ilya-korotya
What does the final working cmd look like? Can you share it in full?

yudidi commented 2 years ago

@ilya-korotya Hello, What does the final working cmd look like? Can you share it in full?

jamslinger commented 2 years ago

Thx, this worked for me: go tool pprof -trim_path=/build/ -source_path=~/app/ out.prof