News for hackers. Stuff that matters.
Re:Emacs for Professionals by rs_rs_rs_rs_rs on Tuesday May 03, 2022 @05:48AM (#31246446)
Would love to use emacs but for my use case everytime I open a relatively big json file it takes couple of sends until emacs is usable while lsp and other plugins run on it. I keep hitting these annoying lags when I can't use the tool for 1-2 seconds while something runs.

Is this something I could avoid or it's unavoidable since Emacs is single threaded?

Using Doom Emacs at the moment.

Re:Emacs for Professionals by TacticalCoder on Tuesday May 03, 2022 @06:18AM (#31246596)
What is your hardware? How fast is your Emacs? Ryzen 3700K here:

    time emacs -nw -Q -eval '(kill-emacs)'     <- no GUI, no config file at all
0.086s in my case (86 milliseconds) and I think that's relatively slow compare to machines others have here (5900X / 12th gen Intel / M1 macs etc.).

Then:

    time emacs -eval '(kill-emacs)'
1.4s (loading a very big custom Emacs setup).

Are you using the native-comp branch of Emacs?

Are you using a native JSON parsing lib? (not sure if it helps to open JSON files themselves but it speeds up LSP greatly, for LSP uses JSON files).

> Is this something I could avoid or it's unavoidable since Emacs is single threaded?

I don't know about gigantic JSON files but that's very weird to me: I can start working on my Clojure files while LSP is starting. And LSP is definitely starting in another process that is not blocking the Emacs thread.

Emacs may use a single kernel thread but there are lots of things that are done by external processes.

I'm not saying there aren't things that can block Emacs but, in my case, although LSP is still slow to start up, it's definitely not blocking my Emacs (top, for example, shows clojure-lsp running as its own process).

I'm using Emacs since decades and it has never felt faster than nowadays: newer hardware, NVMe SSD, native-compilation branch, integration of ripgrep and fzf (two amazing helper tools that are insanely fast) through ivy/counsel (counsel-rg / counsel-fzf)...

Cherry on top: I now get the LSP servers and although it's not IntelliJ yet, it's much better than any "Emacs" I used in the past.

Re:Emacs for Professionals by rs_rs_rs_rs_rs on Tuesday May 03, 2022 @07:07AM (#31246880)
I do have a relatively old processor, i5-4460, but it's not THAT old, fast SSD.

I'm only using the nativecomp branch and doom-emacs starts in 1.4 seconds here too.

Someone suggested eglot instead of lsp-mode, will give that a try.

Re:Emacs for Professionals by arc-in-space on Tuesday May 03, 2022 @08:05AM (#31247287)
Large files are an eternal issue with emacs, typically I open them with 'find-file-literally' to disable the more expensive modes.
Re:Emacs for Professionals by natrys on Tuesday May 03, 2022 @12:14PM (#31250067)
Disable lsp if you don't need it? That said, big slowdowns are also usually down to syntax highlighting. You can either disable that, or better yet switch from the old font-lock method to new tree-sitter based one. Here is a recent thread you might find useful:

https://old.reddit.com/r/emacs/comments/u4q2wl/treesitter_hi...

Re:Emacs for Professionals by stnmtn on Tuesday May 03, 2022 @01:29PM (#31251000)
Reading the replies to this is very humorous when you contrast it with the usual hacker news replies whenever someone mentions VSCode, complaining about how electron is slow and buggy, when comparitvely VSCode is lightning fast compared to emacs and doesn't require intimate knowledge about emacs internals to simply open a large json file.
Re:Emacs for Professionals by danhor on Tuesday May 03, 2022 @07:30AM (#31247026)
You could not load some modes if the file you're loading is large, in the somewhat extreme case fundamental-mode usually performs fine.
Re:Emacs for Professionals by pjm331 on Tuesday May 03, 2022 @05:58AM (#31246486)
Have you tried the eglot package for LSP instead of lsp-mode?

Can toggle it on with +eglot flag for lsp module in your doom config

I was having the same issues and that solved it for me