Garbage collection in Haskell amp parallel computations

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

Most of languages, using garbage collectors (possibly all of them), have one major issue related to parallel computations: garbage collector has to stop all running threads in order to delete unused objects. Haskell has garbage collector too. But, due to purity, Haskell guarantees that no computation changes the original data, it produces a copy instead, and then makes the changes. I suppose, in that way, GC does not has to stop all threads to do its job. I m just curious: does Haskell have the same issue with garbage collection or not?

Answers

GHC s garbage collector is parallel but not concurrent . That means that it can use all threads to perform garbage collection, but it has to stop all threads to do that. Concurrent garbage collection is much harder to implement (and usually has a larger performance overhead).

It is somewhat ironic that Haskell does indeed use lots of mutable objects, namely thunks (unevaluated expressions). Mutable objects cannot freely be duplicated (and even for immutable objects too much duplication should be kept in check).

http://research.microsoft.com/~simonpj/papers/parallel/local-gc.pdf http://research.microsoft.com/~simonpj/papers/parallel/local-gc.pdf

Edit: I forgot to mention that Erlang basically does exactly what you propose. Each Erlang process has its own heap and sending a message copies the data from one process to the other. For this reason each Erlang process can do its own GC independently of all the other processes. (The downside is that Erlang doesn t give you shared memory concurrency.)

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/9547741/garbage-collection-in-haskell-parallel-computations

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils