summaryrefslogtreecommitdiff
path: root/init.el
diff options
context:
space:
mode:
authorJakob L. Kreuze2020-06-02 15:34:38 -0400
committerJakob L. Kreuze2020-06-02 15:34:38 -0400
commit7169b69707b08aa7ab0e9e758482718e050c4b2e (patch)
tree9f19b85f4a537175778edc11529367f6b105f272 /init.el
parentb118b0b7db903a42366ae630bbbf11d1fc2158d3 (diff)
Calm down the garbage collector while Emacs is starting.
Diffstat (limited to 'init.el')
-rw-r--r--init.el24
1 files changed, 24 insertions, 0 deletions
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.

© 2015 - 2026 Jakob L. Kreuze