Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How long pauses can occur in a Haskell program due to garbage collection?

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).

like image 793
Petr Avatar asked Sep 13 '12 10:09

Petr


People also ask

What is pause time in garbage collection?

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.

Does Haskell have garbage collection?

The Haskell runtime system employs a generational garbage collector (GC) with two generations 2. Generations are numbered starting with the youngest generation at zero.

Why does Haskell need a garbage collector?

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.

When should you trigger garbage collection?

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.


1 Answers

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).

like image 163
Don Stewart Avatar answered Oct 17 '22 04:10

Don Stewart