Skip to main content

Module prof

Module prof 

Source
Expand description

Sampling heap profiler.

As in jemalloc, a thread takes a sample after a random number of allocated bytes, exponentially distributed around the sample interval, so each allocation is sampled with probability 1 - exp(-size / interval). A sample records the allocation’s stack; counts per stack are scaled by the inverse of that probability, which makes them unbiased estimates of the real totals.

Sampled allocations live in chunks of their own, so a free only needs to look at the chunk header to know whether it frees a sample.

Structs§

Sample
A live sampled allocation, with the fixed point weights it added

Enums§

DumpError
Why a heap profile could not be dumped

Constants§

DEFAULT_INTERVAL
512 KiB, jemalloc’s default (lg_prof_sample:19)

Functions§

activate
Starts sampling allocations
deactivate
Stops taking new samples; live samples stay in the profile
dump_pprof
The heap profile in pprof’s protobuf format, uncompressed (pprof reads both plain and gzipped files). Its sample types follow Go’s heap profiles: alloc_objects, alloc_space, inuse_objects and inuse_space, the default.
is_active
Whether allocations are being sampled
sample_interval
The mean number of bytes between samples
set_sample_interval
Sets the mean number of bytes between samples, from 1 byte to 128 TiB; values outside are clamped
write_pprof
Writes the heap profile to path; returns its size in bytes