reddit / emacs
Slow emacs startup only on work laptop
Horrih · 2022-04-03 13:06
Hello guys,
I have been using emacs with around 50 packages installed either directly or as dependencies.
Emacs is awefully slow to start on my work laptop , around 25 seconds.
Some more info :
- 1s for vanilla emacs
- 8s empty init.el but with the 50 packages installed
- 25 s for the full setup.
The full startup on my windows potato laptop from 2014 is 2s. It is also 2s for a linux VM on the work laptop.
I am suspecting some windows group policy settings or antivirus settings. Anyone has faced similar performance drop ?
Task manager shows heavy cpu usage during the whole startup
Thanks !
Walheimat · 2022-04-03 14:26
Hard to say without seeing your init file. Are you by chance refreshing your package archives on startup? If you think it's the packages and you're using `use-package` macro, you could set `use-package-compute-statistics` to `t` and run `use-package-report` after init.
Horrih · 2022-04-03 14:31
Thanks will try it to check if it finds anything interesting.
But i don't think my init is at fault : as i said when i remove the init file it starts in 8s (to be compared with 1s if i also delete the elpa folder). For some reason the parsing and/or exécution of elisp seems painfully slow
On my potato laptop running w10 as well it's 2s for the whole startup, Everything included. So literally 10x faster
BlaFasl_sagIchdoch · 2022-04-03 15:29
There must be a pdump file in libexec/emacs/. In Order to speedup loading files.
Lalylulelo · 2022-04-03 18:54
I experience something similar since we switch to Kerberos authentication to be compatible with Windows Active Directory. It slows everything on Linux and my Emacs startup time on desktop is incredibly slow.
thisadamis · 2022-04-03 20:19
I have this problem too. Mine is so slow I can’t even use it. 🤔
mmmnop000 · 2022-04-03 20:36
Have you tried running `M-x esup` with https://github.com/jschaf/esup to see what is taking up the start-up time?
Horrih · 2022-04-03 20:55
Use package report helped me go down from 28s to 18s by disabling helm and doom modeline, basically the only packages i load at startup.
5sec for a single package is not normal, every single function seems awfully slow even after Everything has been loaded
My [init.el](https://github.com/Horrih/config/blob/main/.emacs) file in case it helps.
Walheimat · 2022-04-03 22:02
Are you on an older Emacs? I don't think you need to call `package-initialize` since 27. You also don't need to immediately load dashboard which will likely load a bunch of other packages (at least `projectile`). You can use `:hook (after-init . dashboard-setup-startup-hook)`. I don't expect much improvement from these changes. You could sort the `use-package` statistics and check if the lazy-loaded packages are actually configured already when they shouldn't be. Even 18s seems massive.
MistakeNotDotDotDot · 2022-04-03 23:42
Do you have antivirus software on your work laptop? I've noticed performance differences on my work laptop vs. my personal one, though not nearly as bad.
Phil-Hudson · 2022-04-03 23:52
OK, this idea is either going to strike you as a life-changer or just very annoying. Here it is: forget startup time. Stop worrying about it. Ignore it. Just start Emacs, wait however long it takes, then (and this is the crucial part) \*never quit Emacs\*. Average your startup time over the number of weeks that Emacs is running and marvel as the ratio tends toward zero.
Horrih · 2022-04-04 05:26
Yes I do, sadly I can't disable it
Horrih · 2022-04-04 05:28
Tried it, every single use package section takes a lot of time. Even my misc section where i only do a brunch of setq takes a non negligeable time
MistakeNotDotDotDot · 2022-04-04 05:28
It's definitely at least possible that's messing with you. Not sure how I'd test it if you can't disable it, though :/ Can you look at the AV logs or ask your IT department?
Horrih · 2022-04-04 05:29
We also use Kerberos here, maybe the issue is related. Don't know how to confirm/infirm tjis hypothesis though
BlaFasl_sagIchdoch · 2022-04-04 09:56
With regard to Kerberos, it takes:
- time kinit 0,01s user
With regard to emacs:
- time bin/emacs 3,02s user 0,58s system
7890yuiop · 2022-04-04 10:28
Are you using Emacs 28 or later *with* native-compilation?
If so, my bet is https://old.reddit.com/r/emacs/comments/sed9oy/native_compilation_vs_virus_scanners/
Rebuilding without native compilation should get you back to normal start-up times (and load-times in general) if that's the issue. Your call as to whether that's a worthwhile trade, obviously.
thisadamis · 2022-04-04 11:54
Hard to do when you are building your init config for the first time right? Unless there is a command to reload the config file.
thisadamis · 2022-04-04 11:57
well i feel stupid lol. There is a eval-buffer command!
Horrih · 2022-04-05 06:46
Thank you all for your time.
My many attempts have not been successful on 27.2
However upgrading to the just released 28.1 fixed the issue to some extent : down to 7 sec from \~25. And this is without native compiling my packages. Still a far shot from the 2s of the VM on the same computer but definitely usable.
So either some weird interaction has been fixed, or just the sheer performance enhancement of native compiling the built in packages helped, either way I am quite happy.
See [screenshot](https://picbun.com/p/ArxBu5AL)
7890yuiop · 2022-04-05 07:52
> So either some weird interaction has been fixed, or just the sheer performance enhancement of native compiling the built in packages helped
The former, presumably -- I don't believe you're going to see any load-time benefits from the native-compilation feature.
Per my other comment, you should probably also test a build *without* native compilation.