I’ve been looking for methods to improve Emacs performance especially with my configuration being over >3k. I’m not particularly interested in startup-time since I never close Emacs. Here’s what I found so far

(setq package-native-compile                            t
      gcmh-high-cons-threshold                          100000000
      gc-cons-threshold                                 100000000
      scroll-conservatively                             101
      jit-lock-defer-time                               0
      large-file-warning-threshold                      nil)



(add-hook 'after-init-hook #'(lambda () (setq gc-cons-threshold (* 100 1000 1000))))
(defvar gc-timer nil)
(defun salih/maybe-gc ()
  (let ((original gc-cons-threshold))
    (setq gc-cons-threshold 800000)
    (setq gc-cons-threshold original
          gc-timer (run-with-timer 2 nil #'salih/schedule-maybe-gc))))

(defun salih/schedule-maybe-gc ()
  (setq gc-timer (run-with-idle-timer 2 nil #'salih/maybe-gc)))

(salih/schedule-maybe-gc)

I can tell that I’ve noticed some improvements.

  • sping@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    If not in startup, what performance deficits and improvements have you noticed? How do you measure or notice the improvements?

  • suzuki11109@alien.topB
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    Define fast. Speed is relative. Your fast and my fast may not be the same. But my answer is lazy load everything.

  • MitchellMarquez42@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    I had the package yascroll active, and it was fine on most files but org-mode was quite slow. I disabled that as well as svg-tag-mode etc

  • monad_in_disguise@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago
    1. use a POSIX OS (i.e., linux, unix, or macOS) as their file system and I/O management are generally more performant than Windows. NOTE: macOS I/O is worse than linux/unix, but better than windows; and their ARM chips generally perform better in their OS as well.

    2. I use 29.1 with native compilation enabled, and I generally use the Full Ahead of Time compile when i can, so that all the built-in/included by default emacs code is already compiled.

    3. I use a lot of tricks from DOOM Emacs, its hard to list them all, but many of them are good. Take a look at their early-init.el, init.el, and core files to see what they do to speed things up in various cases.

    4. I used Elpaca over straight/use-package for package management, as it was designed to be async from the ground up, so it can do a lot in parallel, well, emacs version of parallel.

    5. I use a lot of built-in hooks, package-hooks, and custom-hooks, to only load packages when they are actually needed, and try to avoid global modes when possible.

    my config is a bit of a mess, but if you are curious, you can see it here:

    customacs

    • ddptr@alien.topB
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      Also if you need to use windows, I found out recently that even GUI apps can be run under WSL. That seems to help the speed problem (I only tried magit and basic file handling and it is much closer to the speed under Linux)

      • monad_in_disguise@alien.topB
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        yes, definitely use WSL if you are on windows! Emacs goes from useable, to very performant when you setup WSL for GUI :)

    • jplindstrom@alien.topB
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      Can you say what’s going on here?

      I’m assuming it’s avoiding doing work, but from which package? Something in core Emacs?

  • jagster247@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    I’m sure there is a way to do this in vanilla but doom emacs cli lets you compile so I will compile all the packages with that

  • blitzsniping@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    Doom Emacs has great optimizations for this.

    You should manage your packages and defer those that are not immediately necessary (using use-package options and consider using benchmark to control initialization time).

    If you truly want to achieve blazing speed, consider running Emacs as a daemon (Emacs Daemon).

  • i_serghei@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    I’ve focused on what I really need and avoid cluttering my config. I’ve spent considerable time understanding what performs well and what doesn’t. I try to minimize the use of global modes and refrain from installing additional packages if built-in ones do the job. I’m very discerning when it comes to choosing any new package. Essentially, I have to “sell” myself on a new package, if you know what I mean. Yes, I do use byte-compilation for Lisp code and feel that I’ve managed to make things quite efficient and clean. You can take a look and borrow any solutions from my setup here: https://github.com/sergeyklay/.emacs.d

    • mok000@alien.topB
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      With the new --init-directory switch of Emacs 29, you can define a completely separate environment for Emacs that could be used to make more mean, lean and specialized versions of Emacs. For example, instead of having your Emacs do everything, IRC, email, programming, Org mode stuff etc. etc. etc. you could have a shell command invoking each one, e.g. Eirc, Eemail, Eorg, etc.