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.
This commit is contained in:
Henrik Lissner 2022-09-24 21:31:20 +02:00
parent 1c32e317cc
commit 8c442d84b9
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -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