spacemacs
spacemacs copied to clipboard
[low prio] [feature inquiry] GCMH: Garbage Collector Magic Hack: suitable for Spacemacs?
I recently found out about Andrea Corallo's Garbage Collector Magic Hack (gcmh), which changes GC thresholds at load time and after finished loading Emacs, to allow for quicker startup and shortening GC pauses: https://akrl.sdf.org
However, as memory usage goes with Spacemacs and multiple layers, I wanted to ask if you think it's worth adding as a feature or layer.
Emacs maintainer Eli Zaretskii has useful information on a default value if its to be included in Spacemacs. https://old.reddit.com/r/emacs/comments/bg85qm/garbage_collector_magic_hack/
Personally what made the biggest difference for me for spacemacs performance is
- Use the emacs profiler. Spacemacs binds this to =SPC h P=
Setting =savehist-autosave-interval= to 60 seconds (from the default of 300) and =history-length= to 1000 (from the default of 100) uses a lot of processing power. Performance problems can be plainly seen by using the Emacs cpu+mem profiler. See https://emacs.stackexchange.com/questions/12086/high-cpu-memory-usage-and-abnormally-large-savehist-file =spacemacs-defaults/init-savehist=, Spacemacs Github issues #9409, #1369.
Here's my config for savehist,
(setf history-length 25
savehist-save-minibuffer-history nil
savehist-autosave-interval nil
kill-ring-max 200
savehist-mode nil)
(delq 'mark-ring savehist-additional-variables)
(delq 'global-mark-ring savehist-additional-variables)
(delq 'search-ring savehist-additional-variables)
(delq 'regexp-search-ring savehist-additional-variables)
(delq 'extended-command-history savehist-additional-variables)
(delq 'kill-ring savehist-additional-variables)
(put 'org-brain-headline-cache 'history-length 10)
(put 'bibtex-completion-cache 'history-length 10)
(push 'org-brain-headline-cache savehist-additional-variables)
(push 'bibtex-completion-cache savehist-additional-variables)
(push 'helm-ff-history savehist-additional-variables)
(push 'org-clock-history savehist-additional-variables)
;; Emacs profiler shows `savehist-autosave' is very performance intensive.
(add-hook 'kill-emacs-hook #'savehist-save) ; Savehist only on exit.
- Comment out packages I don't need. The following is from the layers section in my .spacemacs
;; I prefer no battery info on my modeline. Emacs profiler tells me the
;; package uses a lot of battery itself.
;; Ditto for icons, lots of wasted cpu cycles for no functionality.
;; Symon is cute, but https://github.com/zk-phi/symon/issues/42 shows
;; that a significant performance price is paid.
(spacemacs-modeline :packages (not
anzu
fancy-battery
font-lock+
neotree
;; spaceline-all-the-icons
symon
vim-powerline))
(spacemacs-navigation :packages (not
restart-emacs
;; `avy-goto-word-or-subword-1' is a more general use case.
ace-link
;; I believe the winum (SPC 1) and avy-word (jumps across windows)
;; is enough.
ace-window
;; package-list-packages and
;; package-menu-filter-by-keyword "status:installed"
;; paradox
;; More gimmicky than useful.
golden-ratio
;; Utility packages that I have no use for.
centered-cursor-mode
open-junk-file
auto-highlight-symbol))
A lot of low hanging fruit in my opinion. Definitely a system-specific setting. I would help test a PR.
Thanks for the detailed suggestion!
I found this comment on the Doom Emacs repo yesterday, with some insights on the matter by Henrik Lissner: https://github.com/doomemacs/doomemacs/issues/3108
Still, I'm going to test the profiler on x86_64 Linux + macOS & i686 Linux, then come back with results.
Actually Spacemacs already do that.
At begin of startup, the gc parameters were gc-cons-threshold 402653184 gc-cons-percentage 0.6, or (400M, 0.6).
At the end of startup, the gc parameters will change to customer ones, default is (100M, 0.1).
https://github.com/syl20bnr/spacemacs/blob/develop/init.el#L31
https://github.com/syl20bnr/spacemacs/blob/develop/core/core-spacemacs.el#L266-L267
Then I have nothing else to add. Thanks for clarifying!