manateelazycat / lsp-bridge

A blazingly fast LSP client for Emacs
GNU General Public License v3.0
1.41k stars 202 forks source link

Extreme lag (about 1s) when switch from other apps back to emacs #626

Closed WinterSong closed 1 year ago

WinterSong commented 1 year ago

not sure about whether caused by any recent update, an extreme lag (about 1s) occures frequently when I switch from other app back to Emacs. By using explain-pause-top to probe the time cost, I found the main cost comes from command acm-frame-restore-font in acm-frame.el.

This method seems to be customized for emacs 30, as described in the comment.

I am not sure if this is a bug related to Mac OS or Doom Emacs. FYI: The configuration of Emacs:

generated  May 09, 2023 22:10:13
system     MacOS 13.0 Darwin 22.1.0 arm64 ns
emacs      28.2 ~/.config/doom-emacs/
doom       3.0.0-pre PROFILE=_@0 HEAD -> master 042fe0c43 2023-04-12 15:09:23 -0400
           ~/.config/doom/
shell      /bin/zsh
features   ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS
           PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM ZLIB
traits     gui server-running chemacs-2.0 exec-path-from-shell custom-file
custom     warning-suppress-log-types
modules    :config use-package :input (&user rime) :completion (vertico +orderless
           +icons) (&user copilot) :ui doom doom-dashboard doom-quit hl-todo modeline
           nav-flash ophints (popup +defaults) treemacs unicode vc-gutter
           vi-tilde-fringe window-select workspaces zen :editor (evil +everywhere)
           file-templates fold (format +format-all) snippets (&user numpydoc) :emacs
           dired electric undo vc :term eshell vterm :checkers (syntax +childframe)
           :tools debugger eval lookup (magit +forge) make pdf :os macos :lang
           beancount cc emacs-lisp json java javascript markdown (org +pretty +journal
           +pandoc +dragndrop +pomodoro +noter +roam2 +present +org-download) (python
           +pyvenv +pyenv) rust sh yaml :app everywhere twitter :config (default
           +bindings +smartparens) :myself (&user lsp-bridge) (&user org-alert) (&user
           leetcode)
packages   (anki-editor :recipe (:host github :repo louietan/anki-editor :branch
           master)) (adoc-mode) (sql-indent) (valign :recipe (:host github :repo
           casouri/valign :branch master)) (vue-mode) (doom-snippets :recipe (:host
           github :repo hlissner/doom-snippets :files (*.el *))) (posframe)
           (exec-path-from-shell) (color-rg :recipe (:host github :repo
           manateelazycat/color-rg :branch master))
unpin      org-roam

The result of explain-pause-top is as below:

                                                                       1704 100% - ...
                                                                       1502  88%  - explain-pause--wrap-call-interactively
                                                                       1502  88%   - apply
                                                                       1501  88%    - #<compiled -0x194fa2923120ffd6>
                                                                       1501  88%     - apply
                                                                       1500  88%      - acm-frame-restore-font
                                                                       1500  88%       - set-frame-font
                                                                       1500  88%        - run-hooks
                                                                       1488  87%         - +unicode-init-fonts-h
                                                                       1488  87%          - +unicode-setup-fonts-h
                                                                       1488  87%           - if
                                                                       1488  87%            - progn
                                                                       1488  87%             - let
                                                                       1488  87%              - unwind-protect
                                                                       1488  87%               - progn
                                                                       1488  87%                - let
                                                                       1488  87%                 - unicode-fonts-setup
                                                                       1486  87%                  - cl-remove-if-not
                                                                       1486  87%                   - apply
                                                                       1486  87%                    - cl-remove
                                                                       1486  87%                       #<compiled 0x4e22230f7114453>
                                                                          2   0%                    unicode-fonts-compute-skipped-fonts
                                                                         12   0%         + doom-init-all-the-icons-fonts-h
                                                                          1   0%      + #<compiled -0x194f86725e90ffd6>
                                                                          1   0%    + #<subr call-interactively>
                                                                        202  11%    Automatic GC
manateelazycat commented 1 year ago

You need use emacs -Q for compare test.

acm don't call unicode-fonts-setup, it's looks like your config.

WinterSong commented 1 year ago

seems caused by Emacs 28.2 when resetting unicode fonts, the lag disappears when I switch to Emacs 29...