quelpa / quelpa-use-package

Emacs quelpa handler for use-package

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Startup time of quelpa-use-package is high

amolgawai opened this issue · comments

commented

I am currently profiling my emacs startup time and the highest time is spent in the quelp-use-package bootstrapping. Is there a solution to lower this?
My configuration

  • OS - macos Catalina
  • Machine macbook pro 13"
  • emacs - 26.3

I am using following to bootstrap quelpa-use-package

(quelpa
 '(quelpa-use-package
   :fetcher git
   :url "https://github.com/quelpa/quelpa-use-package.git"))

I used esup to profile the startup time. It takes 10% of the startup time (around 3 seconds) for the above code snippet.

You can set (setq quelpa-use-package-inhibit-loading-quelpa t) to omit loading full quelpa when using quelpa-use-package. It will be loaded when needed.

Also I notice that you're using quelpa to install quelpa-use-package, which can be quite slow since quelpa need to pull/check for new updates from git url.
The following may work:

(use-package quelpa-use-package
  :demand t
  :init
  (setq quelpa-use-package-inhibit-loading-quelpa t)
  (unless (package-installed-p 'quelpa-use-package)
    (quelpa
     '(quelpa-use-package
       :fetcher git
       :url "https://github.com/quelpa/quelpa-use-package.git"))))
commented

Thanks for the quick reply.
Although I am using quelpa-use-package to install use-package as suggested -

Assuming you have bootstrapped quelpa, install quelpa-use-package (which installs use-package as a dependency) and require the library:

So to use your snippet, I would first need use-package, right? Doesn't that defeat the purpose of the above suggestion?

So to use your snippet, I would first need use-package, right? Doesn't that defeat the purpose of the above suggestion?

Well, it's depend. I've always used use-package so I have it always loaded even before quelpa for unify usage of use-package everywhere.
If you want use-package install automatically as quelpa-use-package, you can change the previous snippet into

(unless (package-installed-p 'quelpa-use-package)
  (quelpa
   '(quelpa-use-package
     :fetcher git
     :url "https://github.com/quelpa/quelpa-use-package.git")))
(setq quelpa-use-package-inhibit-loading-quelpa t)
(require 'quelpa-use-package)
commented

I used your snippet and the profiler no longer highlights time taken by quelpa-use-package, although the total time is still the same.
I see the message updating ~/.emacs.d/quelpa/melpa for a noticable time at startup. Is this something related to quelpa or qulpa-use-package?

I would say quelpa. Also, how did you bootstrap your quelpa?
Setting (setq quelpa-update-melpa-p nil) may help

commented

This is my package initialization portion

; list the repositories containing them
(setq package-archives ‘((“elpa” . “http://tromey.com/elpa/“)
                         (“melpa” . “http://melpa.org/packages/“)
                         (“gnu” . “http://elpa.gnu.org/packages/“)
                         (“marmalade” . “http://marmalade-repo.org/packages/“)))
;; avoid problems with files newer than their byte-compiled counterparts
;; it’s better a lower startup than load an outdated and maybe bugged package
(setq load-prefer-newer t)

; activate all the packages (in particular autoloads)
(package-initialize)

; fetch the list of packages available
(unless package-archive-contents
  (package-refresh-contents))

;; bootstrap quelpa
;; don’t auto-update on windows as it results in various problems
(unless (package-installed-p ‘quelpa)
    (with-temp-buffer
      (url-insert-file-contents “https://github.com/quelpa/quelpa/raw/master/quelpa.el”)
      (eval-buffer)
      (quelpa-self-upgrade)))

;; use quelpa with use-package
(quelpa
 ‘(quelpa-use-package
   :fetcher git
   :url “https://github.com/quelpa/quelpa-use-package.git”))
(require ‘quelpa-use-package)

(setq use-package-ensure-function ‘quelpa)

(eval-and-compile
  (setq use-package-always-ensure t)
  (setq use-package-expand-minimally t)
  (setq use-package-compute-statistics t))

I will try your suggestion...

Just saying but (package-refresh-contents) is quite slow too, you probably don't need it

commented

@kiennq
Thanks for all your comments, I will try all of them and will revert back.

commented

@kiennq
I implemented all of your suggestions and the hotspot for qeulpa-use-package is now gone. Thanks a lot.
My emacs startup is still a bit high (~15 sec) but that is of course another story.

commented

The tips from @kiennq helped me get over the hotspot for quelpa and quelpa-use-package, hence closing the issue.

@amolgawai I hope you are using the emacs --daemon. Like that startup time is largely irrelevant. I only start emacs when I boot the OS perhaps once a week and use emacsclient to connect to the running daemon which is instant

commented

@steckerhalter
At the moment, I am not running emacs server as am experimenting with different emacs “distributions” including my own.
Thanks for the tip...

@amolgawai alright, take care