Add minimal-emacs-optimize-startup-gc

This commit is contained in:
James Cherti
2025-02-19 10:28:05 -05:00
parent f9c6386311
commit 2d296235ca
2 changed files with 12 additions and 8 deletions

View File

@@ -38,6 +38,11 @@ turned on.")
(defvar minimal-emacs-gc-cons-threshold (* 16 1024 1024) (defvar minimal-emacs-gc-cons-threshold (* 16 1024 1024)
"The value of `gc-cons-threshold' after Emacs startup.") "The value of `gc-cons-threshold' after Emacs startup.")
(defvar minimal-emacs-optimize-startup-gc t
"If non-nil, increase `gc-cons-threshold' during startup to reduce pauses.
After Emacs finishes loading, `gc-cons-threshold' is restored to the value
stored in `minimal-emacs--restore-gc-cons-threshold'.")
(defvar minimal-emacs-package-initialize-and-refresh t (defvar minimal-emacs-package-initialize-and-refresh t
"Whether to automatically initialize and refresh packages. "Whether to automatically initialize and refresh packages.
When set to non-nil, Emacs will automatically call `package-initialize' and When set to non-nil, Emacs will automatically call `package-initialize' and
@@ -87,12 +92,13 @@ minimalistic appearance during startup.")
;; Garbage collection significantly affects startup times. This setting delays ;; Garbage collection significantly affects startup times. This setting delays
;; garbage collection during startup but will be reset later. ;; garbage collection during startup but will be reset later.
(setq gc-cons-threshold most-positive-fixnum) (when minimal-emacs-optimize-startup-gc
(setq gc-cons-threshold most-positive-fixnum)
(defun minimal-emacs--restore-gc-cons-threshold () (defun minimal-emacs--restore-gc-cons-threshold ()
"Restore `minimal-emacs-gc-cons-threshold'." "Restore `minimal-emacs-gc-cons-threshold'."
(setq gc-cons-threshold minimal-emacs-gc-cons-threshold)) (setq gc-cons-threshold minimal-emacs-gc-cons-threshold))
(add-hook 'emacs-startup-hook #'minimal-emacs--restore-gc-cons-threshold 105) (add-hook 'emacs-startup-hook #'minimal-emacs--restore-gc-cons-threshold 105))
;;; Misc ;;; Misc

View File

@@ -94,9 +94,7 @@
(setq whitespace-line-column nil) ; whitespace-mode (setq whitespace-line-column nil) ; whitespace-mode
;; I reduced the default value of 9 to simplify the font-lock keyword, ;; I reduced the default value of 9 to simplify the font-lock keyword,
;; aiming to improve performance. This package helps differentiate ;; aiming to improve performance.
;; nested delimiter pairs, particularly in languages with heavy use of
;; parentheses.
(setq rainbow-delimiters-max-face-count 5) (setq rainbow-delimiters-max-face-count 5)
;; Can be activated with `display-line-numbers-mode' ;; Can be activated with `display-line-numbers-mode'