Reformat gc optimization & gc on focus-out

Also raises the gc upper limit to 512mb
This commit is contained in:
Henrik Lissner 2019-05-13 19:28:51 -04:00
parent ddb03c6335
commit 20596cd41f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 18 additions and 11 deletions

View file

@ -245,16 +245,6 @@ original value of `symbol-file'."
(funcall orig-fn symbol type)))
(advice-add #'symbol-file :around #'doom*symbol-file)
;; To speed up minibuffer commands (like helm and ivy), defer garbage collection
;; when the minibuffer is active. It may mean a pause when finished, but that's
;; acceptable instead of pauses during.
(defun doom|defer-garbage-collection ()
(setq gc-cons-threshold doom-gc-cons-upper-limit))
(defun doom|restore-garbage-collection ()
(setq gc-cons-threshold doom-gc-cons-threshold))
(add-hook 'minibuffer-setup-hook #'doom|defer-garbage-collection)
(add-hook 'minibuffer-exit-hook #'doom|restore-garbage-collection)
;; File+dir local variables are initialized after the major mode and its hooks
;; have run. If you want hook functions to be aware of these customizations, add
;; them to MODE-local-vars-hook instead.
@ -273,6 +263,23 @@ original value of `symbol-file'."
(add-hook 'after-change-major-mode-hook #'doom|run-local-var-hooks-if-necessary)
;;
;;; Garbage collector optimizations
;; To speed up minibuffer commands (like helm and ivy), defer garbage collection
;; when the minibuffer is active. It may mean a pause when finished, but that's
;; acceptable instead of pauses during.
(defun doom|defer-garbage-collection ()
(setq gc-cons-threshold doom-gc-cons-upper-limit))
(defun doom|restore-garbage-collection ()
(setq gc-cons-threshold doom-gc-cons-threshold))
(add-hook 'minibuffer-setup-hook #'doom|defer-garbage-collection)
(add-hook 'minibuffer-exit-hook #'doom|restore-garbage-collection)
;; GC all sneaky breeky like
(add-hook 'focus-out-hook 'garbage-collect)
;;
;;; Incremental lazy-loading

View file

@ -31,7 +31,7 @@
"The default value to use for `gc-cons-threshold'. If you experience freezing,
decrease this. If you experience stuttering, increase this.")
(defvar doom-gc-cons-upper-limit 268435456 ; 256mb
(defvar doom-gc-cons-upper-limit 536870912 ; 512mb
"The temporary value for `gc-cons-threshold' to defer it.")