[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Eager garbage collection
From: |
Stefan Monnier |
Subject: |
Re: Eager garbage collection |
Date: |
Mon, 16 Nov 2020 13:37:19 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
>> This will cause an eager GC right after Emacs goes idle, which can
>> happen while the user is actively typing. I think it would be
>> preferable to run this from an idle timer to make sure that we run
>> during an actual pause of incoming events. Your code effectively uses
>> an idle-time of 0, and I'm not sure what idle-time we should
>> use instead.
>>
>> Admittedly, using an idle time of 0 means we start the GC right at the
>> beginning of the (potentially short) pause, which also makes it more
>> likely that we'll have finished GC before the next event comes in.
>
> Starting GC immediately when Emacs becomes idle will degrade
> responsiveness if there's a lot of garbage, because once GC starts, it
> runs to completion no matter what.
Indeed.
> So maybe this "eager" GC should also be sensitive to the amount of
> garbage, in a sense that it should wait more if there's lot of it.
The time to do a GC doesn't depend on the amount of garbage so much as
the size of the heap, but I think I like your idea. Better yet: keep
track of the time that each GC takes and use that as a guide for the
idle-time delay.
Stefan