From e9e65f9d9fdbf86b77b5f6ec95303cc3d73d61e7 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 15 Feb 2020 18:10:08 +0000 Subject: [PATCH] perf(startup): Improve startup speed by borrowing from doom-emacs Shameless borrow various methods of improving Emacs startup time from doom-emacs: https://github.com/hlissner/doom-emacs/blob/b0978a4526cfd78bb18e5279909c19bee97e9878/docs/faq.org#how-does-doom-start-up-so-quickly --- core/siren-core-init.el | 1 + core/siren-core-performance.el | 20 ++++++++++++++++++++ early-init.el | 14 ++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 core/siren-core-performance.el diff --git a/core/siren-core-init.el b/core/siren-core-init.el index 4d98918..cf1b2af 100644 --- a/core/siren-core-init.el +++ b/core/siren-core-init.el @@ -36,6 +36,7 @@ ;; Continue core stuff (require 'siren-core-packages) +(require 'siren-core-performance) (require 'siren-core-env) (require 'siren-core-ui) (require 'siren-core-editor) diff --git a/core/siren-core-performance.el b/core/siren-core-performance.el new file mode 100644 index 0000000..f0de02e --- /dev/null +++ b/core/siren-core-performance.el @@ -0,0 +1,20 @@ +;;; siren-core-performance.el --- jimeh's Emacs Siren: Performance tweaks + +;;; Commentary: + +;; Performance tweaks. + +;;; Code: + +;; Setup and use gcmh-mode for improved garbage collection. +(use-package gcmh + :hook + (emacs-startup . (lambda() (gcmh-mode +1))) + (focus-out-hook . gcmh-idle-garbage-collect) + + :custom + (gcmh-idle-delay 10) + (gcmh-high-cons-threshold 16777216)) + +(provide 'siren-core-performance) +;;; siren-core-performance.el ends here diff --git a/early-init.el b/early-init.el index 9ebdb46..e16720d 100644 --- a/early-init.el +++ b/early-init.el @@ -6,8 +6,22 @@ ;;; Code: +;; Defer garbage collection further back in the startup process +(setq gc-cons-threshold most-positive-fixnum) + ;; Disable Emacs 27's automatic package.el initialization before the init.el ;; file is loaded. I use straight.el instead of package.el. (setq package-enable-at-startup nil) +;; Prevent the glimpse of un-styled Emacs by disabling these UI elements early. +(setq tool-bar-mode nil + menu-bar-mode nil) +(when (fboundp 'set-scroll-bar-mode) + (set-scroll-bar-mode nil)) + +;; Resizing the Emacs frame can be a terribly expensive part of changing the +;; font. By inhibiting this, we easily halve startup times with fonts that are +;; larger than the system default. +(setq frame-inhibit-implied-resize t) + ;;; early-init.el ends here