summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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