0

When I launch emacsclient or make a new frame it spends ~2s in:

   - make-frame                                                   312  42%
    - frame-creation-function                                     311  42%
     - apply                                                      311  42%
      - #<compiled 0x3edba9>                                      311  42%
       - x-create-frame-with-faces                                311  42%
        - face-set-after-frame-default                            287  39%
         + face-spec-recalc                                       274  37%

I have 523 faces in frame-face-alist which explains why it's slow. But they all seem to be from packages I use regularly so I can't just get rid off them.

If I replace face-spec-recalc with an empty function, the new frame loads instantly so I'm pretty sure that's the culprit.

Is there anything I can do to make new frames load faster?

Maybe load faces lazily or cache them somewhere?

I'd be fine with a hack that meant that I had to restart emacs to pick up new faces.

  • 1
    I do not know whether you would be interested in buffer-local faces, but I remember launching a thread seeking assistance where I was setting faces and discovered a tremendous overhead / time-suck, and the solution was to use the face-remapping-alist which is designed to work quickly during the redisplay process. It may be worth exploring ... there is a function that uses the face-remapping-alist, which is called face-remap-add-relative: gnu.org/software/emacs/manual/html_node/elisp/… – lawlist May 14 at 7:17
  • ... continued ... I ended up setting the face-remapping-alist as a default for all buffers, and as a buffer-local for other buffers; i.e., setq-default and setq-local. Although the docs say to use the face-remap-add-relative to do the adjustments, I chose to set the face-remapping-alist directly using those default / local approaches. I primarily use this for certain mode-line custom settings; and, I also use it for how the interactive mini-buffer colorizes the prompt and text when focus is inside or out of the mini-buffer.... – lawlist May 14 at 7:22
  • I suggest you M-x report-emacs-bug. I remember suffering from very slow frame creation many years ago with similar symptoms, but what you describe is not normal and should get a proper fix. – Stefan May 14 at 17:31
  • I reported a bug and it was merged as a dupe of debbugs.gnu.org/cgi/bugreport.cgi?bug=41200. Looks like there is a patch that improves performance. Hopefully it will land it emacs 27. – Jamie Brandon May 14 at 19:23

Your Answer

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

Browse other questions tagged or ask your own question.