CPU profiling with pprof

135 views
Skip to first unread message

Vincent Blanchon

unread,
Sep 6, 2019, 11:36:40 PM9/6/19
to golang-nuts
Hi,

The documentation of the profiling (https://blog.golang.org/profiling-go-programs) explains that: "Go program stops about 100 times per second".
However, in the code, I could see that the collector has a sleep of 100ms https://github.com/golang/go/blob/master/src/runtime/pprof/pprof.go#L779. Therefore, it collects data only 10 times per second?
Also, it does not stop the program since it is a separated goroutine https://github.com/golang/go/blob/master/src/runtime/pprof/pprof.go#L764.

Did I miss something here?

Jake Montgomery

unread,
Sep 7, 2019, 11:41:58 AM9/7/19
to golang-nuts
I can not speak to your specific issues, but I would point out that the link you referenced as  "the documentation of the profiling", is not the technical documentation. It is simply an informative blog post. It was also written in 2011 and last updated in 2013. Given those two things, I would not be surprised if it was out of date.

Ian Lance Taylor

unread,
Sep 10, 2019, 1:12:22 AM9/10/19
to Vincent Blanchon, golang-nuts
The actual profile data is collected by the code in runtime/cpuprof.go
and runtime/profBuf.go. That data is generated 100 times per second.
The code you are looking at in the runtime/pprof package is the code
that is collecting that data, which is generated at interrupt time,
and converting it into a format that can be reported to the user or
the pprof program.

Ian
Reply all
Reply to author
Forward
0 new messages