[erlang-questions] Turn off Garbage Collection for a time
Richard A. O'Keefe
Thu Jun 2 00:05:02 CEST 2016
On 1/06/16 6:47 PM, Tobias Pfeiffer wrote:
> Why would I want to do that? I'm working on a benchmarking tool and I
> don't want garbage collection to mess with my measured execution
> times. I run them multiple times and standard deviation goes way up
> because usually GC triggers during one run of n.
I know that trying to avoid GC during benchmarking is a common practice,
but I invite you to think very carefully about the point of doing a
If the thing you are measuring allocates memory, then that memory will have
to be reclaimed somehow, and that's GC. So if you *don't* include GC time
in your measurements, you will be (unintentionally) deceiving anyone who
relies on your results about the true costs of using whatever it is.
So why not go in the other direction? Run the benchmark LOTS of times
so that you get lots of GCs? If you run the benchmark 100 times and get
7 GCs, then each run incurred 7% of the GC time, even if a GC didn't
happen to occur during that run.
(I've been looking at some papers recently that basically did this, but
the point of those papers was to evaluate GC algorithms...)
More information about the erlang-questions