Subject: bug#64712: 29.0.92; Emacs 29 with native compilation compiles cl-loaddefs.el on every startup

From: Eli Zaretskii <[email-masked]>
Date: Wed, 06 Sep 2023 16:03:40 +0300

> Date: Wed, 6 Sep 2023 15:26:20 +0300
> Cc: [email-masked], [email-masked], [email-masked]
> From: Dmitry Gutov <[email-masked]>
> 
> On 03/09/2023 08:15, Eli Zaretskii wrote:
> >> I personally can't see that it would make much of a difference if we
> >> have them or not, but maybe I'm missing something.
> > If nothing else, it will slow down startup (because each .eln files
> > needs to be loaded via dlopen, as opposed to .elc that is dumped into
> > the pdumper file), albeit insignificantly.  But if we do this with all
> > the autoload files we have, that could slow down in a more tangible
> > ways.  So basically we have here two minor annoyances: you can solve
> > one, but then you "gain" the other one.
> 
> So you suppose
> 
>    - Findinb .eln in its load path
>    - dlopen-ing it
> 
> can be slower than
> 
>    - Looking for .eln in its load path, not finding it
>    - Extracting cl-loaddefs.el from cl-loaddefs.el.gz
>    - Loading it
> 
> ?

No.  But that's not what happens.  What does happen in the second case
is that we load the .elc file, and then, asynchronously and in a
separate Emacs session, try to native-compile the .el file.  So this:

>    - Looking for .eln in its load path, not finding it
>    - Extracting cl-loaddefs.el from cl-loaddefs.el.gz
>    - Loading it

happens in parallel with the Emacs session running, not sequentially.
And if the .elc file is in the pdumper file, we don't even load it,
it's already loaded.