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:
parent
e9b132d7e8
commit
586aa741df
2 changed files with 31 additions and 12 deletions
24
config.org
24
config.org
|
|
@ -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
|
||||
|
||||
|
|
|
|||
7
init.el
7
init.el
|
|
@ -17,6 +17,12 @@
|
|||
(package-refresh-contents)
|
||||
(package-install 'use-package))
|
||||
|
||||
;;; Increase garbage collection threshold during init but leave it to the default value after
|
||||
;;; There are a LOT of articles/sites/... discussing this:
|
||||
;;; https://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/
|
||||
;;; https://jonnay.github.io/emagicians-starter-kit/Emagician-Base.html
|
||||
;;; ...
|
||||
(let ((gc-cons-threshold most-positive-fixnum))
|
||||
;; This is the actual config file. It is omitted if it doesn't exist so emacs won't refuse to launch.
|
||||
(when (file-readable-p "~/.emacs.d/config.org")
|
||||
(org-babel-load-file (expand-file-name "~/.emacs.d/config.org")))
|
||||
|
|
@ -24,5 +30,6 @@
|
|||
;; If it exists, load some project-specific configurations.
|
||||
(when (file-readable-p "~/.emacs.d/project.org")
|
||||
(org-babel-load-file (expand-file-name "~/.emacs.d/project.org")))
|
||||
)
|
||||
|
||||
(provide 'init)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue