Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Shake recommend disabling idle garbage collection?

In the Shake documentation it recommends compiling using the flag -with-rtsopts=-I0 to disable idle garbage collection. Why does Shake recommend that?

like image 700
Neil Mitchell Avatar asked Jan 04 '16 09:01

Neil Mitchell


1 Answers

By default (without the flag) GHC performs a garbage collection (GC) if all Haskell threads have been idle for 0.3 seconds. Since a build system is regularly running external processes, it is quite common for all Haskell threads to be idle for > 0.3s, which causes a lot of unnecessary garbage collections. Since the machine is likely to be fully loaded from the processes Shake is running, the GC will take time away that could otherwise be doing useful work. The problem is exacerbated if the GC runs multi-threaded.

like image 133
Neil Mitchell Avatar answered Oct 02 '22 08:10

Neil Mitchell