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

From: Dmitry Gutov <[email-masked]>
Date: Tue, 16 Dec 2014 16:31:29 +0200

On 12/16/2014, Artur Malabarba wrote:

 > I didn't notice anything as aggravating as the report, but I agree my
 > latest patch is a performance concern.

Do you maybe have fewer packages installed?

> avoid a lot of
> calls to `file-truename'. This, I suspect, is the bigger performance
> issue.

Any particular reason you're using `file-truename', instead of 
`expand-file-name'? Replacing the former with the latter already gives 
~twofold performance improvement.

> 2. Creating the `history' variable as below is a problem.
>
> (mapcar (lambda (x) (file-name-sans-extension
>                                    (file-truename (car x))))
>                      load-history)

With the above change, this piece of code is relatively fast.

For instance, (package--list-loaded-files default-directory) in the Helm 
directory takes 140 ms here, whereas

             (mapcar (lambda (x) (file-name-sans-extension
                                  (expand-file-name (car x))))
              load-history)

only takes ~10 ms. Still not fast enough not to need the other patch, of 
course.