reddit / emacs
Blazing fast starup like in 1995
NoeticIntelligence · 2022-08-19 00:53
Back in 1993 or 1994 I installed Linux on a home PC for the first time.
I think it was Yggdrasil I got my paws on.
I had to travel some distance to buy set of cds.
The servers I had access to at work were huge and powerful
but so many people were using them 24/7 that the interaction
was slow.
Starting Emacs was slow.
Eventually I got my Pentium PC to run Linux and that was a magical moment.
I logged in and started Emacs.
I was blown away
It just popped up.
So much power in my hands.
Pop forwards to today.
I am running Ubuntu on a nice Core9 with 32GB.
Immensely powerful.
Starting Emacs takes time.
How can it be that with all this power it is slower?
Then last week I installed OpenBSD 7 on a much slower system.
I logged in. Installed Emacs.
I started it up and --bang-- it is up.
Just like in 1993/4.
Now this is all using the standard OpenBSD and Ubuntu Emacs packages.
With 0 customizations, configs, or anything else.
My guess would be that if I dug into the packages I would find
that the Ubuntu default has more stuff in it.
It was a nostalgic feeling though.
WingFat92 · 2022-08-19 00:57
I have much less spec than you and my emacs starts instantly with custom config, using arch Linux, it’s probably an Ubuntu issue.
I also have emacs on Gentoo, also starts instantly.
cellular--automaton · 2022-08-19 01:19
SSD vs HDD maybe ?
ideasman_42 · 2022-08-19 01:32
I keep seeing reports of emacs starting slow but often reports lack any details.
* How long does your emacs take to start?
* How many packages are you using?
My emacs starts in around 0.66 seconds on a modern PC, with 72 packages including LSP/DAP/Evil-mode/spell checking etc.
In case this helps here is my personal config: https://bitbucket.org/ideasman42/dotfiles/src/master/.config/emacs/
[deleted] · 2022-08-19 01:51
First of all, emacs isn't the same program it was in 1993.
Second, try starting with emacs -q, if it's instant then the problem is your config. It's pretty easy to accidentally put something really slow in there that can be sped up easily.
I just leave slow stuff in there because I only start emacs once per boot.
redguardtoo · 2022-08-19 01:59
Learn some Emacs Lisp APIs `autoload`, `with-eval-after-load`, `prog-mode-hook`, `run-with-idle-timer` which are often used in startup optimization.
You can also read code and documentation of third party distributions like doomemacs to learn optimization skills.
My emacs starts up in 0.6 seconds on Linux and 2 seconds on Windows. And my low spec computer is 10 years old (still using Intel i3 cpu).
Here is my emacs.d,
[https://github.com/redguardtoo/emacs.d](https://github.com/redguardtoo/emacs.d)
henry7579 · 2022-08-19 02:33
Do you use desktop.el? Mine takes minutes to load because of all the open file buffers I have.
LynxOfTheWastes · 2022-08-19 03:30
Run it as a daemon.
zennnderrr · 2022-08-19 05:38
Ubuntu known to install "snap" packages by default which can be slow to startup. Check if this the case for you
[deleted] · 2022-08-19 06:04
[deleted]
arthurno1 · 2022-08-19 06:35
> How can it be that with all this power it is slower?
Longer time from disk to RAM with all caches, more complex OS, more latency in hardware due to more stages, different communication protocols (more complex) etc?
On my Arch Linux system, emacs-init-time for emacs -Q says 0.2s, and on Windows it says 0.3s. For a human, it should "feel" instant. But it feels much longer. Either emacs-init-time repports wrong time, or time to display a window on the screen is much longer.
PS. To previous commenters; dude already said 0 config:
> With 0 customizations, configs, or anything else.
;-)
aard_fi · 2022-08-19 07:04
Does the Ubuntu one have native comp enabled? I noticed significantly longer startups as well as occasional hangs/delays later on when stuff gets autoloaded, which turned out to be the compiler trying to locate files.
I didn't find a way to turn off native comp without recompiling, so didn't do that yet, but so far I don't see any benefit in having that enabled.
__f · 2022-08-19 07:10
So a lot of people don't realize this but emacs has a daemon that runs in the background. You can pretty much set it to start up as soon as you get ubuntu running. The second part of this is that emacs is actually primarily a gui application; this means you don't really want to run it from the terminal. So setting up the daemon + opening the gui application it pretty much opens up instantly, even if you have plugins and whatnot.
Of course do go ahead and check that your configurations are actually optimal and aren't causing lag. But beyond that run the daemon and run the gui application.
Ironballs · 2022-08-19 08:43
My emacs (29, from git) with 100+ packages starts up in ~0.3s on Linux w/ native comp and pgtk
The secret: use-package + :defer
cradlemann · 2022-08-19 09:18
My Emacs start up less than second without daemon-mode. Latest master, compiled with `pgtk` and `native-comp` features.
https://github.com/Crandel/home/tree/master/.config/emacs
c96aes · 2022-08-19 10:41
In addition to all the other suggestions, I can report that I'm happy with running Emacs server as a user systemd service. This makes *emacsclient* a near instantaneous experience, despite crazy amounts of custom nonsense.
It might not be for everyone, but I'm happy with it. One of the underestimated things is how it makes the whole "oh, have I started the server, or should I do that now?"-moment go away.
ideasman_42 · 2022-08-19 11:00
Odd, have been using native compilation since it was usable (pre-release) and never noticed long startup times or hangs.
itoshkov · 2022-08-19 11:24
This.
[deleted] · 2022-08-19 11:25
[deleted]
sunnyata · 2022-08-19 11:25
> How many packages are you using?
None -- did you read the post?
sunnyata · 2022-08-19 11:26
No, they said this is with zero config.
fazalmajid · 2022-08-19 12:09
If the Linux distro ships with a `default.el` the lack of a `.emacs` does not mean no packages loaded.
onearmedphil · 2022-08-19 12:21
Man you got to tell everyone that you use arch and gentoo in one post!
(Just kidding/teasing of course)
icemanblues · 2022-08-19 12:54
This!
Run an emacs server daemon as a systems user service.
Then change $EDITOR to be emacsclient.
agumonkey · 2022-08-19 14:09
could you `time` emacs startup under bsd7 ? or even `strace` it ?
hkjels · 2022-08-19 14:57
Ubuntu with snap has become unusable over the years as someone else mentioned. Ubuntu stems from Debian, which is still fast and reliable
iofthestorm · 2022-08-19 18:47
Neat idea! I just have emacs set up as an alias to emacsclient which auto starts the server if not running.
HumanBrainMapper · 2022-08-19 20:22
about defer: https://emacs.stackexchange.com/questions/41329/when-to-use-defer-in-use-package
BettaGeorge · 2022-08-20 00:09
Everything on Ubuntu takes time. It's basically Windows.
ideasman_42 · 2022-08-20 11:17
Emacs comes with packages, even `emacs -Q` loads certain functionality (it's not exactly bare bones although it's close).
And you still didn't mention how long it takes to start.
PerdejniyGas · 2022-08-21 05:15
Is GUI emacs work faster than terminal version?
__f · 2022-08-21 09:32
I don't know for sure since I don't really use emacs anymore these days. But as far as i'm concerned the only thing that gets faster is startup times when using the daemon + gui. I'm not sure that the daemon affects the actual emacs experience past startup.
yedefash · 2022-08-21 11:39
impressive configuration, can it be used without the evil module ?
I disable evil module so that to keep vanilla emacs flavor
cradlemann · 2022-08-21 11:59
Yes sure, just comment `(require evil-rcp)` in init.el
yedefash · 2022-08-21 13:40
it will not affect the others module ?
yedefash · 2022-08-21 13:46
can you create a separate repo just for your emacs config ?
I had to clone your whole home config.
yedefash · 2022-08-21 13:51
tempel-rcp is not in the receipes folder
cradlemann · 2022-08-21 13:58
It shouldn't affect other modules, but I didn't test it
cradlemann · 2022-08-21 13:58
Sorry I had no time for this
yedefash · 2022-08-21 14:01
deactivating evil-rcp gives error with module hydra-rcp
https://github.com/Crandel/home/blob/master/.config/emacs/recipes/hydra-rcp.el#L38
[deleted] · 2022-08-21 14:03
[deleted]
cradlemann · 2022-08-21 15:50
I added `tempel-rcp.el` into `recipes`
yedefash · 2022-09-20 10:42
disabeling evil-mode gives this error
​
Debugger entered--Lisp error: (void-variable evil-normal-state-map) (and evil-normal-state-map (symbolp evil-normal-state-map)) (if (and evil-normal-state-map (symbolp evil-normal-state-map)) (symbol-value evil-normal-state-map) evil-normal-state-map) (or (if (and evil-normal-state-map (symbolp evil-normal-state-map)) (symbol-value evil-normal-state-map) evil-normal-state-map) global-map) (let\* ((name "gri") (key "gri") (kmap (or (if (and evil-normal-state-map (symbolp evil-normal-state-map)) (symbol-value evil-normal-state-map) evil-normal-state-map) global-map)) (kdesc (cons (if (stringp name) name (key-description name)) (if (symbolp evil-normal-state-map) evil-normal-state-map 'evil-normal-state-map))) (binding (lookup-key kmap key))) (let ((entry (assoc kdesc personal-keybindings)) (details (list #'org-insert-structure-template (if (numberp binding) nil binding)))) (if entry (setcdr entry details) (add-to-list 'personal-keybindings (cons kdesc details)))) (define-key kmap key #'org-insert-structure-template)) (lambda nil (let\* ((name "gri") (key "gri") (kmap (or (if (and evil-normal-state-map (symbolp evil-normal-state-map)) (symbol-value evil-normal-state-map) evil-normal-state-map) global-map)) (kdesc (cons (if (stringp name) name (key-description name)) (if (symbolp evil-normal-state-map) evil-normal-state-map 'evil-normal-state-map))) (binding (lookup-key kmap key))) (let ((entry (assoc kdesc personal-keybindings)) (details (list #'org-insert-structure-template (if (numberp binding) nil binding)))) (if entry (setcdr entry details) (add-to-list 'personal-keybindings (cons kdesc details)))) (define-key kmap key #'org-insert-structure-template)))() eval-after-load-helper("/usr/share/emacs/28.2/lisp/org/org.elc") do-after-load-evaluation("/usr/share/emacs/28.2/lisp/org/org.elc") (org-babel-load-file "\~/.emacs.d/config.org") load-with-code-conversion("/home/perrierjouet/.emacs.d/init.el" "/home/perrierjouet/.emacs.d/init.el" t t) load("/home/perrierjouet/.emacs.d/init" noerror nomessage) startup--load-user-init-file(#f(compiled-function () #<bytecode 0x176324ea7ccdb9b8>) #f(compiled-function () #<bytecode -0x1f3c686ddc0ca9b5>) t) command-line() normal-top-level()
cradlemann · 2022-09-20 10:50
Fill free to remove evil references. I use evil, so I will not change anything