natebosch / vim-lsc

A vim plugin for communicating with a language server
BSD 3-Clause "New" or "Revised" License
693 stars 83 forks source link

Vim-lsc seems to slow down vim8 popup #423

Closed smekkley closed 3 years ago

smekkley commented 3 years ago

I use Leaderf to search file in a vim8 pop up. After vim-lsc finishes with initialization with whatever language, anything I input in the popup becomes slow. I didn't observe this issue once I disabled vim-lsc. Leaderf also has an option not to use vim8 popup but normal vim window, and with non-popup mode the issue doesn't happen. I'm guessing that vim-lsc might be doing something during input in the popup.

https://github.com/Yggdroot/LeaderF/issues/803

Can somebody help me with debugging? Or point me to the right direction?
I'm not sure if it's vim issue or plugins issue.

Here is vim profiler results.

When the issue is reproduced.

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
    2  14.317551   0.000216  leaderf#Any#start()
    2  14.317335  14.311359  leaderf#LfPy()
    1   0.105057   0.100973  lsc#server#exit()
   21   0.003753             leaderf#ResetPopupOptions()
    4   0.003541   0.000899  <SNR>33_Kill()
    1   0.002498   0.000866  218()
    1   0.001358   0.000321  225()
    2   0.000989   0.000207  228()
    4   0.000790             leaderf#colorscheme#popup#hiMode()
    2   0.000778             leaderf#colorscheme#popup#hiMatchMode()
    1   0.000543   0.000013  <lambda>1()
    1   0.000530   0.000064  229()
   48   0.000528             leaderf#PopupFilter()
    1   0.000466   0.000141  <SNR>41_Consume()
    2   0.000448   0.000094  230()
    2   0.000354   0.000220  231()
    1   0.000275   0.000062  <SNR>41_Dispatch()
    1   0.000213   0.000033  <SNR>33_HandleShutdownResponse()
    4   0.000183             lsc#util#shift()
    2   0.000183             <SNR>41_Encode()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
    2  14.317335  14.311359  leaderf#LfPy()
    1   0.105057   0.100973  lsc#server#exit()
   21              0.003753  leaderf#ResetPopupOptions()
    4   0.003541   0.000899  <SNR>33_Kill()
    1   0.002498   0.000866  218()
    4              0.000790  leaderf#colorscheme#popup#hiMode()
    2              0.000778  leaderf#colorscheme#popup#hiMatchMode()
   48              0.000528  leaderf#PopupFilter()
    1   0.001358   0.000321  225()
    2   0.000354   0.000220  231()
    2  14.317551   0.000216  leaderf#Any#start()
    2   0.000989   0.000207  228()
    4              0.000183  lsc#util#shift()
    2              0.000183  <SNR>41_Encode()
    2              0.000181  <SNR>41_Format()
    1   0.000466   0.000141  <SNR>41_Consume()
    2              0.000134  232()
    5              0.000122  <SNR>30_OnClose()
    1              0.000110  lsc#config#messageHook()
    1              0.000105  lsc#config#responseHook()

When the issue isn't happening.(leaderf non-popup mode)

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
    2  10.511816   0.000276  leaderf#Any#start()
    2  10.511540  10.303251  leaderf#LfPy()
    2   0.121452             leaderf#colorscheme#highlightMode()
    1   0.103069   0.100990  lsc#server#exit()
    2   0.078680   0.000133  LSCEnsureCurrentWindowState()
    2   0.078118   0.071986  lsc#highlights#update()
    2   0.005800             lsc#highlights#clear()
   10   0.003560   0.000387  <SNR>30_IfEnabled()
    2   0.002634   0.000157  lsc#cursor#onMove()
    2   0.002144   0.000669  lsc#cursor#showDiagnostic()
    2   0.001476             <SNR>8_LoadFTPlugin()
    2   0.001475   0.000724  lsc#diagnostics#underCursor()
    6   0.001458   0.001217  <SNR>18_Highlight_Matching_Pair()
    4   0.001454   0.000365  <SNR>33_Kill()
    2   0.001381   0.000864  <SNR>3_SynSet()
    1   0.001019   0.000189  218()
    2   0.000905             leaderf#Rg#Maps()
    6   0.000894   0.000273  <SNR>47_HighlightReferences()
    1   0.000771   0.000137  225()
    6   0.000732             lsc#file#fullPath()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
    2  10.511540  10.303251  leaderf#LfPy()
    2              0.121452  leaderf#colorscheme#highlightMode()
    1   0.103069   0.100990  lsc#server#exit()
    2   0.078118   0.071986  lsc#highlights#update()
    2              0.005800  lsc#highlights#clear()
    2              0.001476  <SNR>8_LoadFTPlugin()
    6   0.001458   0.001217  <SNR>18_Highlight_Matching_Pair()
    2              0.000905  leaderf#Rg#Maps()
    2   0.001381   0.000864  <SNR>3_SynSet()
    6              0.000732  lsc#file#fullPath()
    2   0.001475   0.000724  lsc#diagnostics#underCursor()
    2   0.002144   0.000669  lsc#cursor#showDiagnostic()
   10   0.003560   0.000387  <SNR>30_IfEnabled()
    4   0.001454   0.000365  <SNR>33_Kill()
    6              0.000330  leaderf#colorscheme#setStatusline()
    2              0.000324  <SNR>11_LoadIndent()
    2              0.000323  leaderf#colorscheme#popup#hiMode()
    8              0.000280  <SNR>18_Remove_Matches()
    2  10.511816   0.000276  leaderf#Any#start()
    6   0.000894   0.000273  <SNR>47_HighlightReferences()

When the issue isn't happening.(leaderf popup mode, vim-lsc disabled)

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
    2   5.461203   0.000242  leaderf#Any#start()
    2   5.460961   5.455218  leaderf#LfPy()
   26   0.003742             leaderf#ResetPopupOptions()
    4   0.000886             leaderf#colorscheme#popup#hiMode()
   32   0.000527             leaderf#PopupFilter()
    2   0.000478             leaderf#colorscheme#popup#hiMatchMode()
    1   0.000311             lsc#server#exit()
    4   0.000147             <SNR>30_OnClose()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
    2   5.460961   5.455218  leaderf#LfPy()
   26              0.003742  leaderf#ResetPopupOptions()
    4              0.000886  leaderf#colorscheme#popup#hiMode()
   32              0.000527  leaderf#PopupFilter()
    2              0.000478  leaderf#colorscheme#popup#hiMatchMode()
    1              0.000311  lsc#server#exit()
    2   5.461203   0.000242  leaderf#Any#start()
    4              0.000147  <SNR>30_OnClose()

When the issue isn't happening.(leaderf window mode, vim-lsc disabled)

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
    2   5.659075   0.000367  leaderf#Any#start()
    2   5.658708   5.632011  leaderf#LfPy()
    2   0.013357             leaderf#colorscheme#highlightMode()
    2   0.003482             <SNR>8_LoadFTPlugin()
    2   0.003153   0.001885  <SNR>3_SynSet()
    6   0.001868   0.001601  <SNR>18_Highlight_Matching_Pair()
    2   0.000697             leaderf#Rg#Maps()
    2   0.000642             <SNR>11_LoadIndent()
    6   0.000619             leaderf#colorscheme#setStatusline()
    8   0.000310             <SNR>18_Remove_Matches()
    2   0.000248             lfMru#record()
    1   0.000247             lsc#server#exit()
   10   0.000185             <SNR>30_IfEnabled()
    2   0.000175             <SNR>19_LocalBrowse()
    2   0.000165             leaderf#colorscheme#popup#hiMode()
    4   0.000127             <SNR>30_OnWinEnter()
    2   0.000106             LSCEnsureCurrentWindowState()
    2   0.000031             lfMru#recordBuffer()
    2   0.000020             <SNR>30_OnClose()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
    2   5.658708   5.632011  leaderf#LfPy()
    2              0.013357  leaderf#colorscheme#highlightMode()
    2              0.003482  <SNR>8_LoadFTPlugin()
    2   0.003153   0.001885  <SNR>3_SynSet()
    6   0.001868   0.001601  <SNR>18_Highlight_Matching_Pair()
    2              0.000697  leaderf#Rg#Maps()
    2              0.000642  <SNR>11_LoadIndent()
    6              0.000619  leaderf#colorscheme#setStatusline()
    2   5.659075   0.000367  leaderf#Any#start()
    8              0.000310  <SNR>18_Remove_Matches()
    2              0.000248  lfMru#record()
    1              0.000247  lsc#server#exit()
   10              0.000185  <SNR>30_IfEnabled()
    2              0.000175  <SNR>19_LocalBrowse()
    2              0.000165  leaderf#colorscheme#popup#hiMode()
    4              0.000127  <SNR>30_OnWinEnter()
    2              0.000106  LSCEnsureCurrentWindowState()
    2              0.000031  lfMru#recordBuffer()
    2              0.000020  <SNR>30_OnClose()
smekkley commented 3 years ago

I noticed that some other popup plugins disable completion for some lsp client plugin. I confirmed that disabling lsc completion doesn't cause issue, so it should be done on every popup plugins that accepts input, not with vim-lsc.