Subject: bug#19390: 25.0.50; `package-activate' is too slow

From: Artur Malabarba <[email-masked]>
Date: Thu, 18 Dec 2014 17:13:31 -0200

2014-12-18 16:40 GMT-02:00 Stefan Monnier <[email-masked]>:
>>> I don't think this performance hit will be noticeable during regular
>>> package loading.
>> It'll probably slow down Emacs startup: `require' will have to call
>> `find-library-name' for each common feature that someone depends on, each
>> time a dependant is loaded.
>
> And more importantly, we suffer the slow down when require is supposed to
> be fast (i.e. when the package has already been loaded), so the relative
> speed impact is not negligible.

Again, is this slow down really that much?
It is a single call to `find-library'.

Yes, it is slow compared to the current speed of `require'ing an
already loaded package, but is it slow in perspective with what else
is being done?
`require' is only ever called as part of loading package (or doing
some other processing). Is a single call to `find-library' really that
slow compared to the rest of the package that will be loaded (or
byte-compiled) after this require?

>
> And doing it in `require' doesn't catch all cases, because it's done too
> lazily and doesn't account for packages loaded via autoloads.  Doing the
> reloads eagerly when a package is (re)activated is the better choice.

Yes, that's why I said we'd need to do something with `autoload's. Why
do you think that's too high level?

When `autoload' is called, if the function in question is completely
defined (instead of not defined or just autoloaded), `autoload' will
check if the file it was given is a different file from the one the
function was defined in (when we know that file).
If it is then all is fine, if it wasn't then it loads the new file.