summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2023-03-14 14:58:05 +0100
committerRicardo Wurmus <rekado@elephly.net>2023-03-14 15:05:15 +0100
commit6ee9ea26f82b0a52c2aab18366f6197a08ca7b6a (patch)
tree60f821d4df79fde3ecd530e0fd9ac3ce54807150
parent37b8fe3d231e247f94467432db89998d453177c2 (diff)
Add Performance section.
-rw-r--r--init.org24
1 files changed, 24 insertions, 0 deletions
diff --git a/init.org b/init.org
index 46783a5..23f53c3 100644
--- a/init.org
+++ b/init.org
@@ -29,6 +29,30 @@ We take all code blocks in this file and assemble an =init.el= from it if the so
(load target))))
#+END_SRC
+* Performance
+
+Make startup faster by reducing the frequency of garbage collection and then use a hook to measure Emacs startup time.
+
+#+begin_src elisp
+;; The default is 800 kilobytes. Measured in bytes.
+(setq gc-cons-threshold (* 50 1000 1000))
+
+;; Profile emacs startup
+(add-hook 'emacs-startup-hook
+ (lambda ()
+ (message "*** Emacs loaded in %s with %d garbage collections."
+ (format "%.2f seconds"
+ (float-time
+ (time-subtract after-init-time before-init-time)))
+ gcs-done)))
+#+end_src
+
+Native compilation gives Emacs a speed boost, but it spews compiler warnings that are quite annoying. Silence them.
+
+#+begin_src elisp
+(setq comp-async-report-warnings-errors nil)
+#+end_src
+
* Initialise packages
Emacs is an operating system and I use it as such (see [[http://elephly.net/posts/2016-02-14-ilovefs-emacs.html][this blog post]]). I rely on quite a few extensions that have been made available on various ELPA repositories. Recently, I have moved to installing and managing Emacs packages like any other software package on my system with the functional package manager [[https://gnu.org/s/guix][GNU Guix]]. I find this more reliable, although at first it is slightly less convenient as I can no longer just use =package.el= but first need to package the Elisp code for Guix.