org-bullets icon indicating copy to clipboard operation
org-bullets copied to clipboard

Very slow performance

Open jaksz opened this issue 8 years ago • 13 comments

Whenever org-bullets is enabled, scrolling (and even fast typing) becomes laggy.

I'm running GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21) of 2015-04-10 on builder10-9.porkrind.org.

If there is a way I can provide more information (e.g. my about my system, config), please let me know.

This is inside the GUI version of Emacs. Note that there is no lag when using a terminal.

jaksz avatar Aug 19 '15 13:08 jaksz

M-x customize-group jit-lock has some variables that might help. Ex. jit-lock-defer-time

sabof avatar Aug 28 '15 01:08 sabof

I have experienced the same thing in GNU Emacs 25.1.1 (x86_64-w64-mingw32) of 2016-09-17. The problem is so bad that emacs almost invariably crashes. I have used org-bullets for years without problem, but this has come up immediately on my new machine. This is my first Win10 machine, but also my first quad-density display.

It seems that emacs isn't coping well with the display of extended Unicode characters. For example, if I load the org-bullets source, the lagginess occurs whenever the special characters (that appear literally in the code) come into view, and it goes away when they are out of view. I can also reproduce the lag by running view-hello-file, which contains mostly non-English characters.

So from what I can tell, this is not a problem with org-bullets per se, but with the fact that non-ASCII characters end up being in view effectively all the time, which is apparently problematic on some systems.

ghost avatar Nov 22 '16 16:11 ghost

I can hang emacs by scrolling my largest orgmode files in GNU Emacs 25.1.1 (x86_64-w64-mingw32) of 2016-09-17.

To @gavinpc's point that it's a non-ASCII (or general font-lock) problem, even the following simple snippet is enough to cause the hang. I have to disable org-bullets and this fancy list bullets functionality to eliminate the hang.

(defvar org-fancy-list-bullets
  '(("^ +\\([*]\\) "   ; asterisks need a space first to skip headings
     (1 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))
    ("^ *\\([-]\\) "   ; hyphens can start at bol
     (1 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
(font-lock-add-keywords 'org-mode org-fancy-list-bullets)

But I tend to use page up and page down so scrolling isn't much of an issue in practice. However, loading these huge files takes several seconds, which is annoying.

By systematically commenting things out in org-bullets, I learned that removing the calls to font-lock-fontify-buffer does positively impact file load time. I was surprised to see it did not break bullets composition. I may be missing something but it seems to still work.

shoover avatar Mar 22 '17 14:03 shoover

I have a (maybe?) the same issue.

This is on Windows 10, using emacs-w64-25.3-O2-with-modules.7z from https://sourceforge.net/projects/emacsbinw64/files/release/ and spacemacs

Here's a .gif with org-bullets on, where I press tab twice as soon as I get into the file. I know slowness can't really translate very well into video, but here goes, there isn't a pause I do at any point. This is all the editor hanging completely:

org bullets hanging

One curious thing to note is that after having the file open for a while, and having opened/closed the items and the like, the performance picks up pretty drastically.

Same thing after disabling org-bullets.

no org bullets, performance is fine

This issue only happens to me on my computer at home. On my work laptop performance is great. So it might either be a specific-piece-of-hardware issue, or it might be an issue that I have a 5k monitor at home, and a 1080p monitor at work. And that's what's making the difference.

Zyst avatar May 05 '18 18:05 Zyst

Same issue here with GNU Emacs 26.1 (build 1, x86_64-w64-mingw32) of 2018-05-30 and a display 4k (with powerline-mode and few other things).

The very same Emacs setup at work (with a 1080p as stated by @Zyst ) works very well.

giupo avatar Jul 03 '18 19:07 giupo

I found this on the all the icons package. This was a game changer for me on windows and I HIGHLY recommend it for anyone using org-bullets on windows as well!

(setq inhibit-compacting-font-caches t)

Turning that on is night and day for performance on windows for me.

ihdavids avatar Nov 15 '18 23:11 ihdavids

@ihdavids can confirm that this really does make an incredible difference

Zyst avatar Nov 16 '18 19:11 Zyst

@ihdavids thanks! this fixes the issue for me.

giupo avatar Nov 17 '18 14:11 giupo

It would be good to figure out what the apparent problem is with compacting font caches is on Windows. Would any of the Windows users in this discussion be willing to report it as an Emacs bug and help the developers investigate it? Maybe it could be fixed.

alphapapa avatar Jul 07 '19 00:07 alphapapa

I experienced the same slownesss in Emacs 27.1 / Fedora Linux. I added the inhibit-compacting-font-caches nil as suggested above but didn't help. The issue doesn't seem to be related to "org-bullets". I tried the newer "org-superstar" package as well and experienced the same slowness.

I think the slowness is because how Emacs renders unicode characters. I removed this line from my init.el and it fixed the slowness for me:

(set-fontset-font t 'symbol (font-spec :family "Noto Color Emoji"))

Take a look at your font settings and play with the definitions, try to change to a different font, etc.. It may help.

zoliky avatar Dec 05 '20 16:12 zoliky

Hi @zoliky

I tried the newer "org-superstar" package as well and experienced the same slowness.

I think the slowness is because how Emacs renders unicode characters.

That is correct, as pointed out here.

I added the inhibit-compacting-font-caches nil as suggested above but didn't help.

Do you mean (setq inhibit-compacting-font-caches t)? nil would be counterproductive. If you have found a font that is particularly resource-intensive for Emacs (for whatever reason), that would be quite interesting to add to my FAQ.

integral-dw avatar Dec 05 '20 19:12 integral-dw

I keep inhibit-compacting-font-caches t enabled. I haven't found a negative effect but it didn't fix the slowness in my case. I'm using Linux, though. inhibit-compacting-font-caches t may have better effect on Windows (unfortunately I don't have any windows machine to test).

This is my fonts config:

;; Default
(set-face-attribute 'default nil :font "Hack" :height 180)

;; Variable-pitch
(set-face-attribute 'variable-pitch nil :font "Hack" :height 180)

;; Fixed-pitch
(set-face-attribute 'fixed-pitch nil :font "DejaVu Sans Mono")

;; Emoji
; (set-face-attribute 'symbol nil :font "Noto Color Emoji")

Removing the Emoji font declaration fixed the slowness. I will try other emoji fonts as well and report back.

zoliky avatar Dec 05 '20 19:12 zoliky

This may be obvious to some, but it wasn't obvious to me so I will put it here in case it can help someone. I noticed the problem when I picked certain fonts as my default. Turns out that the font I selected did not have the symbols I have set in my org-bullet configuration. One way around this is to set the variable org-bullets-face-name to some face defined with some exhaustive font family. I use:

(defface my-org-bullets
  '((t :family "Symbola"
       ))
  "Face for org-bullets bullets."
  )
(setq org-bullets-face-name (quote my-org-bullets))

It fixes my speedup problems.

An alternative that seemed to work was setting the fall-back font in your init file. Like this:

(set-fontset-font "fontset-default" nil 
                  (font-spec :name "Symbola"))

Obviously, you should install Symbola in your system for any of this to work. This post helped me sort some of this out: https://zhangda.wordpress.com/2016/02/15/configurations-for-beautifying-emacs-org-mode/

Hope it helps someone!

sturgman avatar Aug 18 '21 15:08 sturgman