[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Speeding up Emacs load time

From: Sebastien Vauban
Subject: Re: Speeding up Emacs load time
Date: Thu, 25 Jul 2013 21:24:07 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (windows-nt)

J. David Boyd wrote:
> "Sebastien Vauban" <> writes:
>> - `(server-start)' takes more than 200 ms to run [1]; just that one command.
>>   Though, I must have it in my .emacs file, right?
>> - diff-mode-.el must be loaded before diff-mode; hence, I must have it at
>>   startup.
>> - Helm is my tool for opening files or switching between buffers. Just
>>   requiring `helm-config' (almost only autoloads) -- hence, NOT `helm' (which
>>   is more hungry in time) -- already takes 160 ms (as it still requires
>>   `easy-menu' and `helm-aliases').
>> - `diary-lib' and co (needed for appointments notification) takes 233 ms.
>>   Shouldn't I be notified at startup of events occurring in less than 15
>>   minutes, without having to make a first call to calendar or so?
>> - `mic-paren' takes just 32 ms, but for just one small package, for which I
>>   don't have a particular trigger. Is it `find-file-hook'?  Then, I won't 
>> have
>>   parenthesis highlighted when directly typing text in a newly created buffer
>>   (or in the scratch). So, I need it in my .emacs. It's not 
>> eval'ed-after-load
>>   of something else.
>> - The same for YASnippet (loaded in 130 ms): what would be the trigger?
>>   Unless I have a clear one, I must require it in my .emacs file.
>> - Once again, the same with `recentf', which takes 92 ms. Don't I have to 
>> load
>>   it right at startup?
>> These are a couple of examples which take a lot of the time, and for which I
>> don't see a specific trigger that would allow me to defer their load to 
>> later.
> How did you time those sections?  Could you share, please?

The config file that I'm using is publicly available at

    Note -- Put (setq leuven-load-verbose t) before loading it, and you'll get
    load times, and call tree of the packages.

In summary, to time a package is done this way:

--8<---------------cut here---------------start------------->8---
  ;; make loaded files give a message
  (defadvice load (around leuven-load activate)
    "Execute a file of Lisp code named FILE and report time spent."
    (let ((filename (ad-get-arg 0))
          (find-file-time-start (float-time)))
      (message "(info) Loading %s..." filename)
      (message "(info) Loaded %s in %.3f s." filename
               (- (float-time) find-file-time-start))))

  (defadvice require (around leuven-require activate)
    "Leave a trace of packages being loaded."
    (let* ((feature (ad-get-arg 0))
           (require-depth (or (and (boundp 'require-depth) require-depth)
           (prefix (concat (make-string (* 2 require-depth) ? ) "+-> ")))
      (cond ((featurep feature)
             (message "(info) %sRequiring `%s'... already loaded"
                      prefix feature)
             ;; in the case `ad-do-it' is not called, you have to set the
             ;; return value yourself!
             (setq ad-return-value feature))
             (let ((time-start))
               (message "(info) %sRequiring `%s'... %s"
                        prefix feature
                        (locate-library (symbol-name feature)))
               (setq time-start (float-time))
               (let ((require-depth (1+ require-depth)))
               (message "(info) %sRequiring `%s'... loaded in %.3f s"
                        prefix feature
                        (- (float-time) time-start)))))))
--8<---------------cut here---------------end--------------->8---

Though, do you have ideas for not being forced the above packages at startup
time?  To which event (such as load of package "x") to which hook could I tie

Best regards,

Sebastien Vauban

reply via email to

[Prev in Thread] Current Thread [Next in Thread]