prosseek
prosseek

Reputation: 191099

Speed up loading emacs by compiling packages

With packages loading such as orgmode, nxhtml, yasnippet, I see that the loading of emacs slowed down pretty much.

I expect I can speed it up with the compilation of the packages.

Upvotes: 4

Views: 1603

Answers (3)

Eric
Eric

Reputation: 3949

The easiest way to get a speedup in your .emacs file doesn't have much to do with byte compilation, though you should always byte compile new packages you install.

Instead, if you know you do this in your .emacs:

(require 'some-pkg)

and then later you might do this:

`M-x command-in-pkg'

you are better off adding this to your .emacs file.

(autoload 'command-in-pkg "some-pkg" "A command in some package" t)

which will load much faster at startup than the original require. Many packages have installation setups that have a file full of autoloads that you require in your .emacs file which will already be optimized as best that maintainer can get it.

Upvotes: 5

Bozhidar Batsov
Bozhidar Batsov

Reputation: 56655

Generally everything that comes with the Emacs installation is byte compiled and every package you installed via a Linux distribution package management system is compiled as well. If you're using ELPA - it byte compiles the packages after downloading them. That said, byte-compilation will not bring you any significant performance gains.

If we assume that the greatest bottleneck with Emacs performance is its startup time, you'd do a lot better to start a single Emacs instance as a daemon(emacs --daemon) and share it between multiple emacsclient processes that will start instantly once the daemon is running.

Upvotes: 5

offby1
offby1

Reputation: 7023

Yes, you can do it: M-x byte-compile-file on each .el that you want to compile. It won't speed things up as much, though, as will using "autoload" and "eval-when-require".

Upvotes: 7

Related Questions