GNU bug report logs -
#79021
31.0.50; Unnecessary GC in after-load-functions
Previous Next
Full log
Message #20 received at 79021 <at> debbugs.gnu.org (full text, mbox):
On September 12, 2025 12:54:42 AM PDT, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> From: Helmut Eller <eller.helmut <at> gmail.com>
>> Cc: Eli Zaretskii <eliz <at> gnu.org>, 79021 <at> debbugs.gnu.org
>> Date: Fri, 12 Sep 2025 09:26:02 +0200
>>
>> On Tue, Jul 15 2025, Stefan Monnier wrote:
>>
>> >>> In loadup.el there is this:
>> >>>
>> >>> (add-hook 'after-load-functions (lambda (_) (garbage-collect)))
>> >>>
>> >>> What's this for? It seems unnecessary.
>> >>>
>> >>> It would be nice to remove this, because without it the time to execute
>> >>> loadup.el goes down from 13 seconds to 6.
>> >>
>> >> I presume this is because we don't want to dump any garbage.
>> >> Stefan?
>> >
>> > AFAIK it was added to keep the dumped Emacs' heap "dense": if we run the
>> > GC only "in the normal way", the heap objects created during `loadup.el`
>> > end up interspersed with more free spaces.
>> >
>> > It's possible/likely that the portable dumper has made that unnecessary.
>>
>> diff --git a/lisp/loadup.el b/lisp/loadup.el
>> index 18f09878f98..05bd468b713 100644
>> --- a/lisp/loadup.el
>> +++ b/lisp/loadup.el
>> @@ -127,7 +127,11 @@
>>
>> ;; Do it after subr, since both after-load-functions and add-hook are
>> ;; implemented in subr.el.
>> -(add-hook 'after-load-functions (lambda (_) (garbage-collect)))
>> +;;
>> +;; This was probably done to reduce fragmentation with unexec. With the
>> +;; pdumper it makes little sense. See bug#79021.
>> +(if (not (fboundp 'dump-emacs-portable))
>> + (add-hook 'after-load-functions (lambda (_) (garbage-collect))))
>
>Are we sure the problem no longer happens with pdumper? Daniel, WDYT?
>
It's unnecessary with pdumper, which compacts automatically.
>In any case, the fboundp test is not enough, we should test the value
>of dump-mode instead, I think. Because Emacs might be built with
>pdumper support, but this session is not going to call
>dump-emacs-portable, due to command-line options or some other trick.
Just delete it.
This bug report was last modified 7 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.