2

I have a working setup of emacs on Windows 10 that I like so far. However, I find that emacs start-up takes very long. It can be anywhere from 20s to 60s. I tried installing the benchmark-init package which profiles the start-up and saves the results which can be accessed after start-up is complete. This is what it looks like.

I can't quite tell if just one package is the bottleneck or not. There seems to be a uniform spread.

  Module                                                            Type        ms      Total ms
---------------------------------------------------------------------------------------------------
  ispell                                                            require     364     364
  default                                                           load        265     265
  evil-vars                                                         require     216     216
  undo-tree                                                         require     213     328
  wid-edit                                                          require     196     196
  compile                                                           require     189     189
  easy-mmode                                                        require     187     187
  ewoc                                                              require     170     170
  subr-x                                                            require     167     167
  spacemacs-common                                                  require     165     165
  etags                                                             require     137     397
  xref                                                              require     136     260
  flyspell                                                          require     133     496
  comint                                                            require     131     243
  project                                                           require     124     124
  rect                                                              require     121     121
  evil-commands                                                     require     121     813
  tree-widget                                                       require     119     314
  pcomplete                                                         require     115     115
  reveal                                                            require     114     114
  diff                                                              require     114     114
  thingatpt                                                         require     112     112
  ansi-color                                                        require     112     112
  shell                                                             require     111     469
  color                                                             require     110     110
  windmove                                                          require     109     109
  dash                                                              require     109     109
  powerline-separators                                              require     109     219
  bind-key                                                          require     107     293
  ggtags                                                            require     106     862
  powerline                                                         require     101     403
  spaceline                                                         require      95     773
  s                                                                 require      95      95
  spaceline-segments                                                require      88     184
  powerline-themes                                                  require      82      82
  spaceline-config                                                  require      73     257
  evil-common                                                       require      70     448
  evil-types                                                        require      60      60
  evil-integration                                                  require      57     385
  ~/.emacs.d/recentf                                                load         56      56
  evil-core                                                         require      51      51
  evil-search                                                       require      49     556
  evil-jumps                                                        require      44      44
  evil-repeat                                                       require      42      42
  evil                                                              require      40    2763
  evil-states                                                       require      40      40
  evil-maps                                                         require      39      39
  evil-macros                                                       require      38      38
  evil-ex                                                           require      38     507
  evil-command-window                                               require      38      38
  evil-digraphs                                                     require      36      36
  evil-keybindings                                                  require      35      35

Any advice appreciated.

6
  • Maybe you can try to use a curate distribution like github.com/hlissner/doom-emacs , to check if the startup time is windows problem, emacs version/bug or the configuration you made. It is also useful if you can provide some example of your config
    – Fermin MF
    May 8, 2020 at 19:30
  • 1
    Try bisecting your init file (comment out 1/2, then 1/4, 1/8, 1/16, .... till you find the culprit package. It's a binary search, so it goes pretty quickly. You can do the same thing on individual Lisp files in a package, to find just which part(s) are troublesome.
    – Drew
    May 8, 2020 at 22:54
  • @f-sasa, I looked at doom, it seems to not be well tested for Windows. It seems like a framework to manage emacs packages and recommends emacs 27, which is not out yet. Seems like a beta testing version. I can give it a shot though. I'll try it and update.
    – archmuon
    May 9, 2020 at 22:08
  • @Drew thanks! Will try that. I might have to do this carefully, since some packages were installed through use-package following examples on the web, while some others were directly installed using M-x package-install command.
    – archmuon
    May 9, 2020 at 22:10
  • Yes, you might need to proceed methodically. But overall it's really pretty simple and quick.
    – Drew
    May 10, 2020 at 4:32

2 Answers 2

1

I also run Emacs on Windows and I used to have a start up time of about 20 seconds, just like you. I've gotten my startup time down to 3-5 seconds by following many of the principles in this post. Also, if you don't want to use Doom Emacs, you can still use many of the tips that its creator suggests. One tip I've found for speeding up things is to use the MELPA Stable distribution for some packages, and use the normal MELPA distribution for others, depending on which loads up faster. In general MELPA Stable is faster because all the debugging code has been removed, but there are exceptions.

Other than that, bisection and profiling your code are the only ways to find where the bottlenecks are. I've found profile-dotemacs to be more useful for this.

6
  • Thanks! The first step from that post "Measure the best possible start-up time" shows 5.3secs for me which is quite disappointing to begin with. In any case, I'm not very good with Elisp and not comfortable yet with using use-package. The syntax and commands are quite confusing to me at this point. So I think I'll have to simply spend some time learning that separately. So, in the interest of time I'm finally trying out doom. Once I hit doom install, it's been cloning and building a whole bunch of packages and the .emacs.d folder has grown to almost 0.5GB. Is that normal?
    – archmuon
    May 12, 2020 at 3:23
  • Doom seems to be equally worse. 141 packages loaded in 22.5secs. Out of the box experience is quite bad. It might just be windows. I'll try to learn use-packages and work with my older emacs config.
    – archmuon
    May 12, 2020 at 3:32
  • Really? If you run emacs -q --eval='(message "%s" (emacs-init-time))' it takes 5.3 seconds?! For me it takes only 0.2 seconds. What are the specs on your Windows machine?
    – shankar2k
    May 13, 2020 at 12:16
  • No, I tried the step1 from this post: blog.d46.us/advanced-emacs-startup (which you shared above). the latest command you gave: emacs -q.... doesn't print any time anywhere. My machine is core i56300U 2.5GHz, 20GB RAM, 64-bit operating system.
    – archmuon
    May 13, 2020 at 23:45
  • The command I listed is step 1 of the blog post, 2nd code block. The blog post assumes that one is running a UNIX-like system. To get the command to work in Windows, I had to modify the command to: emacs -q --eval="(message \"%s\" (emacs-init-time))" The specs of your machine are quite good. I see no reason why barebones emacs should take more than one second to start up.
    – shankar2k
    May 14, 2020 at 10:10
0

Windows is bad at handling many small files.
You could try to put as much as possible (elisp code, even autoloads) in as less as possible files.
Also lazy loading is cruicial (use-package helps a lot here).

I heard that with Windows also magit crawls, because Windows is bad at spawning multiple small processes in fast succession. (there should be a speedup in the working (or it's even finished))

Running Emacs in WSL is reported to be much faster, also magit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.