How to Reduce Emacs Load Time
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
How to Reduce Emacs Load Time         


Author: formido
Date: Aug 30, 2008 14:11

Hello there,

Emacs takes like 10 seconds to load. It's a lot faster if I don't load
all my packages. What strategies could I use to get my load time down?
Emacs itself is made up of tons of elisp files and it doesn't take
forever to load, so I don't see why I should be forced to endure long
load times just because I add third party packages. If I do, 'require
package', I'm at the mercy of the package maker's initialization
process, right?
21 Comments
Re: How to Reduce Emacs Load Time         


Author: Pascal J. Bourguignon
Date: Aug 30, 2008 14:36

formido gmail.com> writes:
> Hello there,
>
> Emacs takes like 10 seconds to load. It's a lot faster if I don't load
> all my packages. What strategies could I use to get my load time down?
> Emacs itself is made up of tons of elisp files and it doesn't take
> forever to load, so I don't see why I should be forced to endure long
> load times just because I add third party packages. If I do, 'require
> package', I'm at the mercy of the package maker's initialization
> process, right?

Right.

- compile ~/.emacs ; this is not a good idea, because the gain is
minimal, and you have to remember compiling it everytime you update
~/.emacs.

- don't load what you don't need. Remove cruft from your ~/.emacs.
Show full article (1.44Kb)
no comments
Re: How to Reduce Emacs Load Time         


Author: Pascal J. Bourguignon
Date: Aug 30, 2008 14:41

formido gmail.com> writes:
> Hello there,
>
> Emacs takes like 10 seconds to load. It's a lot faster if I don't load
> all my packages. What strategies could I use to get my load time down?
> Emacs itself is made up of tons of elisp files and it doesn't take
> forever to load, so I don't see why I should be forced to endure long
> load times just because I add third party packages. If I do, 'require
> package', I'm at the mercy of the package maker's initialization
> process, right?

Ah, also even it emacs took one hour to load, it woudn't matter much,
because you should leave your emacs process running. On this machine,
emacs uptime is close to the system uptime.

Keep emacs running, and use emacsclient. So the boot time is amortized.
Show full article (1.06Kb)
no comments
Re: How to Reduce Emacs Load Time         


Author: formido
Date: Aug 30, 2008 15:03

On Aug 30, 3:05 pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
> formido gmail.com> writes:
>> Hello there,
>
>> Emacs takes like 10 seconds to load. It's a lot faster if I don't load
>> all my packages. What strategies could I use to get my load time down?
>> Emacs itself is made up of tons of elisp files and it doesn't take
>> forever to load, so I don't see why I should be forced to endure long
>> load times just because I add third party packages. If I do, 'require
>> package', I'm at the mercy of the package maker's initialization
>> process, right?
>
> Ah, also even it emacs took one hour to load, it woudn't matter much,
> because you should leave your emacs process running.  On this machine,
> emacs uptime is close to the system uptime.
>
> Keep emacs running, and use emacsclient.  So the boot time is amortized.
>
> -- ...
Show full article (1.41Kb)
no comments
Re: How to Reduce Emacs Load Time         


Author: Ivan Kanis
Date: Aug 31, 2008 02:39

formido gmail.com> wrote:
> Emacs takes like 10 seconds to load. It's a lot faster if I don't load
> all my packages. What strategies could I use to get my load time down?
> Emacs itself is made up of tons of elisp files and it doesn't take
> forever to load, so I don't see why I should be forced to endure long
> load times just because I add third party packages. If I do, 'require
> package', I'm at the mercy of the package maker's initialization
> process, right?

Hi,

I use late binding, I load the package when I start using it. For
example for ido mode:

(defun ivan-ido-file ()
"Find file, late bind ido."
(interactive)
(ivan-ido-late-bind)
(ido-find-file))
Show full article (1.21Kb)
no comments
Re: How to Reduce Emacs Load Time         


Author: Nikolaj Schumacher
Date: Aug 31, 2008 04:26

pjb@informatimago.com (Pascal J. Bourguignon) wrote:

Another tip:
Use `eval-after-load' a lot. With that you can load minor modes and
configurations only when a specific major mode has been (auto-)loaded.

I use this to load cedet only when cc-mode is loaded, for example.
> - don't load what you need, yet. This means, instead of loading or
> requiring the packages you may need, define autoloading functions.
> Good packages will do that for you, when you require them, they load
> only a file which defines autoloading functions, so you spend time
> loading the package only when you try to run these functions.

I don't think /good/ packages do that, just /huge/ packages.
IHMO the proper thing for packages to do is just add ;;;###autoload
markers, so /you/ can generate the autoloads automatically, if you want
them (using `update-directory-autoloads').

Package managers like ELPA will do that step automatically when the
package is updated.
Show full article (1.70Kb)
no comments
Re: How to Reduce Emacs Load Time         


Author: David
Date: Aug 31, 2008 04:39

formido gmail.com> writes:
> Emacs takes like 10 seconds to load. It's a lot faster if I don't load
> all my packages. What strategies could I use to get my load time down?

First, you should identify what parts of your .emacs take so long. You
can do this e.g. by starting emacs with "emacs -q", set up your
load-path, and then evaluate

(benchmark-run
(require 'package))

The first number appearing in the echo area will be the time needed to
run that command.
> Emacs itself is made up of tons of elisp files and it doesn't take
> forever to load, so I don't see why I should be forced to endure long
> load times just because I add third party packages.

Many packages from Emacs use autoloads, which delay the loading of the
complete package until one of the interactive functions is used.
> If I do, 'require package', I'm at the mercy of the package maker's
> initialization process, right?
Show full article (1.36Kb)
no comments
Re: How to Reduce Emacs Load Time         


Author: Nikolaj Schumacher
Date: Aug 31, 2008 05:35

Ivan Kanis wrote:
> I use late binding, I load the package when I start using it. For
> example for ido mode:
>
> (defun ivan-ido-file ()
> "Find file, late bind ido."
> (interactive)
> (ivan-ido-late-bind)
> (ido-find-file))
>
> (defun ivan-ido-late-bind ()
> (unless ido-mode
> (require 'uniquify)
> (ido-mode 'both)))
>
> I then bind C-x C-f to ivan-ido-file, it will load ido the first time
> I need it. This makes my emacs faster to start.

Emacs already provides a mechanism for that. I think you can get rid of
most of these custom commands simply with these lines:
Show full article (0.78Kb)
no comments
Re: How to Reduce Emacs Load Time         


Author: formido
Date: Aug 31, 2008 10:39

On Aug 31, 4:26 am, Nikolaj Schumacher wrote:
> p...@informatimago.com (Pascal J. Bourguignon) wrote:
>
> Another tip:
> Use `eval-after-load' a lot.  With that you can load minor modes and
> configurations only when a specific major mode has been (auto-)loaded.
>
> I use this to load cedet only when cc-mode is loaded, for example.

Haha! I see others have mentioned cedet, too. That's the package
that's causing me the most pain. See, I just followed .emacs setup
instructions, and I went with the whole kit and kaboodle by using the
load-excessive-helper-functions or whatever. My .emacs looks like:

My .emacs has:

(load "lisp/cedet-1.0pre4/common/cedet.elc")
(semantic-load-enable-excessive-code-helpers)

So, when Emacs starts up, the relevant sections of *messages* looks
like this:

Loading lisp/cedet-1.0pre4/common/cedet.elc...
"/Users/formido/.emacs.d/lisp/cedet-1.0pre4/common/" added to `load-
path'
"/Users/formido/.emacs.d/lisp/cedet-1.0pre4/cogre" added to `load-
path'
"/Users/formido/...
Show full article (3.80Kb)
no comments
Re: How to Reduce Emacs Load Time         


Author: formido
Date: Aug 31, 2008 10:42

On Aug 31, 4:39 am, David wrote:
> First, you should identify what parts of your .emacs take so long. You
> can do this e.g. by starting emacs with "emacs -q", set up your
> load-path, and then evaluate
>
> (benchmark-run
>   (require 'package))

Thanks very much for that. In this case, by inspection I can tell
CEDET is a major culprit.
> Essentially, yes. But maybe you "require" too much. My emacs startup
> time is ~1sec, although I include large third party packages like CEDET
> and Gnus. For example, for setting up Gnus, you should only require
> 'gnus-load in your .emacs, which contains the proper autoloads. This
> takes about 0.03 seconds on my machine.

Mind telling me how you load CEDET? I just used instruction they gave--
you can see above what my *messages* looks like at init.
> -David
no comments

RELATED THREADS
SubjectArticles qty Group
Bug#367865: Confirmation: auto-loading by desktop.el fails, manual loading workslinux.debian.bugs.dist ·
1 2 3