package memprof-limits
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=39c73e7f96b5e5a01cf74937e2a5a1ae
sha512=a0049fec23c054eef19a924e5be810ecf9de4f697bd09b133e64c244b7ea09f416cec627ccce412ae793c265043894a878f0d822bcc47a2e622526f96d14af25
doc/statistical.html
Statistical analysis of Memprof-limits
p
: sampling rateS
: expected trigger allocation
By default, p=10^{-4}
samples per word.
We have S = \frac{1}{p} = 10\,\textrm{kw}
(by default). That is, S
is about 39.0 kiB of allocations on 32-bit and 78.1 kiB on 64-bit.
Global memory limits
P_{\mathrm{t}}(n)
: probability of triggering a callback after n
allocated words.
One has:
P_{\mathrm{t}}(n) \geq 1-e^{-\frac{n}{S}}
Thus, once the memory limit is reached, on 64-bit:
- there is more than 64% probability that the function has been interrupted after 80 kiB of allocations,
- there is a probability less than
10^{-9}
that the function has not been interrupted after 1.62 MiB of allocations - there is a probability less than
10^{-14}
that the function has not been interrupted after 2.5 MiB of allocations - there is a probability less than
10^{-50}
that the function has not been interrupted after 8.8 MiB of allocations
Allocation limits
l
: limit chosen by the userk
: number of memprof callback runs needed to interrupt the function
We have k = \frac{l}{S}
.
Probability of being interrupted
P_{\mathrm{a}}(n)
: probability of being interrupted after n
allocations. It is given by the cumulative binomial distribution, that is, one has in terms of the regularized incomplete beta function I:
P_{\mathrm{a}}(n) = I_p(k,n-k+1)
Cumulative probability of being interrupted relative to the chosen limit (table)
|
|
|
---|---|---|
0.00 |
|
|
0.20 |
|
|
0.40 |
|
|
0.60 |
|
|
0.80 |
|
|
1.00 |
|
|
1.20 |
|
|
1.40 |
|
|
1.60 |
|
|
1.80 |
|
|
2.00 |
|
|
\varepsilon
: too small for the precision of calculations in 64-bit floating point.
Accuracy of limit
t
: target safe probabilityN
: maximum number of safe allocations, that is, allocations that can be performed while the cumulative probability of being interrupted remains less thant
.
A good lower bound for N
is estimated for various values of k
, and the error (l-N)/N
is given below for t = 10^{-9}
, t = 4\cdot10^{-15}
, and t = 10^{-50}
. (10^{-9}
is the probability of winning the lottery, 10^{-50}
is considered implausible by physicists' standards.)
Inaccuracy of limit for a target safe allocation (table, rounded up)
Values for p=10^{-4}
.
|
|
|
|
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*: l/N
is higher than 10
(accuracy too low for practical purposes).
The same data gives us an indicative value for l
for a given N
.
Allocation limit for a target safe allocation (table)
Values for p=10^{-4}
.
|
|
|
|
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*: l/N
is higher than 10
(N
too small for practical purposes).
The allocation limit is reasonably accurate (i.e. l
is less than an order of magnitude greater than N
) starting at around N = 20\,\textrm{kw}
, that is, for a target safe probability of 4\cdot10^{-15}
, around a limit of l = 200\,\textrm{kw}
. Allocation limits l \leq 60\,\textrm{kw}
on the other hand are probably too inaccurate to be useful.
Impact of the sampling value
This data is given for the default sampling rate. When memprof is used for profiling via the provided Memprof module, the user's sampling rate is used instead. But, memprof-limits will refuse to run with sampling rates less than the default one. As a consequence, the limits can only get more accurate, not less, such that the chosen N
remains a safe allocation number.
From a theoretical point of view, one can wonder whether it is useful to increase the default rate. Below is the minimal sampling rate for a target safe allocation assuming l
is chosen an order of magnitude greater than N
.
Minimal sampling rate for a target safe allocation (table)
k
chosen such that l/N
is around 10 for the specified value of t
.
|
|
|
|
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*: The minimal sampling rate is higher than 10^{-4}
, the value chosen by Memprof-limits.
The default sampling rate (10^{-4}
) is one among many possible choices that provide reasonable accuracy without affecting performance. Nevertheless, feedback regarding the need of being able to select greater or lower sampling rates is welcome.