manateelazycat / lsp-bridge

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

Can we reduce the frequency of `redisplay` execution? #919

Closed eval-exec closed 2 months ago

eval-exec commented 2 months ago

When I opened a C code:

  1. start profiler-start
  2. long press keyboard down
  3. profiler-report

When pressing the down key, I can feel a sluggishness and notice that redisplay is consuming a lot of CPU.

Is there a way for us to reduce the frequency of redisplay execution?

        1444  79% - lsp-bridge-monitor-post-command
        1443  79%  - let
        1443  79%   - if
        1387  76%    - progn
        1387  76%     - if
        1213  66%      - progn
        1213  66%       - redisplay
        1207  66%        - redisplay_internal (C function)
          59   3%         + eval
          13   0%         + #<advice C88>
           1   0%         + jit-lock-function
         171   9%      + if
           1   0%        string-prefix-p
           1   0%        lsp-bridge-diagnostic-hide-tooltip
          56   3%    + lsp-bridge-has-lsp-server-p
           1   0%  + set
         155   8% + redisplay_internal (C function)
          80   4% + #<closure E11>
          73   4% + command-execute
          26   1% + display-line-numbers-update-width
           6   0% + timer-event-handler
           5   0% + gcmh-register-idle-gc
           4   0% + evil-repeat-post-hook
           3   0% + winner-save-old-configurations
           3   0% + yas--post-command-handler
           2   0%   magit-pre-command-hook
           2   0%   evil--jump-handle-buffer-crossing
           2   0%   cursor-sensor--detect
           2   0% + lsp-bridge-monitor-window-buffer-change
           1   0% + indent-bars--highlight-current-depth
           1   0%   telega--check-buffer-switch
           1   0%   clear-minibuffer-message
           1   0% + internal-timer-start-idle
           1   0%   gcmh-set-high-threshold
           0   0%   ...
manateelazycat commented 2 months ago

inlay hint feature need window-start to fetch start point of current window.

window-start will failed if redisplay is not call first.

I will research window-start source code and try to remove redisplay.

eval-exec commented 2 months ago

eglot use jit-lock to support inlay hints: https://github.com/joaotavora/eglot/blob/db91d58374627a195b731a61bead9b4f84a7e4bc/eglot.el#L3883-L3892

I don't know if this is a better solution.

manateelazycat commented 2 months ago

I have push commit https://github.com/manateelazycat/lsp-bridge/commit/386ac482815ad29dc43fc9cf11d684a5e5c399ae

Can you upgrade to newest version and try again?

manateelazycat commented 2 months ago

Please re-open this issue if still have problem after upgrade to newest version.