Use gcmh package to manage adjust GC interactively
This commit is contained in:
parent
d41e4983ec
commit
db19241936
3 changed files with 17 additions and 34 deletions
|
@ -336,5 +336,6 @@ will be automatically appended to the result."
|
|||
(setq doom-debug-mode value
|
||||
debug-on-error value
|
||||
jka-compr-verbose value
|
||||
lsp-log-io value)
|
||||
lsp-log-io value
|
||||
gcmh-verbose value)
|
||||
(message "Debug mode %s" (if value "on" "off"))))
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
package's name as a symbol, and whose CDR is the plist supplied to its
|
||||
`package!' declaration. Set by `doom-initialize-packages'.")
|
||||
|
||||
(defvar doom-core-packages '(straight use-package async)
|
||||
(defvar doom-core-packages '(straight use-package async gcmh)
|
||||
"A list of packages that must be installed (and will be auto-installed if
|
||||
missing) and shouldn't be deleted.")
|
||||
|
||||
|
|
46
core/core.el
46
core/core.el
|
@ -25,6 +25,12 @@
|
|||
;; You get a minor speed up by nooping this.
|
||||
(setq file-name-handler-alist nil)
|
||||
|
||||
;; Restore `file-name-handler-alist', because it is needed for handling
|
||||
;; encrypted or compressed files, among other things.
|
||||
(defun doom-reset-file-handler-alist-h ()
|
||||
(setq file-name-handler-alist doom--initial-file-name-handler-alist))
|
||||
(add-hook 'emacs-startup-hook #'doom-reset-file-handler-alist-h)
|
||||
|
||||
;; Load the bare necessities
|
||||
(require 'core-lib)
|
||||
|
||||
|
@ -49,10 +55,6 @@ DEBUG envvar will enable this at startup.")
|
|||
(defvar doom-interactive-mode (not noninteractive)
|
||||
"If non-nil, Emacs is in interactive mode.")
|
||||
|
||||
(defvar doom-gc-cons-threshold 16777216 ; 16mb
|
||||
"The default value to use for `gc-cons-threshold'. If you experience freezing,
|
||||
decrease this. If you experience stuttering, increase this.")
|
||||
|
||||
;;; Directories/files
|
||||
(defconst doom-emacs-dir
|
||||
(eval-when-compile (file-truename user-emacs-directory))
|
||||
|
@ -261,34 +263,14 @@ users).")
|
|||
(unless IS-MAC (setq command-line-ns-option-alist nil))
|
||||
(unless IS-LINUX (setq command-line-x-option-alist nil))
|
||||
|
||||
;; Restore `file-name-handler-alist' because it is necessary for handling
|
||||
;; encrypted or compressed files, among other things.
|
||||
(defun doom-restore-file-name-handler-alist-h ()
|
||||
(setq file-name-handler-alist doom--initial-file-name-handler-alist))
|
||||
(add-hook 'emacs-startup-hook #'doom-restore-file-name-handler-alist-h)
|
||||
|
||||
;; To speed up minibuffer commands (like helm and ivy), we defer garbage
|
||||
;; collection while the minibuffer is active.
|
||||
(defun doom-defer-garbage-collection-h ()
|
||||
"Increase `gc-cons-threshold' to stave off garbage collection."
|
||||
(setq gc-cons-threshold most-positive-fixnum))
|
||||
|
||||
(defun doom-restore-garbage-collection-h ()
|
||||
"Restore `gc-cons-threshold' to a reasonable value so the GC can do its job."
|
||||
;; Defer it so that commands launched immediately after will enjoy the
|
||||
;; benefits.
|
||||
(run-at-time
|
||||
1 nil (lambda () (setq gc-cons-threshold doom-gc-cons-threshold))))
|
||||
|
||||
(add-hook 'minibuffer-setup-hook #'doom-defer-garbage-collection-h)
|
||||
(add-hook 'minibuffer-exit-hook #'doom-restore-garbage-collection-h)
|
||||
|
||||
;; Not restoring these to their defaults will cause stuttering/freezes.
|
||||
(add-hook 'emacs-startup-hook #'doom-restore-garbage-collection-h)
|
||||
|
||||
;; When Emacs loses focus seems like a great time to do some garbage collection
|
||||
;; all sneaky breeky like, so we can return to a fresh(er) Emacs.
|
||||
(add-hook 'focus-out-hook #'garbage-collect)
|
||||
;; Adopt a sneaky garbage collection strategy of waiting until idle time to
|
||||
;; collect and staving off the collector while the user is working.
|
||||
(unless doom-interactive-mode
|
||||
(add-transient-hook! 'pre-command-hook (gcmh-mode +1))
|
||||
(with-eval-after-load 'gcmh
|
||||
(setq gcmh-idle-delay 10
|
||||
gcmh-verbose doom-debug-mode)
|
||||
(add-hook 'focus-out-hook #'gcmh-idle-garbage-collect)))
|
||||
|
||||
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue