From 6ee9ea26f82b0a52c2aab18366f6197a08ca7b6a Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Tue, 14 Mar 2023 14:58:05 +0100 Subject: Add Performance section. --- init.org | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'init.org') 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. -- cgit v1.2.3