From eea3302ce3cafc7a03b721b52c9b2c240f5e8be6 Mon Sep 17 00:00:00 2001 From: Jack Foltz Date: Sun, 10 Feb 2019 14:34:50 -0500 Subject: [PATCH] Add GC optimizations --- lain/.emacs.d/config.org | 13 ++++++++++++- lain/.emacs.d/init.el | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lain/.emacs.d/config.org b/lain/.emacs.d/config.org index 80f9f34..73df382 100644 --- a/lain/.emacs.d/config.org +++ b/lain/.emacs.d/config.org @@ -354,6 +354,14 @@ Print more stuff when running =C-x C-e= or =(eval-last-sexp)= #+BEGIN_SRC emacs-lisp (setq eval-expression-print-level 100) #+END_SRC +*** GC in Minibuffer +Don't garbage collect while the minibuffer is open, as heavy +things like completion and searches are happening and will +slow down with many garbage collections. +#+BEGIN_SRC emacs-lisp + (add-hook 'minibuffer-setup-hook #'jf-inhibit-gc) + (add-hook 'minibuffer-exit-hook #'jf-resume-gc) +#+END_SRC ** UI *** Font Engage a nice coding font. @@ -414,7 +422,10 @@ Show a cool custom dashboard buffer on startup. :custom (dashboard-startup-banner 'logo) - (dashboard-banner-logo-title "Welcome to Electronic Macs") + (dashboard-banner-logo-title + (format "Welcome to Electronic Macs. Ready in %.2f seconds with %d GCs." + (float-time (time-subtract after-init-time before-init-time)) + gcs-done)) (dashboard-items '((recents . 5) (agenda) diff --git a/lain/.emacs.d/init.el b/lain/.emacs.d/init.el index 38de94a..6ee2991 100755 --- a/lain/.emacs.d/init.el +++ b/lain/.emacs.d/init.el @@ -4,6 +4,19 @@ (defvar jf-config-file (expand-file-name "config.org" user-emacs-directory)) (defvar jf-init-file (expand-file-name "init.el" user-emacs-directory)) (defvar jf-load-path (expand-file-name "lisp/" user-emacs-directory)) +(defvar jf-gc-threshold 20000000) ; 20MB up from 800KB -(message "Initializing Electronic Macs...") +(defun jf-inhibit-gc () + (setq gc-cons-threshold most-positive-fixnum)) +(defun jf-resume-gc () + (setq gc-cons-threshold jf-gc-threshold)) + + +(message "-> Initializing Electronic Macs...") + +;; Don't garbage collect during init +(jf-inhibit-gc) (org-babel-load-file jf-config-file) +(jf-resume-gc) + +(message "-> Initialized in %s" (emacs-init-time))