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

て烟熏妆下的殇ゞ 提交于 2019-12-20 10:13:13

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/12404031/how-long-pauses-can-occur-in-a-haskell-program-due-to-garbage-collection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!