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
0 answers

Combine several google-pprof files (pproc CPU profiler)

I want to use CPU Profiler from google-perftools (gperftools's libprofiler.so ), which is described here: http://gperftools.googlecode.com/svn/trunk/doc/cpuprofile.html In my setup I want to run the program to be profiled several times (up to 1500;…
osgx
  • 90,338
  • 53
  • 357
  • 513
0
votes
0 answers

Top RES is showing more memory usage than the golang pprof-heap/runtime.MemStats

We have a golang process that internally uses CGO libraries. We are observing OOM kills for this process after some time. kernel: [322533.632311] Memory cgroup out of memory: Killed process 1895550 (grpc_latest_srvc) total-vm:3072488kB,…
samba
  • 323
  • 1
  • 4
  • 14
0
votes
0 answers

Golang heapsize remains constant but the allocations are increasing

I have a go microservice for which the resident memory consumption is constantly increasing with number of requests. I used pprof to determine whether i have any of following scenarios: increasing goroutines (remains consistent and the number drops…
Manish Gupta
  • 4,438
  • 18
  • 57
  • 104
0
votes
1 answer

How can I write go profile to file as it goes?

I am trying to profile a go application and below is the code: func main() { defer pprof.StopCPUProfile() f, err := os.Create("./profile.tar.gz") if err != nil { log.Fatal(err) } pprof.StartCPUProfile(f) ... I am…
Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523
0
votes
0 answers

PProf for C/C++ not working as expected inside Docker

I'm trying to profile some C/C++ code inside Docker using pprof from gperftools (not pprof for golang). When running it locally I have no problem. However, when running it in a Docker environment, pprof is unable to find the files/lines of the…
Benjamin Barrois
  • 2,566
  • 13
  • 30
0
votes
0 answers

Why go heap profiler shows significantly less total memory than MemStats.HeapAlloc?

I'm trying to investigate a memory leak in our service. And for some reason, while HeapAlloc grows up to 3.7gb, pprof heap profiler explains only 2.4gb. What is that 1.3gb space for? I thought, that HeapAlloc memory is exactly what heap profiler…
0
votes
0 answers

Correct way to use Go Pprof to compare execution-time differences in two versions of a same functionality

I am running a Golang project in a container environment which has two pods. Pod1: user-interaction and data-access layer. Pod2: Database server. The data-access layer involves functions like data validation, do get on db to check if data already…
Harish Reddy
  • 65
  • 1
  • 6
0
votes
0 answers

How to make pprof for tcmalloc show all allocated memory instead of only the difference to the previous dump?

I'm using libtcmalloc.so with LD_PRELOAD on some executable and it works fine. The problem is, that the output only contains the difference compared to the previous file. But I would like to see all allocated memory (and not freed) since the start…
Frank Puck
  • 467
  • 1
  • 11
0
votes
0 answers

Understanding golang cpu pprof profile times

I'm trying to optimize some parts of my Go application and profiling the CPU with pprof I got some numbers that, first of all, surprise me. It feels weird to me that lines 81, 82, and 83 are one of the slower ones. They are only applying bitwise…
Pherrymason
  • 7,835
  • 8
  • 39
  • 57
0
votes
1 answer

Why do Prometheus and Pprof disagree on memory usage?

Tried googling for this but couldn't find any answers. I was profiling my golang app and pprof showed it running around ~200 mb for inuse_space but then I checked it in Prometheus and it showed it using over 900mb of memory. I'm inclined to trust…
staticFlow
  • 141
  • 1
  • 2
  • 13
0
votes
1 answer

pprof how to get profile.pb.gz without using pprof -http

I ues pprof -http to generate profiling result all the time, but every time i need profile.pb.gz i need go to the http web to download it. what i did Is that anyway to generate profile.pb.gz with local binary,but no need to using pprof -http.
kido G
  • 1
  • 1
0
votes
2 answers

How to make go trace show every func call?

I'm trying to get a call tree with go tool trace, but it shows only top 80 functions and doesn't seem to support pprof's flags like --nodecount, etc. How can I make the traces show all nodes? And if trace isn't designed for that, how can I get a…
0
votes
1 answer

Run pprof on data collected from remote machine?

I have a program that runs on a remote headless machine (ie no X server) that has a memory leak. I was able to install gperftools and ran the heap checker which found the leak. My problem is I can't install pprof on the remote machine because of all…
zephod
  • 11
  • 1
0
votes
0 answers

Big latency on Go channel send / receive? (PProf tracing)

I was Using PProf to analyze tracing for a data pipeline with producer and consumer. I'm not sure how I should read this, but from the scheduler latency profile, chanrecv and chansend accounts for a decent portion of my total run time. I find it…
smilence
  • 349
  • 4
  • 9
0
votes
0 answers

go tool pprof list -- missed source lines

Using list command in go tool pprof sometimes some lines of code are missing. There is beginning of the function: func SlowSearch(out io.Writer) { file, err := os.Open(filePath) if err != nil { panic(err) } fileContents,…
1 2 3
8 9