Run emacs garbage collection when idle.

This is to hopefully avoid running garbage collection while I am actively interacting with emacs, which should theoretically result in a smoother experience.
This commit is contained in:
Tom Alexander 2024-01-26 21:21:09 -05:00
parent 574a2d0ce7
commit ed7d4ab4e6
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 15 additions and 3 deletions

View File

@ -1,6 +1,6 @@
(setq gc-cons-threshold 100000000) ;; Increase garbage collection threshold for performance (default 800000) (setq gc-cons-threshold (* 128 1024 1024)) ;; Increase garbage collection threshold for performance (default 800000)
;; Increase amount of data read from processes, default 4k ;; Increase amount of data read from processes, default 4k
(when (>= emacs-major-version 27) (when (version<= "27.0" emacs-version)
(setq read-process-output-max (* 1024 1024)) ;; 1mb (setq read-process-output-max (* 1024 1024)) ;; 1mb
) )

View File

@ -36,6 +36,8 @@
;; Don't pop up a small window at the bottom of emacs at launch. ;; Don't pop up a small window at the bottom of emacs at launch.
inhibit-startup-screen t inhibit-startup-screen t
inhibit-startup-message t inhibit-startup-message t
;; Don't show the list of buffers when opening many files.
inhibit-startup-buffer-menu t
;; Give the scratch buffer a clean slate. ;; Give the scratch buffer a clean slate.
initial-major-mode 'fundamental-mode initial-major-mode 'fundamental-mode
initial-scratch-message nil initial-scratch-message nil
@ -81,4 +83,12 @@
(setopt auto-revert-check-vc-info t) (setopt auto-revert-check-vc-info t)
(global-auto-revert-mode) (global-auto-revert-mode)
;;;;; Performance
;; Run garbage collect when emacs is idle
(run-with-idle-timer 5 t (lambda () (garbage-collect)))
(add-function :after after-focus-change-function
(lambda ()
(unless (frame-focus-state)
(garbage-collect))))
(provide 'base) (provide 'base)

View File

@ -38,6 +38,7 @@
:hook (eglot-managed-mode . company-mode) :hook (eglot-managed-mode . company-mode)
:config :config
(setq company-backends '((company-capf))) (setq company-backends '((company-capf)))
(setq company-idle-delay 0) ;; Default 0.2
) )
;; (use-package company-box ;; (use-package company-box

View File

@ -18,5 +18,6 @@
"[python]": { "[python]": {
"editor.defaultFormatter": "ms-python.black-formatter", "editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true "editor.formatOnSave": true
} },
"black-formatter.importStrategy": "fromEnvironment"
} }