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
20
votes
2 answers

Pprof and golang - how to interpret a results?

I am trying to use pprof on my program, however, I have slightly different results from articles I read (links below). In my results, I am getting such table: (pprof) top10 1.65s of 1.72s total (95.93%) Showing top 10 nodes out of 114 (cum >=…
Sławosz
  • 11,187
  • 15
  • 73
  • 106
20
votes
4 answers

Can't use go tool pprof with an existing server

I have an existing http server which I would like to profile. I have included _ "net/http/pprof"to my imports, and I already have http server running: router := createRouter() server := &http.Server { Addr: ":8080", Handler: …
Max Malysh
  • 29,384
  • 19
  • 111
  • 115
17
votes
1 answer

How to optimize golang program that spends most time in runtime.osyield and runtime.usleep

I've been working on optimizing code that analyzes social graph data (with lots of help from https://blog.golang.org/profiling-go-programs) and I've successfully reworked a lot of slow code. All data is loaded into memory from db first, and the data…
Aaron
  • 666
  • 1
  • 7
  • 23
16
votes
3 answers

How to profile benchmarks using the pprof tool?

I want to profile my benchmarks generated by go test -c, but the go tool pprof needs a profile file usually generated inside the main function like this: func main() { flag.Parse() if *cpuprofile != "" { f, err :=…
Salah Eddine Taouririt
  • 24,925
  • 20
  • 60
  • 96
12
votes
1 answer

Using pprof with gperftools resulting in curl error

So I have been doing the following: $ pprof /bin/ls ls.prof Using local file /bin/ls. Gathering CPU profile from http://ls.prof/pprof/profile?seconds=30 for 30 seconds to /home/user/csteifel/pprof/ls.1414597606.ls.prof Be patient... curl: (7)…
csteifel
  • 2,854
  • 6
  • 35
  • 61
11
votes
1 answer

How to interpret pprof output?

I'm trying to profile an application written in go which apparently uses about 256 virtual memory (checked using ps aux). I'm trying to use pprof package and see what functions allocate/consume most of the memory but the results make no sense to me.…
Anthony Hunt
  • 1,470
  • 5
  • 20
  • 32
11
votes
2 answers

How to use pprof in Go program

How to use pprof in Go program? There is a Go package named net/http/pprof,but I can't use it. The document says go tool pprof http://localhost:6060/debug/pprof/heap ,which does not work. And,what does the below _ mean? import _ "net/http/pprof"
Codefor
  • 1,318
  • 2
  • 13
  • 22
10
votes
2 answers

Golang: What is etext?

I've started to profile some of my Go1.2 code and the top item is always something named 'etext'. I've searched around but couldn't find much information about it other than it might relate to call depth in Go routines. However, I'm not using any…
Bill
  • 25,119
  • 8
  • 94
  • 125
9
votes
1 answer

Interpreting pprof heap diagrams

When I profile the heap in go with pprof I get the following: However, I'm not clear on how to interpret that visualization. In particular: "The memory next to the arrows means _____ and the memory inside of a box means ______. So when a box has…
Kyle Brandt
  • 26,938
  • 37
  • 124
  • 165
9
votes
1 answer

golang tool pprof not working properly - same broken output regardless of profiling target

I've previously used the pprof tool without issue and it worked great - now I see output like the following no matter what I profile: the application being profiled in this example probably makes 40+ function calls and even more complex apps are…
SwiftD
  • 5,769
  • 6
  • 43
  • 67
8
votes
1 answer

is it ok to use golang pprof on production without effecting performance?

I'm kind of new to the pprof tool, and am wondering if its ok to keep running this in production. From the articles I have seen, it seems to be ok and standard, however I'm confused as to how this does not affect performance since it does a…
pandith padaya
  • 1,643
  • 1
  • 10
  • 20
8
votes
1 answer

golang - net/http/pprof doesn't work

I have customer http service: s := &http.Server{ Addr: config.Port, Handler: Controller.Log(http.DefaultServeMux), ReadTimeout: 3 * time.Second, WriteTimeout: 3 * time.Second, } …
leiyonglin
  • 6,474
  • 12
  • 36
  • 41
7
votes
1 answer

what would cause go to spend so much time in runtime.pthread_cond_signal

I have written a multi-goroutine benchmark test in go. And I use the go tool pprof to analyze how to optimize my code. When I use top10 to show some information, I got the following outputs: Showing top 10 nodes out of 167 flat flat% sum% …
cwcing
  • 101
  • 1
  • 3
7
votes
1 answer

Show counts of function calls in golang pprof

For profing program I use the following command: go tool pprof http://localhost:6060/debug/pprof/profile As a result in web mode I get this picture: How is it possible to show the number of function calls, not the time spent inside of this…
Kenenbek Arzymatov
  • 8,439
  • 19
  • 58
  • 109
7
votes
2 answers

pprof fails to locate source files when running over http

I am running remote profiling of my golang application on a remote server using "net/http/pprof". I have set PPROF_BINARY_PATH env variable for go tool to be able to find my the local binary on my machine. When I use the "list" keyword in the go…
OhadBasan
  • 797
  • 6
  • 15
1
2 3
8 9