Start the sampling with the given parameters. Fails if sampling is already active.
The parameter sampling_rate
is the sampling rate in samples per word (including headers). Usually, with cheap callbacks, a rate of 1e-4 has no visible effect on performance, and 1e-3 causes the program to run a few percent slower
The parameter callstack_size
is the length of the callstack recorded at every sample. Its default is max_int
.
The parameter tracker
determines how to track sampled blocks over their lifetime in the minor and major heap.
Sampling is temporarily disabled when calling a callback for the current thread. So they do not need to be re-entrant if the program is single-threaded. However, if threads are used, it is possible that a context switch occurs during a callback, in this case the callback functions must be re-entrant.
Note that the callback can be postponed slightly after the actual event. The callstack passed to the callback is always accurate, but the program state may have evolved.