Fix #4093: runaway gc-cons-threshold in lsp-mode
gc-cons-threshold was doubled every time an lsp-mode buffer was opened (i.e. every time +lsp-optimization-mode was activated) causing heavy freezes.
This commit is contained in:
parent
d85c7b857b
commit
1c7fd9c220
1 changed files with 20 additions and 15 deletions
|
@ -14,6 +14,7 @@ killing and opening many LSP/eglot-powered buffers.")
|
||||||
|
|
||||||
(defvar +lsp--default-read-process-output-max nil)
|
(defvar +lsp--default-read-process-output-max nil)
|
||||||
(defvar +lsp--default-gcmh-high-cons-threshold nil)
|
(defvar +lsp--default-gcmh-high-cons-threshold nil)
|
||||||
|
(defvar +lsp--optimization-init-p nil)
|
||||||
|
|
||||||
(define-minor-mode +lsp-optimization-mode
|
(define-minor-mode +lsp-optimization-mode
|
||||||
"Deploys universal GC and IPC optimizations for `lsp-mode' and `eglot'."
|
"Deploys universal GC and IPC optimizations for `lsp-mode' and `eglot'."
|
||||||
|
@ -21,7 +22,10 @@ killing and opening many LSP/eglot-powered buffers.")
|
||||||
:init-value nil
|
:init-value nil
|
||||||
(if (not +lsp-optimization-mode)
|
(if (not +lsp-optimization-mode)
|
||||||
(setq-default read-process-output-max +lsp--default-read-process-output-max
|
(setq-default read-process-output-max +lsp--default-read-process-output-max
|
||||||
gcmh-high-cons-threshold +lsp--default-gcmh-high-cons-threshold)
|
gcmh-high-cons-threshold +lsp--default-gcmh-high-cons-threshold
|
||||||
|
+lsp--optimization-init-p nil)
|
||||||
|
;; Only apply these settings once!
|
||||||
|
(unless +lsp--optimization-init-p
|
||||||
(setq +lsp--default-read-process-output-max
|
(setq +lsp--default-read-process-output-max
|
||||||
(default-value 'read-process-output-max)
|
(default-value 'read-process-output-max)
|
||||||
+lsp--default-gcmh-high-cons-threshold
|
+lsp--default-gcmh-high-cons-threshold
|
||||||
|
@ -34,8 +38,9 @@ killing and opening many LSP/eglot-powered buffers.")
|
||||||
;; GC-induced slowdowns/freezes. Doom uses `gcmh' to enforce its
|
;; GC-induced slowdowns/freezes. Doom uses `gcmh' to enforce its
|
||||||
;; GC strategy, so we modify its variables rather than
|
;; GC strategy, so we modify its variables rather than
|
||||||
;; `gc-cons-threshold' directly.
|
;; `gc-cons-threshold' directly.
|
||||||
(setq-default gcmh-high-cons-threshold (* 2 +lsp--default-gcmh-high-cons-threshold)))
|
(setq-default gcmh-high-cons-threshold (* 2 +lsp--default-gcmh-high-cons-threshold))
|
||||||
(gcmh-set-high-threshold))
|
(gcmh-set-high-threshold)
|
||||||
|
(setq +lsp--optimization-init-p t))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue