Merge wayland and performance tweaks

This commit is contained in:
Chris Cochrun 2021-04-20 09:51:54 -05:00
commit a25ed0c286
2 changed files with 153 additions and 22 deletions

View file

@ -29,7 +29,7 @@
- [[#elfeed][Elfeed]] - [[#elfeed][Elfeed]]
- [[#bongo][Bongo]] - [[#bongo][Bongo]]
- [[#transmission][Transmission]] - [[#transmission][Transmission]]
- [[#garbage-collection][Garbage Collection]] - [[#performance][Performance]]
- [[#early-init][Early Init]] - [[#early-init][Early Init]]
* Init * Init
@ -111,6 +111,23 @@ Then let's make sure line-numbers are relative and on. And let's turn on visual-
(global-visual-line-mode +1) (global-visual-line-mode +1)
#+end_src #+end_src
Here are some ui changes I pulled from Doom Emacs
#+begin_src emacs-lisp
;; always avoid GUI
(setq use-dialog-box nil)
;; Don't display floating tooltips; display their contents in the echo-area,
;; because native tooltips are ugly.
(when (bound-and-true-p tooltip-mode)
(tooltip-mode -1))
;; ...especially on linux
(setq x-gtk-use-system-tooltips nil)
;; Favor vertical splits over horizontal ones. Screens are usually wide.
(setq split-width-threshold 160
split-height-threshold nil)
#+end_src
Let's make doc-view better Let's make doc-view better
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq doc-view-resolution 192) (setq doc-view-resolution 192)
@ -133,6 +150,7 @@ Finally this is not part of the UI but let's do this early and start the server
** Let's bootstrap straight.el ** Let's bootstrap straight.el
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq straight-fix-org t) (setq straight-fix-org t)
(setq straight-check-for-modifications '(check-on-save find-when-checking))
(defvar bootstrap-version) (defvar bootstrap-version)
(let ((bootstrap-file (let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
@ -346,7 +364,7 @@ This evil-collection package includes a lot of other evil based things.
** Undo-Tree ** Undo-Tree
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package undo-tree (use-package undo-tree
:defer 1 :after evil
:config :config
(global-undo-tree-mode +1) (global-undo-tree-mode +1)
:general :general
@ -578,7 +596,10 @@ Ace link provides an avy like search for links. Upon using the keybindings prese
** Help ** Help
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package helpful (use-package helpful
:commands (helpful-callable helpful-variable helpful-command helpful-key)) :commands (helpful-callable helpful-variable helpful-command helpful-key)
:general
(general-def 'normal 'helpful-mode-map
"q" 'chris/kill-buffer-frame))
#+end_src #+end_src
** Format ** Format
@ -1494,7 +1515,7 @@ Let's add our own eshell prompt. and set the password cache to a significantly h
:keymaps 'override :keymaps 'override
"oe" 'eshell) "oe" 'eshell)
(general-def '(normal insert) eshell-mode-map (general-def '(normal insert) eshell-mode-map
"C-d" 'kill-buffer-and-window)) "C-d" 'chris/kill-buffer-frame))
#+end_src #+end_src
** Sly ** Sly
@ -1528,13 +1549,22 @@ Let's use pdf-tools for a lot better interaction with pdfs.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq display-buffer-alist (setq display-buffer-alist
'(("\\*e?shell\\*" '(("\\*e?shell\\*"
(display-buffer--maybe-pop-up-frame-or-window) (display-buffer-pop-up-frame))
(window-width . 0.4) ("*helpful*"
(side . bottom)) (display-buffer-pop-up-frame))
("*elfeed-entry*"
(display-buffer-pop-up-frame))
("*Bongo-Elfeed Queue*" ("*Bongo-Elfeed Queue*"
(display-buffer-in-side-window) (display-buffer-pop-up-frame))))
(window-height . 0.25) #+end_src
(side . bottom))))
Since I like to make my window manager handle a lot of the window management, I will create a helper function for closing windows.
#+begin_src emacs-lisp
(defun chris/kill-buffer-frame ()
"Kills the active buffer and frame"
(interactive)
(kill-this-buffer)
(delete-frame))
#+end_src #+end_src
** Elfeed ** Elfeed
@ -1685,14 +1715,56 @@ I use transmission on a server to manage my torrents
"ot" 'transmission)) "ot" 'transmission))
#+end_src #+end_src
** Garbage Collection ** Performance
Here we have a bunch of performance tweaks
#+begin_src emacs-lisp
;; Reduce rendering/line scan work for Emacs by not rendering cursors or regions
;; in non-focused windows.
(setq-default cursor-in-non-selected-windows nil)
(setq highlight-nonselected-windows nil)
;; More performant rapid scrolling over unfontified regions. May cause brief
;; spells of inaccurate syntax highlighting right after scrolling, which should
;; quickly self-correct.
(setq fast-but-imprecise-scrolling t)
;; Don't ping things that look like domain names.
(setq ffap-machine-p-known 'reject)
;; Emacs "updates" its ui more often than it needs to, so we slow it down
;; slightly from 0.5s:
(setq idle-update-delay 1.0)
;; Font compacting can be terribly expensive, especially for rendering icon
;; fonts on Windows. Whether disabling it has a notable affect on Linux and Mac
;; hasn't been determined, but we inhibit it there anyway. This increases memory
;; usage, however!
;; (setq inhibit-compacting-font-caches t)
;; Introduced in Emacs HEAD (b2f8c9f), this inhibits fontification while
;; receiving input, which should help with performance while scrolling.
(setq redisplay-skip-fontification-on-input t)
#+end_src
*** Garbage Collection
We set the =gc-cons-threshold= variable to really high, now lets set it back low to make sure emacs performs properly. We set the =gc-cons-threshold= variable to really high, now lets set it back low to make sure emacs performs properly.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq gc-cons-threshold 2000000) (setq gc-cons-threshold (* 32 1024 1024))
(setq garbage-collection-messages nil) (setq garbage-collection-messages nil)
#+end_src #+end_src
Let's also use an automatic garbage collector while idle to make better input.
#+begin_src emacs-lisp
(use-package gcmh
:ensure t
:init
(gcmh-mode)
:config
(setq gcmh-idle-delay 5
gcmh-high-cons-threshold (* 128 1024 1024) ; 128mb
gcmh-verbose t))
#+end_src
* Early Init * Early Init
:PROPERTIES: :PROPERTIES:
:header-args: emacs-lisp :tangle early-init.el :header-args: emacs-lisp :tangle early-init.el

79
init.el
View file

@ -52,6 +52,19 @@
(add-hook 'prog-mode-hook (display-line-numbers-mode +1)) (add-hook 'prog-mode-hook (display-line-numbers-mode +1))
(global-visual-line-mode +1) (global-visual-line-mode +1)
;; always avoid GUI
(setq use-dialog-box nil)
;; Don't display floating tooltips; display their contents in the echo-area,
;; because native tooltips are ugly.
(when (bound-and-true-p tooltip-mode)
(tooltip-mode -1))
;; ...especially on linux
(setq x-gtk-use-system-tooltips nil)
;; Favor vertical splits over horizontal ones. Screens are usually wide.
(setq split-width-threshold 160
split-height-threshold nil)
(setq doc-view-resolution 192) (setq doc-view-resolution 192)
(global-set-key (kbd "<escape>") 'keyboard-escape-quit) (global-set-key (kbd "<escape>") 'keyboard-escape-quit)
@ -61,6 +74,7 @@
(server-start) (server-start)
(setq straight-fix-org t) (setq straight-fix-org t)
(setq straight-check-for-modifications '(check-on-save find-when-checking))
(defvar bootstrap-version) (defvar bootstrap-version)
(let ((bootstrap-file (let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
@ -231,7 +245,7 @@
(global-evil-surround-mode +1)) (global-evil-surround-mode +1))
(use-package undo-tree (use-package undo-tree
:defer 1 :after evil
:config :config
(global-undo-tree-mode +1) (global-undo-tree-mode +1)
:general :general
@ -346,7 +360,10 @@ vertically."
:after avy) :after avy)
(use-package helpful (use-package helpful
:commands (helpful-callable helpful-variable helpful-command helpful-key)) :commands (helpful-callable helpful-variable helpful-command helpful-key)
:general
(general-def 'normal 'helpful-mode-map
"q" 'chris/kill-buffer-frame))
(use-package format-all (use-package format-all
:config :config
@ -1134,7 +1151,7 @@ If on a:
:keymaps 'override :keymaps 'override
"oe" 'eshell) "oe" 'eshell)
(general-def '(normal insert) eshell-mode-map (general-def '(normal insert) eshell-mode-map
"C-d" 'kill-buffer-and-window)) "C-d" 'chris/kill-buffer-frame))
(use-package sly (use-package sly
:mode ("\\.lisp\\'" . sly-mode)) :mode ("\\.lisp\\'" . sly-mode))
@ -1154,13 +1171,19 @@ If on a:
(setq display-buffer-alist (setq display-buffer-alist
'(("\\*e?shell\\*" '(("\\*e?shell\\*"
(display-buffer--maybe-pop-up-frame-or-window) (display-buffer-pop-up-frame))
(window-width . 0.4) ("*helpful*"
(side . bottom)) (display-buffer-pop-up-frame))
("*elfeed-entry*"
(display-buffer-pop-up-frame))
("*Bongo-Elfeed Queue*" ("*Bongo-Elfeed Queue*"
(display-buffer-in-side-window) (display-buffer-pop-up-frame))))
(window-height . 0.25)
(side . bottom)))) (defun chris/kill-buffer-frame ()
"Kills the active buffer and frame"
(interactive)
(kill-this-buffer)
(delete-frame))
(use-package elfeed (use-package elfeed
:commands (elfeed) :commands (elfeed)
@ -1298,5 +1321,41 @@ interfere with the default `bongo-playlist-buffer'."
:keymaps 'override :keymaps 'override
"ot" 'transmission)) "ot" 'transmission))
(setq gc-cons-threshold 2000000) ;; Reduce rendering/line scan work for Emacs by not rendering cursors or regions
;; in non-focused windows.
(setq-default cursor-in-non-selected-windows nil)
(setq highlight-nonselected-windows nil)
;; More performant rapid scrolling over unfontified regions. May cause brief
;; spells of inaccurate syntax highlighting right after scrolling, which should
;; quickly self-correct.
(setq fast-but-imprecise-scrolling t)
;; Don't ping things that look like domain names.
(setq ffap-machine-p-known 'reject)
;; Emacs "updates" its ui more often than it needs to, so we slow it down
;; slightly from 0.5s:
(setq idle-update-delay 1.0)
;; Font compacting can be terribly expensive, especially for rendering icon
;; fonts on Windows. Whether disabling it has a notable affect on Linux and Mac
;; hasn't been determined, but we inhibit it there anyway. This increases memory
;; usage, however!
;; (setq inhibit-compacting-font-caches t)
;; Introduced in Emacs HEAD (b2f8c9f), this inhibits fontification while
;; receiving input, which should help with performance while scrolling.
(setq redisplay-skip-fontification-on-input t)
(setq gc-cons-threshold (* 32 1024 1024))
(setq garbage-collection-messages nil) (setq garbage-collection-messages nil)
(use-package gcmh
:ensure t
:init
(gcmh-mode)
:config
(setq gcmh-idle-delay 5
gcmh-high-cons-threshold (* 128 1024 1024) ; 128mb
gcmh-verbose t))