I wonder if it would be possible to record the window ids of the windows overlapped by the completion pum and only redraw those with NOT_VALID rather than all of them?
> On 20 Aug 2022, at 19:24, Bram Moolenaar <[email protected]> wrote: > > > Ben Jackson wrote: > >> I have been investigating some pathological performance problems with >> YouCompleteMe (YCM). YCM is a vim plugin which, in effect calls >> complete() on every keystroke in insert mode. I have noticed that >> sometimes, vim can become extremely slow while typing in this >> scenario. >> >> I did some profiling with callgrind and found that 99% of the time was >> redrawing, and in particular syntax highlighting regex code. Of >> course, doing something very often makes it appear “slow”. >> >> Anyway, my solution has been to reduce the number of times I call >> complete(), but I’m still curious if this can be improved. I’m not >> super clear on the exact set of calls here, but looking at the code it >> _appears_ that we force a redraw of all windows whenever the pum is >> undisplayed (pum_undisplay calls redraw_all_later(UPD_NOT_VALID), >> which is called by set_completion, via ins_compl_free, etc.). >> >> I think this also happens when any key is pressed while the pum is >> displayed (however it is displayed). >> >> Am I understanding the behaviour correctly - that a full redraw is >> requested whenever the pum is visible and a key is pressed, or >> complete() is called? >> Is there a way this redraw can be reduced? I seem to recall that popup >> windows have a clever way to minimise the redraw by storing what they >> are obscuring (or did I imagine that?). > > If a popup window is closed, moved or resized, the windows under it are > updated with UPD_NOT_VALID. The window contents (with text and > attributes) isn't cached, it needs to be recomputed. Normally this is > fast enough, but with complex syntax highlighting it can be a bit slow. > > Caching the text and attributes under the popup might be possible, but > it is tricky. Especially with completion, some text might be put in the > line (which is removed again when not using the completion) which > requires redrawing text around it. The caching only helps in limited > situations. > > What would help in general is to make syntax highlighting faster. At > least avoid bottlenecks. > > > -- > CRONE: Who sent you? > ARTHUR: The Knights Who Say Ni! > CRONE: Aaaagh! (she looks around in rear) No! We have no shrubberies here. > "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD > > /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ > /// \\\ > \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// > \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/F7756A28-03B7-46E0-B76A-4E03F238ABC7%40gmail.com.
