Fix lag in LSP mode due to garbage collection

Used profiler to determine more than 80% of time was spent in garbage
collection...
Lowering the value back to the default fixes the lag.
This commit is contained in:
laurensmiers 2020-04-20 14:07:56 +02:00
parent e9b132d7e8
commit 586aa741df
2 changed files with 31 additions and 12 deletions

View file

@ -228,15 +228,27 @@ so rebind it to something easy to remember.
** Garbage collection (gc)
I used to have the following enabled in my init to increase the gc threshold to speed-up emacs startup:
(stolen from [[http://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/]])
A lot of articles/sites/posts/... about this:
- [[https://lists.gnu.org/archive/html/help-gnu-emacs/2007-06/msg00243.html ]]
- https://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/
- ...
This just contains some hooks to stop/enable the GC at critical moments.
I'm not touching the value except during startup.
If I leave it too high, I got a lot of lag when using LSP mode, so just leave it at the default value.
I just 'Disable' GC in the minibuffer, I don't want lags/hangups/... in the minibuffer.
#+BEGIN_SRC emacs-lisp
(setq gc-cons-threshold 100000000)
#+END_SRC
(defun my-minibuffer-setup-hook ()
(setq gc-cons-threshold most-positive-fixnum))
But according to this: [[https://lists.gnu.org/archive/html/help-gnu-emacs/2007-06/msg00243.html ]],
it is no longer necessary. But I found that I still have to do this to speed up emacs.
(defun my-minibuffer-exit-hook ()
(setq gc-cons-threshold 800000))
(add-hook 'minibuffer-setup-hook #'my-minibuffer-setup-hook)
(add-hook 'minibuffer-exit-hook #'my-minibuffer-exit-hook)
#+END_SRC
** Yes-or-no questions