The settings and behaviour of idle GC are very confusing
This extracting the issue between comments
into their own issue.
There are a few problems problems (as of GHC 8.4.3):
- *1) You can't disable idle GC.**
- This is contrary to the manual, which says
Specifying -I0 disables the idle GC..
+RTS -I0will run the idle GC a few times and then it will stop. Detailed here.
- It will run in intervals of
0.3seconds (which is claimed to be the default for
-Iin the manual).
- *2) Giving the default for
+RTS -Iexplicitly, namely
+RTS -I0.3, changes the behaviour.**
- With it given, idle GC will run every 0.3 seconds.
- With it not given, it will run for a few times at 0.3 second and then stop.
- This is exactly the behaviour of
-I0. So if the manual said "the default for
-I0, that would be (perversely) more accurate.
- *3) The docs suggest idle GC is only in effect with
- manual "In the threaded and SMP versions of the RTS (see -threaded ...)."
- But idle GC settings like
+RTS -Iclearly also affect the nonthreaded RTS.
- *4) The concept of running the idle GC "for a little while" is a bit dubious in my opinion.**
- Its origin as a power-saving mechanism is sensible.
- But it makes things "weird": When you look at
strace, then first there's
SIGVTALRMgoing on (because the idle GC timer of 0.3 seconds is checked against in each timer signal tick of 0.02 seconds by default), then after some time they suddenly stop. Of course
SIGVTALRMoccurring can also have effects on underlying library calls (syscalls return with
EINTR), so (at least in non
-threaded) a simple idling Haskell program creates some time-dependent behaviour on C libraries being used.
- This makes debugging signal issues and behaviour extra hard, if you constantly have to keep in mind "oh but in the next 0.3 seconds the program will behave like this, and then behaviour will change. When you're debugging with
strace, you have to be constantly aware whether or not the current output you read is inside or outside that time window.
- But I don't have an idea of how this could be improved without sacrificing something else, so I guess this point just remains as "weird" for now.
I think points 1-3 are fixable, we should perhaps
-I<thedefaultvalue> behave the same as not giving
* change the "default value" to something that reflects what the current default behaviour actually is
the actual possibilities for this option expressed in Haskell would be
data IdleGcMode = NoneAtAll | StoppingAfterSeconds Double | IntervalSeconds Double
so perhaps we should change
-Ito allow passing the following values to it:
and the default would be
-I0.3stoppingto reflect the current default.
fix the documentation to reflect all this