tools/lsp: refactor +lsp-optimization-mode

This commit is contained in:
Henrik Lissner 2020-10-11 19:46:08 -04:00
parent ebc1e7092d
commit c344d40d15
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -19,23 +19,22 @@ killing and opening many LSP/eglot-powered buffers.")
"Deploys universal GC and IPC optimizations for `lsp-mode' and `eglot'." "Deploys universal GC and IPC optimizations for `lsp-mode' and `eglot'."
:global t :global t
:init-value nil :init-value nil
(if +lsp-optimization-mode (if (not +lsp-optimization-mode)
(progn (setq-default read-process-output-max +lsp--default-read-process-output-max
(setq +lsp--default-read-process-output-max gcmh-high-cons-threshold +lsp--default-gcmh-high-cons-threshold)
(default-value 'read-process-output-max) (setq +lsp--default-read-process-output-max
+lsp--default-gcmh-high-cons-threshold (default-value 'read-process-output-max)
(default-value 'gcmh-high-cons-threshold)) +lsp--default-gcmh-high-cons-threshold
;; `read-process-output-max' is only available on recent development (default-value 'gcmh-high-cons-threshold))
;; builds of Emacs 27 and above. ;; `read-process-output-max' is only available on recent development
(setq-default read-process-output-max (* 1024 1024)) ;; builds of Emacs 27 and above.
;; REVIEW LSP causes a lot of allocations, with or without Emacs 27+'s (setq-default read-process-output-max (* 1024 1024))
;; native JSON library, so we up the GC threshold to stave off ;; REVIEW LSP causes a lot of allocations, with or without Emacs 27+'s
;; GC-induced slowdowns/freezes. Doom uses `gcmh' to enforce its ;; native JSON library, so we up the GC threshold to stave off
;; GC strategy, so we modify its variables rather than ;; GC-induced slowdowns/freezes. Doom uses `gcmh' to enforce its
;; `gc-cons-threshold' directly. ;; GC strategy, so we modify its variables rather than
(setq-default gcmh-high-cons-threshold (* 2 +lsp--default-gcmh-high-cons-threshold))) ;; `gc-cons-threshold' directly.
(setq-default read-process-output-max +lsp--default-read-process-output-max (setq-default gcmh-high-cons-threshold (* 2 +lsp--default-gcmh-high-cons-threshold)))
gcmh-high-cons-threshold +lsp--default-gcmh-high-cons-threshold))
(gcmh-set-high-threshold)) (gcmh-set-high-threshold))