Peculiar performance problem with doom-snippets with (layout +bepo)

What happened?

Hi, I’ve been trying to debug a performance issue I am facing when (layout +bepo) is enabled.

The problem, is that Emacs is being really sluggish in some area when using this module. Specifically, while using which-key or prompting M-x takes a few seconds, where it is instantaneous (besides the normal idle-delay for which-key) in vanilla Emacs.

My really poor attempt at debugging this issue, led me to believe doom-snippets is causing the issue.

I ran multiple doom/toggle-profiler, the difference between vanilla and with (layout +bepo) enabled is that Emacs seems to call evil-after-load often, which in turns, loads multiple instance of doom-snippets-initialize. Here’s the relevant part of the profiler:

                       1264  50%       - which-key–propertize-description
                       1215  48%        - byte-code
                       1209  48%         - eval-after-load
                        306  12%          - #<compiled 0x1f40096f955d>
                        306  12%           + doom-snippets-initialize
                        302  12%          - #<compiled 0x1f40096f955d>
                        302  12%           + doom-snippets-initialize
                        302  12%          + #<compiled 0x1f40096f955d>
                        299  11%          + #<compiled 0x1f40096f955d>

Unfortunately, this is where my knowledge on debugging issue ends. I feel that I’ve found what’s responsible for my poor performance, but not the underlying problem. Why is there a call to eval-after-load when using (layout +bepo), but not in vanilla Emacs.

The complete profiler output with vanilla Doom Emacs and (layout +bepo) enabled: Test sequence:

  1. run doom/toggle-profiler
  2. SPC h … (wait for which-key menu to appear)
  3. T, which run doom/toggle-profiler

and the same test sequence without (layout +bepo):

Maybe @gagbo might have an idea? (I know you’re not really using bépo anymore, so sorry for the ping)

I also know that Doom is undergoing a massive refactor and the issue might take some time to get resolved, in the meantime, I’ll try to see if I can live without doom-snippets or without the bépo module.

What did you expect to happen?

Similar performance to the vanilla Doom Emacs experience.

Steps to reproduce

  1. enable the layout module with +bepo flag in init.el (layout +bepo)
  2. try to prompt a which-key entry (SPC h) or M-x
  3. observe abnormal delays to show the which-key menu or M-x prompt

System information

This is my current doom/info, profilers were run with vanilla Doom Emacs, though.

Loading data dump...

Does the performance stay bad or is it horrible only the first time. Which-key triggers a lot of hooks and loads, which trigger a lot of eval-after-load and possibly a lot of evil-collection-setup-hook invocations. I don’t know why it triggers snippets that much, but I wouldn’t be surprised that the first invocation takes significantly more time than without the module

It is every time that which-key or M-x is invoked. The performance aren’t degraded by much, M-x was instant, now it’s a second or two, which-key can take a bit longer. It’s not too bad, but enough to make it very frustrating at times.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.