From c344d40d155120d063cc3519a58feca97daece62 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 11 Oct 2020 19:46:08 -0400 Subject: [PATCH] tools/lsp: refactor +lsp-optimization-mode --- modules/tools/lsp/config.el | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/modules/tools/lsp/config.el b/modules/tools/lsp/config.el index 8831e1fd4..b446ada27 100644 --- a/modules/tools/lsp/config.el +++ b/modules/tools/lsp/config.el @@ -19,23 +19,22 @@ killing and opening many LSP/eglot-powered buffers.") "Deploys universal GC and IPC optimizations for `lsp-mode' and `eglot'." :global t :init-value nil - (if +lsp-optimization-mode - (progn - (setq +lsp--default-read-process-output-max - (default-value 'read-process-output-max) - +lsp--default-gcmh-high-cons-threshold - (default-value 'gcmh-high-cons-threshold)) - ;; `read-process-output-max' is only available on recent development - ;; builds of Emacs 27 and above. - (setq-default read-process-output-max (* 1024 1024)) - ;; REVIEW LSP causes a lot of allocations, with or without Emacs 27+'s - ;; native JSON library, so we up the GC threshold to stave off - ;; GC-induced slowdowns/freezes. Doom uses `gcmh' to enforce its - ;; GC strategy, so we modify its variables rather than - ;; `gc-cons-threshold' directly. - (setq-default gcmh-high-cons-threshold (* 2 +lsp--default-gcmh-high-cons-threshold))) - (setq-default read-process-output-max +lsp--default-read-process-output-max - gcmh-high-cons-threshold +lsp--default-gcmh-high-cons-threshold)) + (if (not +lsp-optimization-mode) + (setq-default read-process-output-max +lsp--default-read-process-output-max + gcmh-high-cons-threshold +lsp--default-gcmh-high-cons-threshold) + (setq +lsp--default-read-process-output-max + (default-value 'read-process-output-max) + +lsp--default-gcmh-high-cons-threshold + (default-value 'gcmh-high-cons-threshold)) + ;; `read-process-output-max' is only available on recent development + ;; builds of Emacs 27 and above. + (setq-default read-process-output-max (* 1024 1024)) + ;; REVIEW LSP causes a lot of allocations, with or without Emacs 27+'s + ;; native JSON library, so we up the GC threshold to stave off + ;; GC-induced slowdowns/freezes. Doom uses `gcmh' to enforce its + ;; GC strategy, so we modify its variables rather than + ;; `gc-cons-threshold' directly. + (setq-default gcmh-high-cons-threshold (* 2 +lsp--default-gcmh-high-cons-threshold))) (gcmh-set-high-threshold))