Relating to my other question Haskell collections with guaranteed worst-case bounds for every single operation?, I'm curious: How long pauses can be caused by garbage collection?
Does Haskell use some kind of incremental garbage collection so that a program is stopped only for small periods at a time, or can it stop for several seconds in an extreme case?
I found two SPJ's papers on the subject: https://research.microsoft.com/en-us/um/people/simonpj/papers/non-stop/index.htm. But I didn't find a reference if these ideas were actually adopted by GHC (or other Haskell implementations).
Metronome garbage collector (GC) pause time can be fine-tuned for each Java™ process. By default, the Metronome GC pauses for 3 milliseconds in each individual pause, which is known as a quantum.
The Haskell runtime system employs a generational garbage collector (GC) with two generations 2. Generations are numbered starting with the youngest generation at zero.
A garbage collector deallocates unused allocated memory from time to time. This way, in Haskell memory deallocation can be hidden, making the language (more) declarative.
Common triggers for garbage collection are Eden space being full, not enough free space to allocate an object, external resources like System. gc(), tools like jmap or not enough free space to create an object.
GHC is designed for computational throughput, not latency. As a result, GHC uses a generational, multi-threaded garbage collector with thread-local heaps. Garbage collection of thread-local objects does not stop other threads. The occasional major GC of the global heap will pause all threads.
Typically the pauses are in the small number of milliseconds, hwoever there is no guarantee of latency.
You can control the frequency of GC via several runtime flags (e.g. the gc -I
interval).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With