<div dir="ltr">Thanks! Let's see if I can find the time to make a patch for this.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 2 Nov 2023 at 17:17, Teofil Camarasu <<a href="mailto:teofilcamarasu@gmail.com">teofilcamarasu@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Bryan,<br>
<br>
Thanks for improving this documentation! I've often found these flags<br>
to be quite confusing.<br>
<br>
> For an interactive application, it is probably a good idea to use the idle GC, because this will allow finalizers to run and deadlocked threads to be detected in the idle time when no Haskell computation is happening. [Why is this a good thing? What happens when the idle GC is disabled?]<br>
<br>
So there's basically 3 ways to trigger a major GC as far as I know:<br>
1. Heap overflow: when we last performed a major GC we checked how<br>
much live data there is and set a variable so that we do another major<br>
GC when the heap grows to be live * F.<br>
2. Idle GC<br>
3. Manually triggering a GC using the interface in System.Mem<br>
<br>
When idle gc is disabled, then GC will happen less often. One of the<br>
other two may still trigger a GC.<br>
<br>
A key difference is both of those are only activated by the mutator<br>
running code: either through allocation or by calling a GC directly.<br>
On the other hand, idle GC can be triggered when the mutator isn't<br>
running. So, if you want to ensure that finalizers get called promptly<br>
then idle GC can help, especially if your application is idle for long<br>
periods of time.<br>
<br>
The other key benefit of the idle GC is that it can reduce the<br>
prevalence of heap overflow GCs. These can only happen when your<br>
application is allocating and hence running code. So it's quite likely<br>
that it's going to tank the response time for the request your<br>
application is serving at the time. And since idle GCs free some<br>
memory, it makes it less likely that you reach the limit that would<br>
trigger a heap overflow GC.<br>
<br>
With idle GCs, if you are lucky, major GCs will only run while your<br>
application isn't meant to be responding to requests at all, which<br>
makes it basically free.<br>
<br>
> Also, it will mean that a GC is less likely to happen when the application is busy, so application responsiveness may be improved. However, if the amount of live data in the heap is particularly large, then the idle GC can cause a significant penalty to responsiveness. [Why? Is it because the idle GC was delayed by waiting for some idle time, and thus has more work to do?].<br>
<br>
The reason this can happen is because the time a major GC takes is<br>
proportional to the live data in the heap. So, if the pause required<br>
by the GC starts to overlap with time when you'd like the application<br>
to be working on a response, then you will regress response times. For<br>
instance if it takes 100ms to run an idle GC and a request comes in<br>
just after you've started the GC then processing it will have to wait<br>
until the GC is over.<br>
<br>
>Conversely, too small of an interval could adversely affect interactive responsiveness [How? And how is this worse than having idle GC disabled? What is the actual behavior when it's disabled, anyway?]<br>
<br>
The smaller the interval, the more time you are spending running an<br>
idle GC, the more likely it becomes that it will overlap with time you<br>
want to be doing something else. This is similar to the long GC case<br>
above due to large heaps.<br>
<br>
Another reason you might not want to run it too often is that you are<br>
unlikely to free much memory.<br>
<br>
I think this documentation was written before the non-moving GC was<br>
added. It would also be important to add that the savings in terms of<br>
responsiveness don't really apply if that is enabled as the non-moving<br>
GC runs concurrently with the mutator anyway. So, the main advantage<br>
would just be more prompt finalization, deadlock detection, etc.<br>
<br>
I hope that helps; let me know if you'd like anything clarified.<br>
<br>
Cheers,<br>
Teo<br>
</blockquote></div>