Questions tagged [pprof]

pprof is a golang package used to profile various runtime properties of golang's http server.

Golang's pprof package serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool.

The package is typically only imported for the side effect of registering its HTTP handlers. The handled paths all begin with /debug/pprof/.

To use pprof, link this package into your program:

import _ "net/http/pprof"

If your application is not already running an http server, you need to start one. Add "net/http" and "log" to your imports and the following code to your main function:

go func() {
    log.Println(http.ListenAndServe("localhost:6060", nil))
}()

Then use the pprof tool to look at the heap profile:

go tool pprof http://localhost:6060/debug/pprof/heap

Useful links

133 questions
1
vote
2 answers

Go GC responsible for 90% of CPU time

I'm writing a virtual machine for a simple, made-up programming language in Go. I'm using the profiler pprof to improve performance. I'm running the Fibonacci function in my made up language to test recursive functions. func fib(n) { if n < 2 { …
Francis
  • 53
  • 6
1
vote
0 answers

Why read and write slice in multi-goroutine cost a lot in go?

I have written a multi-goroutine version's mergeSort by go, and I also wrote a benchmark test. Now I want to use "go tool pprof" to analyze the bottleneck of my code. When I got the cpu profile, I use "top10" in pprof to get the following…
cwcing
  • 101
  • 1
  • 3
1
vote
1 answer

How can I get samples when running go with pkg/profile enabled?

I have the following in my main block: func main() { defer profile.Start().Stop() fmt.Println("running version", version, "built on", date) fmt.Println() cmd.Execute() time.Sleep(2 * time.Second) } where cmd is a cobra…
Geo
  • 93,257
  • 117
  • 344
  • 520
1
vote
0 answers

How to do benchmark on CGO tcp server?

I finished a TCP server by using CGO. Now I wish to do some benchmark analysis and optimization. The connection flow across Go and C is as follows: user <--> connFD <--> socketpair[0] <--> socketpair[1] <--> intranet server |---------- Go domain…
Changkun
  • 1,502
  • 1
  • 14
  • 29
1
vote
1 answer

Golang pprof full call graph

I'm kinda new to pprof. I've started CPU profiling, and after a bit of time checked the top25. This is what I got: Showing top 25 nodes out of 174 flat flat% sum% cum cum% 1.01mins 21.92% 21.92% 1.10mins 23.83% …
Andrew
  • 2,063
  • 3
  • 24
  • 40
1
vote
0 answers

understanding go pprof result

I have Go code and I have written unit test for it. The test runs for 6.5 sec and it creates huge CPU load. I am running tests in docker container and its CPU usage reaches at 400-500%. I got cpuprofile and it shows following result: (pprof)…
Rohanil
  • 1,717
  • 5
  • 22
  • 47
1
vote
0 answers

TCMalloc memory leak debugging

I've compiled an application with tcmalloc and used HEAPPROFILE environment variable to get heap files every 10MB or so a new heap file is created and according to the tcmalloc page i can use the pprof tool to compare heap files, and see what are…
user3696279
  • 99
  • 1
  • 5
1
vote
0 answers

error occured while generating flamegraph for CPU profiling in ubuntu using uber torch tool: no stack counts found

Image show the pprof command and uber-torch command to visualise flamegraph:
Amit Pawar
  • 11
  • 3
1
vote
1 answer

glob.func in pprof heap profiles

When doing a heap profile using go tool pprof, I see some entries like github.com/anacrolix/utp.glob.func1. This doesn't correspond to any named function I can see, I assume it's a closure. What does glob refer to? How can I associate names like…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
1
vote
1 answer

Golang: How to get computing time using pprof within a web server

I have built a web server and did an ab(apache benchmark) test. Now I want to know the computing time of each part. I used the go tool pprof url:port/xxx and get the profile of this program, but it does not tell me the computing time(only has…
Wyatt
  • 141
  • 1
  • 2
  • 9
1
vote
1 answer

Golang profiling simple example for training purposes

I'm doing Go training in my company and I want to present in best way pprof package. I think that My example isn't good enough to simply present power of pprof. I want to use only go std library. Code should give me simplier call graph with some…
Jacek Wysocki
  • 1,070
  • 11
  • 24
1
vote
1 answer

go tool pprof using application PID instead of http endpoint

Right now, I profile Go applications using go tool pprof like this: go tool pprof http://localhost:8080/debug/pprof/profile I want to use the pprof tool on an arbitrary Go process which is running a http server on an unknown port. The only…
Ben Sandler
  • 2,223
  • 5
  • 26
  • 36
1
vote
2 answers

Why does `go tool pprof` show addresses instead of function names?

$ go tool pprof pgears.go profilefile.prof addr2line: crackhdr: unknown header type Welcome to pprof! For help, type 'help'. (pprof) top Total: 8 samples 5 62.5% 62.5% 5 62.5% 0000000000028a8b 1 12.5% 75.0% 1 12.5%…
lincolnge
  • 1,037
  • 14
  • 19
1
vote
1 answer

The pprof heap report displays raw memory addresses

Following this guide http://golang.org/pkg/net/http/pprof/, i'm trying to look at the heap report. When i navigate to the appropriate url, this is what is displayed: I tried this with ActivePerl, StrawberryPerl and the Perl coming with MSYS tools.…
Dante
  • 10,722
  • 16
  • 51
  • 63
1
vote
0 answers

How to display symbols in stack trace of google-perftools heap profiler

We're using google-perftools heap profiler in a TDD environment. We get the heap dump at the end that we can use pprof to see the hot spots. It shows the symbols but gives little to no information about how the leak is reached in the stack. In fact,…
William
  • 337
  • 4
  • 14
1 2 3
8 9