Live data from Hacker News

Are your memory-bound benchmarking timings normally distributed?

lemire.me

41–50 of 50 posts

Re: Are your memory-bound benchmarking timings normally distributed?

#41

Earlier quoted context omitted.

I too am an engineer that doesn't understand why/when you would use a gamma distribution. Could you point me in the right direction?

There's a pretty good section on the natural occurrences and applications of the distribution in the wikipedia article. https://en.wikipedia.org/wiki/Gamma_distribution#Occurrence_...

> Consider a sequence of events, with the waiting time for each event being an exponential distribution with rate β

Why is the exponential distribution of waiting times a reasonable assumption in this case?

Re: Are your memory-bound benchmarking timings normally distributed?

#42

Earlier quoted context omitted.

There's a pretty good section on the natural occurrences and applications of the distribution in the wikipedia article. https://en.wikipedia.org/wiki/Gamma_distribution#Occurrence_...

> Consider a sequence of events, with the waiting time for each event being an exponential distribution with rate β Why is the exponential distribution of waiting times a reasonable assumption in this case?

Yeah that is what I can't figure out

Re: Are your memory-bound benchmarking timings normally distributed?

#43
Usually I don't do any statistical tests when benchmarking and optimizing.

("If your result depends on statistics then you need a better experiment.” Oft quoted remark attributed to Rutherford.)

s/experiment/optimization/

I'm happy with min, max and average. max is actually often the most important.

On the other hand the point of view in this paper is interesting:

"Violating the normality assumption may be the lesser of two evils" (1)

If you really feel the urge to do statistical tests then do it.

(I do not work in medicine or anything dangerous at all)

https://link.springer.com/article/10.3758/s13428-021-01587-5 (1)

Re: Are your memory-bound benchmarking timings normally distributed?

#44

Usually I don't do any statistical tests when benchmarking and optimizing. ("If your result depends on statistics then you need a better experiment.” Oft quoted remark attributed to Rutherford.) s/experiment/optimization/ I'm happy with min, max and average. max is actually often the most important. On the other hand the point of view in this paper is interesting: "Violating the normality assumption may be the lesser…

The only extra statistic in the article not on your list is standard deviation. I don’t know whom this comment is aimed at.

Re: Are your memory-bound benchmarking timings normally distributed?

#45

Earlier quoted context omitted.

There's a pretty good section on the natural occurrences and applications of the distribution in the wikipedia article. https://en.wikipedia.org/wiki/Gamma_distribution#Occurrence_...

> Consider a sequence of events, with the waiting time for each event being an exponential distribution with rate β Why is the exponential distribution of waiting times a reasonable assumption in this case?

In the general case? Because the exponential distribution is directly the result of a poisson process, and poisson processes are also naturally ubiquitous. A poisson process results in poisson distributed counts of events over fixed periods of time, and exponentially distributed times between events. They are used to model everything from rainfall to particle physics, and those concepts do fit very neatly with things that are obviously more complicated like human dynamics.

In the case of memory-bound code benchmarking? Because memory access in NUMA architectures with tiered caches are approximately exponential: L1 vs L2 vs L3 vs main memory vs swap are all exponential increases in latencies. It's obviously more of a step function than a continuous function but the relationship is definitely exponential.

The pages for the exponential distribution and poisson distribution are also informative and interesting.

https://en.wikipedia.org/wiki/Exponential_distribution#Occur...

https://en.wikipedia.org/wiki/Poisson_distribution#Occurrenc...

When I go through the process of finding an appropriate distribution, I usually first look through wikipedia to see if I can find conceptual parallels, just like this. That doesn't mean I settle on it..I'll usually test the distribution fit with functions like those found in fitdistr plus, as well as test to see if residuals are roughly normally distributed.

One hard and fast rule that I use though is that I never use an unbounded distribution to model a bounded process. For compute times, you can't have negative latencies, and you can't have zero latencies, but you can have infinite latencies. Therefore, I would only consider using distributions in the space of (0,infinity). The log normal distribution fits this and is probably adequate here, but the gamma distribution might be a smidge better.

https://cran.r-project.org/web/packages/fitdistrplus/vignett...

Re: Are your memory-bound benchmarking timings normally distributed?

#46
post #18

Earlier quoted context omitted.

You can run any process on any core and allocate local memory to that core. What is missing? Sure you can't hide metadata in the unused bits of a pointer, but that didn't seem particularly critical for making good use of a NUMA machine.

> What is missing? Fast memory, addressable by the core. The one that is there, but can only used by accessing the slow memory.

And praying that the slow memory is magically in the fast memory.

I think ultimately what I'm asking for means a much, much tighter bound on worst case performance, but at the cost of best case performance. That most of us never see anyway. For certain workloads, that could end up being a net positive. And there's probably some way to expose CPU metadata that gives some of that difference back.

Re: Are your memory-bound benchmarking timings normally distributed?

#47
post #46

Earlier quoted context omitted.

> What is missing? Fast memory, addressable by the core. The one that is there, but can only used by accessing the slow memory.

And praying that the slow memory is magically in the fast memory. I think ultimately what I'm asking for means a much, much tighter bound on worst case performance, but at the cost of best case performance. That most of us never see anyway. For certain workloads, that could end up being a net positive. And there's probably some way to expose CPU metadata that gives some of that difference back.

I think it’s worthwhile to distinguish between throughput and latency for these sorts of discussions, rather than just talking about performance since scratchpads are usually better for latency (even best-case latency) and caches are usually better for throughput. Though of course in this as in any sort of discussion of computer performance, caveats abound.

Re: Are your memory-bound benchmarking timings normally distributed?

#48
post #30
post #24

Earlier quoted context omitted.

I think he's saying that since the distribution follows a log-normal, the mean is harder to pin down than if it were a normal due to the higher variance. From the CLT, the variance of the mean statistic is var(X)/sqrt(N) -- the var(X) is higher and he'd expect from an assumed normal of X. The other point he makes is that the mean is not very representative in this wide log-normal scenario, and optimizing for the diff…

One can also work in log space to do the stats, and report the geometric mean in linear space…

I think we're nitpicking too much here, but the main takeaway seems to be to not assume normals and to actually measure things. Seems pretty straightforward advice, but if you've worked anywhere, you'll know how often people content themselves with reporting averages.

Re: Are your memory-bound benchmarking timings normally distributed?

#49

Usually I don't do any statistical tests when benchmarking and optimizing. ("If your result depends on statistics then you need a better experiment.” Oft quoted remark attributed to Rutherford.) s/experiment/optimization/ I'm happy with min, max and average. max is actually often the most important. On the other hand the point of view in this paper is interesting: "Violating the normality assumption may be the lesser…

The only extra statistic in the article not on your list is standard deviation. I don’t know whom this comment is aimed at.

The comment is a bit abrupt.

The article questions the normal distribution assumption for benchmark timings.

It says that this assumption would be important for the "standard error of the mean":

"Your error should go down as the square root of the number of measures."

Standard distribution is not even necessary for this:

https://en.wikipedia.org/wiki/Standard_error

However, normal distributions actually behave benignly and are a prerequisite for some statistical tests.

This is where my first comment gets in, that for my benchmarking statistical tests are not necessary at all ...

---

The author writes that he only measures minimum and average, but the maximum values are of course also important and worth to measure.

The author's key point is that without a normal distribution, the maximum values can be highly scattered. I agree and basically it is always nice to know the distribution of the random variable.

Re: Are your memory-bound benchmarking timings normally distributed?

#50

I've found timings in general were lognormal a long time ago. I had to routinely apply transformations to get meaningful ANOVA and DOE results.

The obvious transformation is the log. Are there other?

Yes, box-cox can be used, even if the lognormal itself isn't a perfect match for the actual distribution, with the correct choice of lambda.
Post reply on HN