From 8c442d84b9c055200e61c4333e117c1ce914027d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 24 Sep 2022 21:31:20 +0200 Subject: [PATCH] perf: custom-dont-initialize = t defcustom does some initialization work to accommodate the possibility that the user has set the variable before it was defined. This work is unneeded so early at startup, so I disable it (temporarily). In the future, Doom will use defcustom more, as it's a helpful indication to readers what variables I intended for configuration (and helps with discovery of options through `M-x doom/help-custom-variable` or `M-x customize`). As that transition occurs, the benefit of this optimization will begin to show, but for now its effect on startup time is negligible. * lisp/doom.el (warning-suppress-types): set this immediately. Since its default value is nil and this happens so early at startup, we don't have to be considerate of defaults. Plus, this custom-dont-initialize optimization can cause breakage if a warning is thrown *before* before this setting is changed. --- lisp/doom.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/doom.el b/lisp/doom.el index 582583f55..7acc69472 100644 --- a/lisp/doom.el +++ b/lisp/doom.el @@ -406,6 +406,16 @@ users).") (setq load-suffixes (get 'load-suffixes 'initial-value) load-file-rep-suffixes (get 'load-file-rep-suffixes 'initial-value)))) + ;; PERF: Doom uses `defcustom' to indicate variables that users are expected + ;; to reconfigure. Trouble is it fires off initializers meant to + ;; accommodate any user attempts to configure them before they were + ;; defined. This is unnecessary before $DOOMDIR/init.el is loaded, so I + ;; disable them until it is. + (setq custom-dont-initialize t) + (add-hook! 'doom-before-init-hook + (defun doom--reset-custom-dont-initialize-h () + (setq custom-dont-initialize nil))) + ;; PERF: The mode-line procs a couple dozen times during startup. This is ;; normally quite fast, but disabling the default mode-line and reducing the ;; update delay timer seems to stave off ~30-50ms. @@ -584,8 +594,7 @@ Otherwise, `en/disable-command' (in novice.el.gz) is hardcoded to write them to ;; defvaralias, which are done because ensuring aliases are created before ;; packages are loaded is an unneeded and unhelpful maintenance burden. Emacs ;; still aliases them fine regardless. -(with-eval-after-load 'warnings - (add-to-list 'warning-suppress-types '(defvaralias))) +(setq warning-suppress-types '(defvaralias)) ;; Reduce debug output unless we've asked for it. (setq debug-on-error init-file-debug