Move startup optimization to early-init
Also load early-init from init if early-init-file isn't bound. This improves startup a modest 3-5% for Emacs 27 users.
This commit is contained in:
parent
126b7b6383
commit
b656e68bc3
3 changed files with 42 additions and 51 deletions
39
init.el
39
init.el
|
@ -27,42 +27,7 @@
|
|||
;;
|
||||
;;; License: MIT
|
||||
|
||||
;; Ensure Doom is always running out of this file's directory
|
||||
(setq user-emacs-directory (file-name-directory load-file-name)
|
||||
load-prefer-newer noninteractive)
|
||||
|
||||
|
||||
;;
|
||||
;; Optimize startup
|
||||
;;
|
||||
|
||||
(unless noninteractive
|
||||
(defvar doom--file-name-handler-alist
|
||||
file-name-handler-alist)
|
||||
(unless after-init-time
|
||||
;; A big contributor to long startup times is the garbage collector, so we
|
||||
;; up its memory threshold, temporarily and reset it later in
|
||||
;; `doom|finalize'.
|
||||
(setq gc-cons-threshold 402653184
|
||||
gc-cons-percentage 1.0
|
||||
;; consulted on every `require', `load' and various file reading
|
||||
;; functions. You get a minor speed up by nooping this.
|
||||
file-name-handler-alist nil))
|
||||
|
||||
(defun doom|finalize ()
|
||||
"Resets garbage collection settings to reasonable defaults (if you don't do
|
||||
this, you'll get stuttering and random freezes) and resets
|
||||
`file-name-handler-alist'."
|
||||
(setq file-name-handler-alist doom--file-name-handler-alist
|
||||
gc-cons-threshold 16777216
|
||||
gc-cons-percentage 0.2))
|
||||
|
||||
(add-hook 'emacs-startup-hook #'doom|finalize)
|
||||
(add-hook 'doom-reload-hook #'doom|finalize))
|
||||
|
||||
|
||||
;;
|
||||
;; Bootstrap Doom
|
||||
;;
|
||||
(unless (boundp 'early-init-file)
|
||||
(load (concat (file-name-directory load-file-name) "early-init")))
|
||||
|
||||
(require 'core (concat user-emacs-directory "core/core"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue