roxma / nvim-completion-manager

:warning: PLEASE USE https://github.com/ncm2/ncm2 INSTEAD
MIT License
917 stars 49 forks source link

UltiSnips causing bad performance in insert mode #118

Closed felixjung closed 7 years ago

felixjung commented 7 years ago

Hi,

First of, thanks for this great plugin! It's so much more straight forward compared to other solutions.

Unfortunately, I've noticed some quite bad performance problems in insert mode with NCM. Here's what this looks like when I'm pressing and holding the DEL key. I experience the frequent stops and delays when typing as well.

ncm_performance

I've tried increasing the g:cm_complete_delay setting. It seems to have helped somewhat, but not really. Setting g:cm_auto_popup to 0 mostly helps fixing these performance issues. But I get the feeling that some completion source is just really bad.

Here's the output I get from profiling neovim:

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
  474  17.730348             provider#python3#Call()
  156  17.270726   0.031126  cm#_notify_sources_to_refresh()
  131  17.239600   0.004796  cm#sources#ultisnips#cm_refresh()
  131  17.216169             UltiSnips#SnippetsInCurrentScope()
  343   0.522950             UltiSnips#TrackChange()
  695   0.213131             <SNR>92_Highlight_Matching_Pair()
  863   0.202735   0.032507  LightLineFugitive()
  863   0.193967   0.009023  LightLineFiletype()
  863   0.184944             WebDevIconsGetFileTypeSymbol()
  863   0.170228   0.015498  fugitive#head()
    1   0.130045   0.000062  <SNR>57_YRInsertLeave()
    1   0.129694   0.118442  YRRecord()
  863   0.124196   0.031714  <SNR>82_repo_head()
    4   0.118208   0.000106  provider#clipboard#Call()
    4   0.118102   0.000146  2()
    4   0.117956             <SNR>58_try_cmd()
  730   0.110377   0.025594  <SNR>115_check_changes()
  716   0.097365             <SNR>115_notify_core_channel()
  370   0.095235   0.012105  cm#complete()
  725   0.094411             AutoPairsDelete()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
  474             17.730348  provider#python3#Call()
  131             17.216169  UltiSnips#SnippetsInCurrentScope()
  343              0.522950  UltiSnips#TrackChange()
  695              0.213131  <SNR>92_Highlight_Matching_Pair()
  863              0.184944  WebDevIconsGetFileTypeSymbol()
    1   0.129694   0.118442  YRRecord()
    4              0.117956  <SNR>58_try_cmd()
  716              0.097365  <SNR>115_notify_core_channel()
  725              0.094411  AutoPairsDelete()
 1726              0.054233  <SNR>82_repo()
  863   0.054973   0.042315  <SNR>82_repo_head_ref()
  605              0.039611  cm#context()
  865   0.058174   0.038840  LightLineFilename()
  863   0.202735   0.032507  LightLineFugitive()
  863   0.124196   0.031714  <SNR>82_repo_head()
  156  17.270726   0.031126  cm#_notify_sources_to_refresh()
  863   0.034207   0.028008  LightLineMode()
  730   0.110377   0.025594  <SNR>115_check_changes()
  865              0.021606  lightline#link()
  863   0.170228   0.015498  fugitive#head()

Is ultisnips the problem here?

Thanks a lot! Would really love to keep using NCM!

felixjung commented 7 years ago

OK, just to try what that would do, I deleted ultisnips. Performance is great now. Any recommendations how to fix ultisnips performance? Or should I just switch to a different snippet manager?

roxma commented 7 years ago

NCM get ultisnips candidates by sync API call, which is kind of heavyweight.

You don't need to delete ultisnips, though, use this to disable the built-in ultisnips source.

let g:cm_sources_override = {
    \ 'cm-ultisnips': {'enable':0}
    \ }

Future work (maybe):

  1. Considering ultisnips candidates are not changing for the same buffer, I will try improving the caching feature of NCM. By then, you don't need to disable ultisnips to use NCM.
  2. g:cm_complete_delay does not supress candidate calculation. Maybe we need to change the behavior, or add another config for this.
felixjung commented 7 years ago

Awesome! Thanks.

roxma commented 7 years ago

A new option g:cm_complete_start_delay is added. Set it to non-zero value when you have to deal with slow, sync completion source.

see #119

felixjung commented 7 years ago

Sweet. Thanks. Now that I know I can disable UltiSnips, I think I prefer having a quickly showing menu without ultisnips.