From 582b20918b3be1cdd611a642019dbcddc4c0fbe5 Mon Sep 17 00:00:00 2001 From: Marc Date: Wed, 21 Apr 2021 10:57:51 +0200 Subject: [PATCH] more performance stuff --- config.org | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/config.org b/config.org index baa78b7..3014700 100644 --- a/config.org +++ b/config.org @@ -179,6 +179,44 @@ Set gc-cons-threshold (default is 800kb) to maximum value available, to prevent (setq gc-cons-threshold most-positive-fixnum) #+END_SRC +Restore it to reasonable value after init. Also stop garbage collection during minibuffer interaction (helm etc.) + +#+begin_src emacs-lisp +(defconst 1mb 1048576) +(defconst 20mb 20971520) +(defconst 30mb 31457280) +(defconst 50mb 52428800) + +(defun me/defer-garbage-collection () + (setq gc-cons-threshold most-positive-fixnum)) + +(defun me/restore-garbage-collection () + (run-at-time 1 nil (lambda () (setq gc-cons-threshold 30mb)))) + +(add-hook 'emacs-startup-hook 'me/restore-garbage-collection 100) +(add-hook 'minibuffer-setup-hook 'me/defer-garbage-collection) +(add-hook 'minibuffer-exit-hook 'me/restore-garbage-collection) + +(setq read-process-output-max 1mb) ;; lsp-mode's performance suggest +#+end_src + +** File Handler +#+begin_src emacs-lisp :tangle early-init.el +(defvar default-file-name-handler-alist file-name-handler-alist) +(setq file-name-handler-alist nil) + +(add-hook 'emacs-startup-hook + (lambda () + (setq file-name-handler-alist default-file-name-handler-alist)) 100) +#+end_src + +** Others +#+begin_src emacs-lisp :tangle early-init.el +;; Resizing the emacs frame can be a terriblu expensive part of changing the font. +;; By inhibiting this, we easily hale startup times with fonts that are larger +;; than the system default. +(setq frame-inhibit-implied-resize t) +#+end_src * Default settings :PROPERTIES: :ID: 3512d679-d111-4ccd-8372-6fc2acbc0374 @@ -297,11 +335,11 @@ Some windows specific stuff #+BEGIN_SRC emacs-lisp (when *sys/windows* (remove-hook 'find-file-hook 'vc-refresh-state) - (progn - (setq gc-cons-threshold (* 511 1024 1024) - gc-cons-percentage 0.5 - garbage-collection-messages t) - (run-with-idle-timer 5 t #'garbage-collect)) +; (progn +; (setq gc-cons-threshold (* 511 1024 1024) +; gc-cons-percentage 0.5 +; garbage-collection-messages t) +; (run-with-idle-timer 5 t #'garbage-collect)) (when (boundp 'w32-pipe-read-delay) (setq w32-pipe-read-delay 0)) (when (boundp 'w32-get-true-file-attributes) @@ -1416,5 +1454,5 @@ Beancount-mode can start fava and open the URL right away. Set garbage collector to a smaller value to let it kick in faster. Maybe a problem on Windows? #+begin_src emacs-lisp -(setq gc-cons-threshold (* 2 1000 1000)) +;(setq gc-cons-threshold (* 2 1000 1000)) #+end_src