fix: disable non-essential startup optimizations in debug-mode
As to not interfere with debugging.
This commit is contained in:
parent
7aa87eb019
commit
6eab48641f
1 changed files with 71 additions and 70 deletions
141
lisp/doom.el
141
lisp/doom.el
|
@ -390,81 +390,82 @@ users).")
|
||||||
(doom-partial #'tty-run-terminal-initialization
|
(doom-partial #'tty-run-terminal-initialization
|
||||||
(selected-frame) nil t))))
|
(selected-frame) nil t))))
|
||||||
|
|
||||||
;; PERF,UX: Site files tend to use `load-file', which emits "Loading X..."
|
(unless init-file-debug
|
||||||
;; messages in the echo area. Writing to the echo-area triggers a
|
;; PERF,UX: Site files tend to use `load-file', which emits "Loading X..."
|
||||||
;; redisplay, which can be expensive during startup. This may also cause
|
;; messages in the echo area. Writing to the echo-area triggers a
|
||||||
;; an flash of white when creating the first frame.
|
;; redisplay, which can be expensive during startup. This may also cause
|
||||||
(define-advice load-file (:override (file) silence)
|
;; an flash of white when creating the first frame.
|
||||||
(load file nil 'nomessage))
|
(define-advice load-file (:override (file) silence)
|
||||||
;; COMPAT: But undo our `load-file' advice later, as to limit the scope of
|
(load file nil 'nomessage))
|
||||||
;; any edge cases it could induce.
|
;; COMPAT: But undo our `load-file' advice later, as to limit the scope of
|
||||||
(define-advice startup--load-user-init-file (:before (&rest _) undo-silence)
|
;; any edge cases it could induce.
|
||||||
(advice-remove #'load-file #'load-file@silence))
|
(define-advice startup--load-user-init-file (:before (&rest _) undo-silence)
|
||||||
|
(advice-remove #'load-file #'load-file@silence))
|
||||||
|
|
||||||
;; PERF: `load-suffixes' and `load-file-rep-suffixes' are consulted on each
|
;; PERF: `load-suffixes' and `load-file-rep-suffixes' are consulted on each
|
||||||
;; `require' and `load'. Doom won't load any dmodules this early, so omit
|
;; `require' and `load'. Doom won't load any dmodules this early, so omit
|
||||||
;; .so for a small startup boost. This is later restored in doom-start.
|
;; .so for a small startup boost. This is later restored in doom-start.
|
||||||
(put 'load-suffixes 'initial-value (default-toplevel-value 'load-suffixes))
|
(put 'load-suffixes 'initial-value (default-toplevel-value 'load-suffixes))
|
||||||
(put 'load-file-rep-suffixes 'initial-value (default-toplevel-value 'load-file-rep-suffixes))
|
(put 'load-file-rep-suffixes 'initial-value (default-toplevel-value 'load-file-rep-suffixes))
|
||||||
(set-default-toplevel-value 'load-suffixes '(".elc" ".el"))
|
(set-default-toplevel-value 'load-suffixes '(".elc" ".el"))
|
||||||
(set-default-toplevel-value 'load-file-rep-suffixes '(""))
|
(set-default-toplevel-value 'load-file-rep-suffixes '(""))
|
||||||
;; COMPAT: Undo any problematic startup optimizations; from this point, I make
|
;; COMPAT: Undo any problematic startup optimizations; from this point, I make
|
||||||
;; no assumptions about what might be loaded in userland.
|
;; no assumptions about what might be loaded in userland.
|
||||||
(add-hook! 'doom-before-init-hook
|
(add-hook! 'doom-before-init-hook
|
||||||
(defun doom--reset-load-suffixes-h ()
|
(defun doom--reset-load-suffixes-h ()
|
||||||
(setq load-suffixes (get 'load-suffixes 'initial-value)
|
(setq load-suffixes (get 'load-suffixes 'initial-value)
|
||||||
load-file-rep-suffixes (get 'load-file-rep-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
|
;; PERF: Doom uses `defcustom' to indicate variables that users are expected
|
||||||
;; to reconfigure. Trouble is it fires off initializers meant to
|
;; to reconfigure. Trouble is it fires off initializers meant to
|
||||||
;; accommodate any user attempts to configure them before they were
|
;; accommodate any user attempts to configure them before they were
|
||||||
;; defined. This is unnecessary before $DOOMDIR/init.el is loaded, so I
|
;; defined. This is unnecessary before $DOOMDIR/init.el is loaded, so I
|
||||||
;; disable them until it is.
|
;; disable them until it is.
|
||||||
(setq custom-dont-initialize t)
|
(setq custom-dont-initialize t)
|
||||||
(add-hook! 'doom-before-init-hook
|
(add-hook! 'doom-before-init-hook
|
||||||
(defun doom--reset-custom-dont-initialize-h ()
|
(defun doom--reset-custom-dont-initialize-h ()
|
||||||
(setq custom-dont-initialize nil)))
|
(setq custom-dont-initialize nil)))
|
||||||
|
|
||||||
;; PERF: The mode-line procs a couple dozen times during startup. This is
|
;; 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
|
;; normally quite fast, but disabling the default mode-line and reducing the
|
||||||
;; update delay timer seems to stave off ~30-50ms.
|
;; update delay timer seems to stave off ~30-50ms.
|
||||||
(put 'mode-line-format 'initial-value (default-toplevel-value 'mode-line-format))
|
(put 'mode-line-format 'initial-value (default-toplevel-value 'mode-line-format))
|
||||||
(setq-default mode-line-format nil)
|
(setq-default mode-line-format nil)
|
||||||
(dolist (buf (buffer-list))
|
(dolist (buf (buffer-list))
|
||||||
(with-current-buffer buf (setq mode-line-format nil)))
|
(with-current-buffer buf (setq mode-line-format nil)))
|
||||||
;; PERF,UX: Premature redisplays can substantially affect startup times and
|
;; PERF,UX: Premature redisplays can substantially affect startup times and
|
||||||
;; produce ugly flashes of unstyled Emacs.
|
;; produce ugly flashes of unstyled Emacs.
|
||||||
(setq-default inhibit-redisplay t
|
(setq-default inhibit-redisplay t
|
||||||
inhibit-message t)
|
inhibit-message t)
|
||||||
;; COMPAT: Then reset it with advice, because `startup--load-user-init-file'
|
;; COMPAT: Then reset it with advice, because `startup--load-user-init-file'
|
||||||
;; will never be interrupted by errors. And if these settings are left
|
;; will never be interrupted by errors. And if these settings are left
|
||||||
;; set, Emacs could appear frozen or garbled.
|
;; set, Emacs could appear frozen or garbled.
|
||||||
(defun doom--reset-inhibited-vars-h ()
|
(defun doom--reset-inhibited-vars-h ()
|
||||||
(setq-default inhibit-redisplay nil
|
(setq-default inhibit-redisplay nil
|
||||||
;; Inhibiting `message' only prevents redraws and
|
;; Inhibiting `message' only prevents redraws and
|
||||||
inhibit-message nil)
|
inhibit-message nil)
|
||||||
(redraw-frame))
|
(redraw-frame))
|
||||||
(add-hook 'after-init-hook #'doom--reset-inhibited-vars-h)
|
(add-hook 'after-init-hook #'doom--reset-inhibited-vars-h)
|
||||||
(define-advice startup--load-user-init-file (:after (&rest _) undo-inhibit-vars)
|
(define-advice startup--load-user-init-file (:after (&rest _) undo-inhibit-vars)
|
||||||
(when init-file-had-error
|
(when init-file-had-error
|
||||||
(doom--reset-inhibited-vars-h))
|
(doom--reset-inhibited-vars-h))
|
||||||
(unless (default-toplevel-value 'mode-line-format)
|
(unless (default-toplevel-value 'mode-line-format)
|
||||||
(setq-default mode-line-format (get 'mode-line-format 'initial-value))))
|
(setq-default mode-line-format (get 'mode-line-format 'initial-value))))
|
||||||
|
|
||||||
;; PERF: Doom disables the UI elements by default, so that there's less for
|
;; PERF: Doom disables the UI elements by default, so that there's less for
|
||||||
;; the frame to initialize. However, the toolbar is still populated
|
;; the frame to initialize. However, the toolbar is still populated
|
||||||
;; regardless, so I lazy load it until tool-bar-mode is actually used.
|
;; regardless, so I lazy load it until tool-bar-mode is actually used.
|
||||||
(advice-add #'tool-bar-setup :override #'ignore)
|
(advice-add #'tool-bar-setup :override #'ignore)
|
||||||
(define-advice startup--load-user-init-file (:before (&rest _) defer-tool-bar-setup)
|
(define-advice startup--load-user-init-file (:before (&rest _) defer-tool-bar-setup)
|
||||||
(advice-remove #'tool-bar-setup #'ignore)
|
(advice-remove #'tool-bar-setup #'ignore)
|
||||||
(add-transient-hook! 'tool-bar-mode (tool-bar-setup)))
|
(add-transient-hook! 'tool-bar-mode (tool-bar-setup)))
|
||||||
|
|
||||||
;; PERF: Unset a non-trivial list of command line options that aren't
|
;; PERF: Unset a non-trivial list of command line options that aren't
|
||||||
;; relevant to our current OS, but `command-line-1' still processes.
|
;; relevant to our current OS, but `command-line-1' still processes.
|
||||||
(unless IS-MAC
|
(unless IS-MAC
|
||||||
(setq command-line-ns-option-alist nil))
|
(setq command-line-ns-option-alist nil))
|
||||||
(unless (memq initial-window-system '(x pgtk))
|
(unless (memq initial-window-system '(x pgtk))
|
||||||
(setq command-line-x-option-alist nil))))
|
(setq command-line-x-option-alist nil)))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue