83 votes
Accepted

How can I troubleshoot a very slow Emacs?

What can cause this problem? Is it caused by Emacs or it is due to my pc's performance? Generally what are the variables that affect Emacs' performance? Emacs has around 50,000 internal variables and ...
user avatar
  • 22.3k
67 votes
Accepted

How do I prevent extremely long lines making Emacs slow?

Emacs' handling of long lines is not very well optimized. For a number of operations, Emacs has to scan the whole line repeatedly. For example, to display a line, Emacs has to figure out the height of ...
user avatar
47 votes
Accepted

What can I do to speed up my start-up?

Here's my points on reducing emacs-init-time, this does not cover things like using a daemon or the server, it goes without saying that you should rarely ever close emacs. Don't: Don't require ...
user avatar
36 votes

How do I prevent extremely long lines making Emacs slow?

so-long.el (Emacs Wiki, GNU ELPA) will help in many situations. It is included by default in Emacs 27+ and available in GNU ELPA for older versions of Emacs (24.4 and later). This library enables you ...
user avatar
  • 43k
35 votes

How do I measure performance of elisp code?

Benchmark The most straightforward options is the built-in benchmark package. Its usage is remarkably simple: (benchmark 100 (form (to be evaluated))) It’s autoloaded, so you don’t even need to ...
user avatar
  • 22.3k
25 votes
Accepted

What algorithm does sort use?

If you have the Emacs source code installed, you can find the source code for sort with M-x find-function. There you can see that sort performs a merge sort. It checks the length of the list, breaks ...
user avatar
  • 5,786
19 votes
Accepted

practical limits on org-mode file size?

One of the less known features of Emacs is that it has a profiler! Let's assume your file is called foo.org, then you could do this: M-xprofiler-start C-x ffoo.org M-xprofiler-report After you've ...
user avatar
  • 10.8k
19 votes

How do I prevent extremely long lines making Emacs slow?

I did some brief experiments with this using a minified copy of jquery. font-lock-mode and flycheck-mode both contributed to slowness, as did js2-mode, and prettify-symbols-mode. line-number-mode and ...
user avatar
  • 3,954
16 votes

How do I measure performance of elisp code?

In addition to @Malabara's answer, I tend to use a custom-made with-timer macro to permanently instrument various parts of my code (e.g my init.el file). The difference is that while benchmark allows ...
user avatar
16 votes
Accepted

How can I improve startup time despite many packages?

One of the design choices in package.el was to try and make things "simple". Part of this is that package-initialize searches for all the packages that are installed, then tries to figure out which ...
user avatar
  • 25.2k
15 votes
Accepted

unicode.txt slowness

Reading the GitHub discussion thread linked in @wvxvw’s comment, I discovered the variable inhibit-compacting-font-caches. Setting it to non-nil solves the issue: (setq inhibit-compacting-font-caches ...
user avatar
  • 989
14 votes

Speed up Emacs start-up time

Whatever your .emacs and its improvements, you also should consider running emacs as a server at your session's opening : emacs --daemon Now, running emacs with emacsclient -t or emacsclient -...
user avatar
  • 273
12 votes
Accepted

How to prevent slow-down when an inferior processes generates long lines?

As already answered in the comments, Emacs becoming very slow in its redisplay for long lines is a well-known issue. Fixing it would be very nice, but needs lots of thought to be pulled off correctly....
user avatar
  • 20.9k
12 votes
Accepted

Magit extremely slow in Windows. How do I optimize?

I have actually done rather a lot of research on this and fundamentally the problem is that git for windows sucks This is the upstream bug: https://github.com/git-for-windows/git/issues/596 and it ...
user avatar
  • 1,690
12 votes
Accepted

How to avoid scrolling with large files hanging for short periods of time? (holding page keys for example)

As you noticed, this basically happens when the redisplay is too slow for some reason. There's not much we can do in the general case (when it's "much too slow") but when it's "just a tad bit too ...
user avatar
  • 25.2k
10 votes

How do I prevent extremely long lines making Emacs slow?

UPDATE http://git.savannah.nongnu.org/cgit/so-long.git/tree/so-long.el is a part of Emacs 27.1! OLD I usually unroll long lines and indent by tags (like HTML, XML, JSON). In order to make such ...
user avatar
  • 3,122
10 votes
Accepted

`looking-back` performance

Definitely. You will especially gain if you just want to test char-before or search backward for a literal string. And if you must use looking-back then try to use a LIMIT argument, if possible. See ...
user avatar
  • 69.1k
9 votes

Optimizing font lock performance

It turns out that the wildly varying performance was related to garbage collection. Each call to the function would get slower until a garbage collection was run. With stock emacs, gc was run every ...
user avatar
8 votes

What can I do to speed up my start-up?

Something that recently popped up on emacs reddit: decrease the number of garbage collection invocations by putting this near the beginning of your init file: (setq gc-cons-threshold 50000000) (add-...
user avatar
8 votes

How do I prevent extremely long lines making Emacs slow?

I expect you'll find that the difference is due to font-lock. When fontification is to be performed on the subset of the file which is visible in the window, it proceeds by first extending the ...
user avatar
  • 2,761
8 votes

Why is `let' faster with lexical scope?

In short — dynamic binding is very slow. Lexical binding is extremely fast at runtime. The fundamental reason is that lexical binding can be resolved at compile time, while dynamic binding cannot. ...
user avatar
  • 5,480
8 votes
Accepted

org-babel result to a separate buffer

I've looked through documentation but it seems like there's no such option. Surprising that org does not offer :output buffer option. Maybe this is in the works for future org versions. ... place ...
user avatar
  • 5,305
7 votes

How do I prevent extremely long lines making Emacs slow?

I created my own solution for this problem here: https://github.com/rakete/too-long-lines-mode I was not satisfied with phils solution which switches a buffer with very long lines to fundamental-mode,...
user avatar
7 votes

Speed up Emacs start-up time

1) I have found esup to be a very convenient for Emacs startup profiling. You just run M-x esup and get back list of all expressions in your init.el sorted by the time they took to execute. You don't ...
user avatar
  • 71
6 votes

What can I do to speed up my start-up?

The time you spend optimizing your startup time will likely be greater than all the extra time you would have otherwise waited for Emacs to start up. At the moment I make 25 require calls in my init ...
user avatar
  • 1,138
6 votes

How can I improve startup time despite many packages?

The problem you describe about package-initialize taking so much time to load is a well known problem. It is also one of the problems that some emacs frameworks try to solve by loading the autoloads ...
user avatar
6 votes
Accepted

Find cause of cpu-usage?

@npostavs' last comment should give you enough hints to solve the problem. The built-in profiler can tell which function is causing the high CPU usage. Here are simple steps to get started: (profiler-...
user avatar
  • 2,793
6 votes
Accepted

Is there an efficient way to tell which parts of my startup of Emacs take the longest to load?

This does it: (setq use-package-verbose t use-package-minimum-reported-time 0) We get in *Messages*: Loading package x...done (0.021s) Configuring package x...done (0.020s) Loading package y......
user avatar
  • 715

Only top scored, non community-wiki answers of a minimum length are eligible