3 ms·
I work on the Firefox GC, so I guess I'm biased, but this doesn't seem like the greatest idea if you use it exactly as proposed. By setting a really high thresh
by sfink 3y ago
I work on the Firefox GC, so I guess I'm biased, but this doesn't seem like the greatest idea if you use it exactly as proposed. By setting a really high threshold for automatic GC scheduling, you're guaranteeing that memory usage is going to grow quite a bit as long as you're even slightly active (15 seconds is a long time to be idle!), which means (1) whatever application you're switching to will have had its pages pushed out and will start responding more slowly as it faults them back in, and (2) 15 seconds into using that application, you'll get a system-wide stutter as the emacs GC faults all of its massive pile of pages back into physical memory in order to scan through the reference graph.
Of course, you'll probably blame both of those on whatever application you're using, so in a way from emacs's point of view this is all free!
I'm not saying the underlying idea is bad. Using idle time for GC is good. 1GB just seems like an awfully high threshold for non-idle time. It's giving up on the idea of "small enough to be unnoticeable" pauses. (Though the right way to do that would be to have an incremental GC, but that has costs of its own.)
Personally, I guess I'd want to try a lower non-idle heap threshold, plus a shorter idle time threshold (15 seconds seems quite long, and a shorter time increases the probability of the GC'd pages still being in RAM), plus using focus as an idle signal.
And maybe play with using variable heap size thresholds, eg base the trigger off of both how long emacs has been idle plus the size of the heap just after the previous collection. So you might say that the heap threshold is 100% of the previous heap size at 15 seconds, 400% at 5 seconds, 1000% when non-idle. Or min(10x previous, 20MB) when non-idle, perhaps, where 20MB is adjusted to take an amount of time that is barely noticeable? But that's adding complexity. I guess I should enable GC logging to see how long these collections typically take; I haven't noticed a lot of pauses in the first place.
- aidenn0 3y ago> It's giving up on the idea of "small enough to be unnoticeable" pauses If emacs already had this, then none of these GC hacks would be needed?