+ Add doom-gc-cons-upper-limit variable + Don't use most-positive-fixnum, in case Emacs somehow wants to allocate that much! + Don't use startup optimizations in noninteractive sessions + Restore gc-cons-threshold on idle timer, instead of hook (to defer the possible GC pause and so deferred packages can take advantage of these optimizations).
73 lines
3.7 KiB
EmacsLisp
73 lines
3.7 KiB
EmacsLisp
;;; init.el -*- lexical-binding: t; -*-
|
|
;;
|
|
;; Author: Henrik Lissner <henrik@lissner.net>
|
|
;; URL: https://github.com/hlissner/doom-emacs
|
|
;;
|
|
;; ================= =============== =============== ======== ========
|
|
;; \\ . . . . . . .\\ //. . . . . . .\\ //. . . . . . .\\ \\. . .\\// . . //
|
|
;; ||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\/ . . .||
|
|
;; || . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||
|
|
;; ||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||
|
|
;; || . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\ . . . . ||
|
|
;; ||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\_ . .|. .||
|
|
;; || . _|| || || || || ||_ . || || . _|| || || || |\ `-_/| . ||
|
|
;; ||_-' || .|/ || || \|. || `-_|| ||_-' || .|/ || || | \ / |-_.||
|
|
;; || ||_-' || || `-_|| || || ||_-' || || | \ / | `||
|
|
;; || `' || || `' || || `' || || | \ / | ||
|
|
;; || .===' `===. .==='.`===. .===' /==. | \/ | ||
|
|
;; || .==' \_|-_ `===. .===' _|_ `===. .===' _-|/ `== \/ | ||
|
|
;; || .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \/ | ||
|
|
;; || .==' _-' '-__\._-' '-_./__-' `' |. /| | ||
|
|
;; ||.==' _-' `' | /==.||
|
|
;; ==' _-' \/ `==
|
|
;; \ _-' `-_ /
|
|
;; `'' ``'
|
|
;;
|
|
;; These demons are not part of GNU Emacs.
|
|
;;
|
|
;;; License: MIT
|
|
|
|
(defvar doom-gc-cons-threshold 16777216 ; 16mb
|
|
"The default value to use for `gc-cons-threshold'. If you experience freezing,
|
|
decrease this. If you experience stuttering, increase this.")
|
|
|
|
(defvar doom-gc-cons-upper-limit 268435456 ; 256mb
|
|
"The temporary value for `gc-cons-threshold' to defer it.")
|
|
|
|
|
|
(defvar doom--file-name-handler-alist file-name-handler-alist)
|
|
|
|
(defun doom|restore-startup-optimizations ()
|
|
"Resets garbage collection settings to reasonable defaults (a large
|
|
`gc-cons-threshold' can cause random freezes otherwise) and resets
|
|
`file-name-handler-alist'."
|
|
(setq file-name-handler-alist doom--file-name-handler-alist
|
|
gc-cons-threshold doom-gc-cons-threshold))
|
|
|
|
|
|
(if (or after-init-time noninteractive)
|
|
(setq gc-cons-threshold doom-gc-cons-threshold)
|
|
;; A big contributor to long startup times is the garbage collector, so we up
|
|
;; its memory threshold, temporarily and reset it later in
|
|
;; `doom|disable-startup-optimizations'.
|
|
(setq gc-cons-threshold doom-gc-cons-upper-limit) ; 256mb
|
|
;; This is consulted on every `require', `load' and various file reading
|
|
;; functions. You get a minor speed up by nooping this.
|
|
(setq file-name-handler-alist nil)
|
|
;; Restore these to their defaults later. Do it on an idle timer to defer the
|
|
;; possible GC pause, and to give deferred packages the ability to take
|
|
;; advantage of these optimizations.
|
|
(run-with-idle-timer 5 nil #'doom|restore-startup-optimizations)
|
|
(add-hook 'doom-reload-hook #'doom|restore-startup-optimizations))
|
|
|
|
|
|
;; Ensure Doom is always running out of this file's directory
|
|
(setq user-emacs-directory (file-name-directory load-file-name))
|
|
;; In noninteractive sessions, we hope that non-byte-compiled files will take
|
|
;; precedence over byte-compiled ones, however, if you're getting odd recursive
|
|
;; load errors, it may help to set this to nil.
|
|
(setq load-prefer-newer noninteractive)
|
|
|
|
|
|
;; Let 'er rip!
|
|
(require 'core (concat user-emacs-directory "core/core"))
|