3

I'm a former vim user that switched to emacs + evil with a still relatively simple configuration with only 36 packages. I'm really happy with the additional functionality emacs delivers, but one thing bothers me really much. Emacs is much slower when working and editing large files than vim. For example when I try to delete many lines with the "d NUMBEROFLINES d" in the magnitude of 10.000 or more emacs will freeze for some time. The same problems occurs when I try to select a large amount of lines in visual mode in similar magnitudes. In vim these things work almost immediately. I think that these performance issues are related to how emacs displays and edit text. My question is if there are any options or packages to work around these bottlenecks?

Edit:

After profiling the garbage collection (automatic gc) seems to be the source of problem. It uses up to 97% of CPU when I try to higlight a large region of text. Activating fundamental-mode and deactivating evil-mode doesn't have any effect on this.

3
  • If you don't use evil, is it any different? What about in fundamental-mode (with and without evil). Which mode is being used normally? Have you tested under emacs -Q? When it's slow, what does the profiler tell you? C-h i g (elisp)Profiling – phils Oct 29 '20 at 11:54
  • You're basically asking for packages that "make Emacs faster". That's much too vague. Please make your question more specific. E.g. ask how to figure out where the performance problem comes from. – Stefan Oct 29 '20 at 13:25
  • I am not 100%sure if this works for you but there is a program called joe editor which works blazingly fast with large files. Open an eshell buffer and type joe filename. You can edit large files in this way. Or even better call vim :-) – Kadir Gunel Oct 29 '20 at 17:15
2

Try:

  1. M-x profiler-start and select cpu from the prompt

  2. do the thing that is slow

  3. M-x profiler-stop

  4. M-x profiler-report

  5. Look for the cpu hogs and drill down in to them by hitting TAB on them to find what's slowing down your Emacs.

Also consider using so-long, which is now part of Emacs (as of Emacs version 27).

2
  • Thank your for the fast respond. The problem seems to be automatic gc. I will look further into it – enco909 Oct 30 '20 at 12:16
  • Try: (setq gc-cons-threshold (* 100 1024 1024)) – izkon Oct 31 '20 at 23:10
0

One common source of problems with large files is font locking/syntax highlighting. As a quick check, you can turn it off by switching to fundamental mode (i.e., M-x fundamental-mode). When you do this, you should see all the text in the buffer displayed in the same, default font with no colouring or other decoration.

If that solves your performance issue, you'll want to set up your config to disable font-locking on files of the type that are giving you problems. That will depend on details you haven't shared yet.

1
  • Thank your for the quick answer. Unfortunatly that doesn't solve the performance issues. – enco909 Oct 30 '20 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.