From 376438b94e7106d124caccfd19a30281f40b2c5b Mon Sep 17 00:00:00 2001 From: Marc Date: Tue, 13 Oct 2020 08:01:31 +0200 Subject: [PATCH] First tries to improve startup time. currently 1.05 from 1.44 --- init.org | 56 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/init.org b/init.org index 8753cdd..ffe2eaa 100644 --- a/init.org +++ b/init.org @@ -63,6 +63,23 @@ This function updates init.el whenever changes in init.org are made. The update (add-hook 'after-save-hook 'me/tangle-init) #+END_SRC +A small function to measure start up time. +Compare that to +emacs -q --eval='(message "%s" (emacs-init-time))' +(roughly 0.27s) +https://blog.d46.us/advanced-emacs-startup/ +#+begin_src emacs-lisp +(add-hook 'emacs-startup-hook + (lambda () + (message "Emacs ready in %s with %d garbage collections." + (format "%.2f seconds" + (float-time + (time-subtract after-init-time before-init-time))) + gcs-done))) + +(setq gc-cons-threshold (* 50 1000 1000)) +#+end_src + #+BEGIN_SRC emacs-lisp (require 'package) @@ -71,8 +88,8 @@ This function updates init.el whenever changes in init.org are made. The update (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t) -(when (< emacs-major-version 27) - (package-initialize)) +;(when (< emacs-major-version 27) +; (package-initialize)) #+END_SRC #+BEGIN_SRC emacs-lisp @@ -80,12 +97,12 @@ This function updates init.el whenever changes in init.org are made. The update (package-refresh-contents) (package-install 'use-package)) -(setq use-package-verbose nil) - (eval-when-compile (require 'use-package)) (require 'bind-key) +(setq use-package-verbose nil) + (use-package diminish :ensure t) #+END_SRC @@ -96,7 +113,6 @@ Maybe turn it on again at some point before the next major emacs upgrade #+begin_src emacs-lisp (setq byte-compile-warnings '(cl-functions)) #+end_src - * Default settings :PROPERTIES: :ID: 3512d679-d111-4ccd-8372-6fc2acbc0374 @@ -346,6 +362,7 @@ Windows Theme: #+BEGIN_SRC emacs-lisp (use-package imenu-list :ensure t + :defer t :config (setq imenu-list-focus-after-activation t imenu-list-auto-resize t @@ -363,6 +380,7 @@ Windows Theme: (use-package which-key :ensure t :diminish which-key-mode + :defer t :config (which-key-mode) (which-key-setup-side-window-right-bottom) @@ -409,6 +427,7 @@ Windows Theme: :ensure t :diminish (ivy-mode . "") + :defer t :init (ivy-mode 1) :bind @@ -423,11 +442,13 @@ Windows Theme: ; make counsel-M-x more descriptive (use-package ivy-rich :ensure t + :defer t :init (ivy-rich-mode 1)) (use-package counsel :ensure t + :defer t :bind (("M-x" . counsel-M-x) ("C-x C-f" . counsel-find-file) @@ -463,6 +484,7 @@ Windows Theme: (use-package company :defer 1 :diminish + :defer t :bind (("C-" . company-complete) :map company-active-map @@ -483,6 +505,7 @@ Windows Theme: (use-package company-statistics :ensure t :after company + :defer t :init (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el") :config @@ -491,12 +514,14 @@ Windows Theme: (use-package company-dabbrev :ensure nil :after company + :defer t :config (setq-default company-dabbrev-downcase nil)) (use-package company-box :ensure t :diminish + :defer t :init (add-hook 'company-mode-hook 'company-box-mode)) #+END_SRC @@ -532,6 +557,7 @@ Windows Theme: :ensure org-plus-contrib :mode (("\.org$" . org-mode)) :diminish org-indent-mode + :defer t :init (add-hook 'org-mode-hook 'company/org-mode-hook) (add-hook 'org-src-mode-hook 'smartparens-mode) @@ -707,7 +733,8 @@ Vorerst deaktiviert, Nutzen evtl. nicht vorhanden ** misc #+begin_src emacs-lisp (use-package eldoc - :diminish eldoc-mode) + :diminish eldoc-mode + :defer t) #+end_src ** Magit / Git :PROPERTIES: @@ -775,6 +802,7 @@ TODO Unterverzeichnisse wurden noch nicht getestet (use-package lsp-ui :after lsp-mode :ensure t + :defer t :diminish :commands lsp-ui-mode :config @@ -813,6 +841,7 @@ For useful snippet either install yasnippet-snippets or get them from here #+begin_src emacs-lisp (use-package yasnippet :ensure t + :defer t :diminish yas-minor-mode :config (setq yas-snippet-dirs (list (concat MY--PATH_USER_GLOBAL "snippets"))) @@ -847,6 +876,7 @@ With hippie expand I am able to use yasnippet and emmet at the same time with th ((css-mode . flycheck-mode) (emacs-lisp-mode . flycheck-mode) (python-mode . flycheck-mode)) + :defer 1.0 :init (setq flycheck-emacs-lisp-load-path 'inherit) :config @@ -865,7 +895,7 @@ Manage projects and jump quickly between its files #+BEGIN_SRC emacs-lisp (use-package projectile :ensure t - :defer t + :defer 1.0 :diminish :hook (projectile-after-switch-project . (lambda () (set-workon_home))) ;; for pyvenv to auto activate environment :bind-keymap @@ -979,12 +1009,14 @@ Default completion is C-j (use-package yaml-mode :if *sys/linux* :ensure t + :defer t :mode ("\\.yml$" . yaml-mode)) #+end_src ** R #+BEGIN_SRC emacs-lisp (use-package ess :ensure t + :defer t :init (if *work_remote* (setq exec-path (append exec-path '("P:/Tools/R/bin/x64")) @@ -1007,18 +1039,20 @@ apt install build-essential python3-dev (use-package lsp-python-ms :if *sys/linux* :ensure t - :defer 0.3 + :defer t :custom (lsp-python-ms-auto-install-server t)) (use-package python :if *sys/linux* :delight "π " + :defer t :bind (("M-[" . python-nav-backward-block) ("M-]" . python-nav-forward-block))) (use-package pyvenv :if *sys/linux* :ensure t + :defer t :after python :hook ((python-mode . pyvenv-mode) (python-mode . (lambda () @@ -1131,3 +1165,9 @@ Start fava with fava my_file.beancount It is accessable on this URL: [[http://127.0.0.1:5000][Fava]] Beancount-mode can start fava and open the URL right away. +* Stuff after everything else +Set garbage collector to a smaller value to let it kick in faster. +Maybe a problem on Windows? +#+begin_src emacs-lisp +(setq gc-cons-threshold (* 2 1000 1000)) +#+end_src