On Thu, Jun 18, 2015 at 10:38 AM, <
ben1s...@gmail.com> wrote:
> Thank you for the answer! I am talking about the http/pprof package (which I
> believe wraps the runtime/pprof package).
>
> Is it true that pprof is a stop-the-world sampler? Does it periodically stop
> the program being profiled to collect information?
No.
> Is pprof a statistical/stochastic profile?
Yes.
> Is it also an event based profiler?
Yes.
> I know it doesn't run at the kernal level, but where in the OS does pprof
> profile?
As you say, the net/http/pprof package is basically a wrapper around
the runtime/pprof package.
For CPU profiling, runtime/pprof works by periodically interrupting
the program. On Unix-like systems, this is done using setitimer to
send a periodic SIGPROF signal. When this signal arrive, the
goroutine that receives it stores a stack trace. This very briefly
stops the goroutine being profiled, but it doesn't affect the rest of
the program.
For heap profiling, the memory allocator tracks the number of
allocations it has done, and periodically records a stack trace.
Ian