emacs-lsp / lsp-ui

UI integrations for lsp-mode
https://emacs-lsp.github.io/lsp-ui
GNU General Public License v3.0
1.04k stars 139 forks source link

[lsp-ui-sideline] Reduce calls to line-number-at-pos #517

Closed sebastiencs closed 3 years ago

sebastiencs commented 3 years ago

line-number-at-pos is the slowest operation in lsp-ui-sideline and was called several times, including in post-command-hook. It impacts performance only with big buffers.

This reduce the number of calls to this function to 0 or 1. It is now called only after the timer lsp-ui-sideline-delay, and when the cursor changes of line. When the cursor stays on the same line it doesn't call line-number-at-pos

@kurnevsky This should also fix the issue we mentioned in https://github.com/emacs-lsp/lsp-ui/pull/509 Can you please confirm ?

kurnevsky commented 3 years ago

Yes, it fixes that issue.

kurnevsky commented 3 years ago

Though I noticed one problem - if I move cursor quickly old requests are not cancelled and they start to execute with new ones and redraw the same sideline multiple times.

kurnevsky commented 3 years ago

I fixed it in this commit: https://github.com/emacs-lsp/lsp-ui/commit/4094eaf557ae43229abf3a0cf6e53c0a446f7bf0 But for some reason it was deleted :(

sebastiencs commented 3 years ago

Though I noticed one problem - if I move cursor quickly old requests are not cancelled and they start to execute with new ones and redraw the same sideline multiple times.

Does this occurs on the master branch ?

I fixed it in this commit: 4094eaf But for some reason it was deleted :(

Ah, this has been removed for https://github.com/emacs-lsp/lsp-ui/issues/483

kurnevsky commented 3 years ago

Does this occurs on the master branch ?

Yes.

I think we should cancel such requests - currently I have an example when it takes ~3s so when moving cursor up-down on such line it loads cpu a lot and continue redrawing/loading after I stop for a long time.

kurnevsky commented 3 years ago

@sebastiencs will you merge this? At least it doesn't make things worse :)