From ae8fde41e1a6b8246ce15a993ccb9e031532510c Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Thu, 18 Feb 2021 05:40:18 -0600 Subject: [PATCH] Adding early-init.el to set our gc threshold --- early-init.el | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 early-init.el diff --git a/early-init.el b/early-init.el new file mode 100644 index 00000000..cdeca727 --- /dev/null +++ b/early-init.el @@ -0,0 +1,43 @@ +;;; early-init.el -*- lexical-binding: t; -*- + +;; Emacs 27.1 introduced early-init.el, which is run before init.el, before +;; package and UI initialization happens, and before site files are loaded. + +;; A big contributor to startup times is garbage collection. We up the gc +;; threshold to temporarily prevent it from running, then reset it later by +;; enabling `gcmh-mode'. Not resetting it will cause stuttering/freezes. +(setq gc-cons-threshold 50000000) + +;; ;; In noninteractive sessions, prioritize non-byte-compiled source files to +;; ;; prevent the use of stale byte-code. Otherwise, it saves us a little IO time +;; ;; to skip the mtime checks on every *.elc file. +;; (setq load-prefer-newer noninteractive) + +;; ;; In Emacs 27+, package initialization occurs before `user-init-file' is +;; ;; loaded, but after `early-init-file'. Doom handles package initialization, so +;; ;; we must prevent Emacs from doing it early! +;; (setq package-enable-at-startup nil) +;; (fset #'package--ensure-init-file #'ignore) ; DEPRECATED Removed in 28 + +;; ;; `file-name-handler-alist' is consulted on every `require', `load' and various +;; ;; path/io functions. You get a minor speed up by nooping this. However, this +;; ;; may cause problems on builds of Emacs where its site lisp files aren't +;; ;; byte-compiled and we're forced to load the *.el.gz files (e.g. on Alpine) +;; (unless (daemonp) +;; (defvar doom--initial-file-name-handler-alist file-name-handler-alist) +;; (setq file-name-handler-alist nil) +;; ;; Restore `file-name-handler-alist' later, because it is needed for handling +;; ;; encrypted or compressed files, among other things. +;; (defun doom-reset-file-handler-alist-h () +;; ;; Re-add rather than `setq', because changes to `file-name-handler-alist' +;; ;; since startup ought to be preserved. +;; (dolist (handler file-name-handler-alist) +;; (add-to-list 'doom--initial-file-name-handler-alist handler)) +;; (setq file-name-handler-alist doom--initial-file-name-handler-alist)) +;; (add-hook 'emacs-startup-hook #'doom-reset-file-handler-alist-h)) + +;; ;; Ensure Doom is running out of this file's directory +;; (setq user-emacs-directory (file-name-directory load-file-name)) + +;; ;; Load the heart of Doom Emacs +;; (load (concat user-emacs-directory "core/core") nil 'nomessage)