Skip to content

Commit 412f19d

Browse files
committed
speed up emacs startup by delaying setting gc after startup. Update
logs on emacs startup time
1 parent f9f7bfd commit 412f19d

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

init.el

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1+
(setq start-time (current-time))
2+
3+
;; assign high memory to reduce gc during load
14
(setq gc-cons-threshold (* 50 1000 1000))
25

36
(add-hook 'after-init-hook (lambda ()
47
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
58
(load-file (expand-file-name "config.el" user-emacs-directory))
69
(load-theme 'nord t)
7-
(setq gc-cons-threshold (* 2 1000 1000))
810
))
911

10-
(add-hook 'emacs-startup-hook
11-
(lambda ()
12-
(message "Emacs ready in %s with %d garbage collections."
13-
(format "%.2f seconds"
14-
(float-time
15-
(time-subtract after-init-time before-init-time)))
16-
gcs-done)))
12+
(defun my/after-startup ()
13+
(message "Emacs ready in %s with %d garbage collections."
14+
(format "%.2f seconds"
15+
(float-time
16+
(time-subtract (current-time) start-time)))
17+
gcs-done)
18+
19+
;; set proper gc values after load
20+
(setq gc-cons-threshold (* 2 1000 1000))
21+
)
22+
23+
(add-hook 'emacs-startup-hook #'my/after-startup)
1724

1825
(require 'package)
1926
(setq package-enable-at-startup nil)

0 commit comments

Comments
 (0)