From 7169b69707b08aa7ab0e9e758482718e050c4b2e Mon Sep 17 00:00:00 2001 From: Jakob L. Kreuze Date: Tue, 2 Jun 2020 15:34:38 -0400 Subject: Calm down the garbage collector while Emacs is starting. --- init.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/init.el b/init.el index 6c9d617..d25cb9d 100644 --- a/init.el +++ b/init.el @@ -58,6 +58,14 @@ +;; The traditional dance of calming down the garbage collector during init, +;; as that improves startup times. Taken from Doom Emacs [1]. +;; +;; [1]: https://github.com/hlissner/doom-emacs/blob/develop/docs/faq.org#how-does-doom-start-up-so-quickly + +(setq gc-cons-threshold most-positive-fixnum) +(setq gc-cons-percentage 0.6) + ;; straight.el is my package manager of choice. Here's the necessary bootstrap ;; code for that. @@ -87,6 +95,22 @@ (use-package bind-key) (require 'bind-key) +;; But we do want to reset the garbage collector settings eventually. When we +;; do, we'll use the GCMH [1] package to schedule the garbage collector to run +;; during idle time, rather than the haphazard "whenever some threshold is +;; reached". +;; +;; [1]: https://gitlab.com/koral/gcmh/ + +(use-package gcmh :defer t) + +(add-hook 'emacs-startup-hook + (lambda () + (setq gc-cons-threshold 16777216) ; 16mb + (setq gc-cons-percentage 0.1) + (require 'gcmh) + (gcmh-mode 1))) + ;; A handful of the Elisp snippets in this file depend on third-party libraries ;; which aren't loaded by default. -- cgit v1.3