From 937f118e6a7755cbfaa692a3329ae96915fa0d63 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 3 Sep 2018 23:52:14 +0200 Subject: [PATCH] Reset gc-cons-threshold on idle timer And remove reset from doom-reload-hook, as it is no longer necessary anymore. ~/.emacs.d/init.el is no longer re-evaluated at any point. --- init.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/init.el b/init.el index 3529750bc..6db64b2ae 100644 --- a/init.el +++ b/init.el @@ -41,8 +41,11 @@ decrease this. If you experience stuttering, increase this.") "Resets garbage collection settings to reasonable defaults (a large `gc-cons-threshold' can cause random freezes otherwise) and resets `file-name-handler-alist'." - (setq file-name-handler-alist doom--file-name-handler-alist - gc-cons-threshold doom-gc-cons-threshold)) + (setq-default file-name-handler-alist doom--file-name-handler-alist) + ;; Do it on an idle timer to defer the possible GC pause, and to give deferred + ;; packages the opportunity to take advantage of these optimizations. + (run-with-idle-timer + 3 nil (lambda () (setq-default gc-cons-threshold doom-gc-cons-threshold)))) (if (or after-init-time noninteractive) @@ -50,15 +53,12 @@ decrease this. If you experience stuttering, increase this.") ;; A big contributor to long startup times is the garbage collector, so we up ;; its memory threshold, temporarily and reset it later in ;; `doom|disable-startup-optimizations'. - (setq gc-cons-threshold doom-gc-cons-upper-limit) ; 256mb + (setq gc-cons-threshold doom-gc-cons-upper-limit) ;; This is consulted on every `require', `load' and various file reading ;; functions. You get a minor speed up by nooping this. (setq file-name-handler-alist nil) - ;; Restore these to their defaults later. Do it on an idle timer to defer the - ;; possible GC pause, and to give deferred packages the ability to take - ;; advantage of these optimizations. - (run-with-idle-timer 5 nil #'doom|restore-startup-optimizations) - (add-hook 'doom-reload-hook #'doom|restore-startup-optimizations)) + ;; Not restoring these to their defaults will cause stuttering/freezes. + (add-hook 'emacs-startup-hook #'doom|restore-startup-optimizations)) ;; Ensure Doom is always running out of this file's directory