airblade / vim-gitgutter

A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.
MIT License
8.37k stars 297 forks source link

Slow performance from gitgutter#async#execute() #588

Closed benwoodward closed 5 years ago

benwoodward commented 5 years ago

What is the latest commit SHA in your installed vim-gitgutter?

78db200b12d5322f43ac518adc8da0d90864a552

What vim/nvim version are you on?

NVIM v0.3.4
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20190113-94620-d8vv4n/neovim-0.3.4/build/config -I/tmp/neovim-20190113-94620-d8vv4n/neovim-0.3.4/src -I/usr/local/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/tmp/neovim-20190113-94620-d8vv4n/neovim-0.3.4/build/src/nvim/auto -I/tmp/neovim-20190113-94620-d8vv4n/neovim-0.3.4/build/include
Compiled by brew@Mojave.local

Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.3.4/share/nvim"

Run :checkhealth for more info

If no signs are showing at all, what does :echo b:gitgutter.path give?

n/a

If no signs are showing at all, and the path value is a path and not -2, does it work with let g:gitgutter_grep=''?

n/a

I've noticed a performance degradation since updating. gitgutter#async#execute() seems to be the source?

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
    4   0.090450   0.002150  gitgutter#all()
    4   0.085023   0.000730  gitgutter#process_buffer()
    4   0.081916   0.002783  gitgutter#diff#run_diff()
    4   0.072860   0.072603  gitgutter#async#execute()
   25   0.017731             <SNR>82_Highlight_Matching_Pair()
   65   0.013529             lightline#link()
    8   0.005328   0.000452  gitgutter#utility#is_active()
   28   0.004735             <SNR>34_abs_path()
    4   0.003525             <SNR>116_write_buffer()
    4   0.003277   0.000197  gitgutter#init_buffer()
   12   0.003153   0.000260  <SNR>34_dir()
    7   0.003106   0.001046  ale#cursor#EchoCursorWarning()
    4   0.003039   0.000095  <SNR>114_on_exit_nvim()
    4   0.002944   0.000312  gitgutter#diff#handler()
    8   0.002808   0.000236  <SNR>34_not_git_dir()
   25   0.002040   0.001496  ale#cursor#EchoCursorWarningWithDelay()
    4   0.001924   0.000247  gitgutter#sign#update_signs()
    8   0.001774   0.000393  <SNR>34_exists_file()
    4   0.001692   0.000181  <SNR>108_AutoReloadStatus()
    7   0.001558   0.001179  ale#ShouldDoNothing()

.init.vim

airblade commented 5 years ago

Which commit did you upgrade from?

airblade commented 5 years ago

I can't see why gitgutter#async#execute() would be slow; basically all it does is call jobstart().

What's the function's profile?

airblade commented 5 years ago

@benwoodward Any updates on this?

What is your &updatetime?

Also, where specifically do you see a performance degradation? Is there a lag between typing a key and it having an effect on screen? Or are the signs taking longer to appear than you would expect?

tcbbd commented 5 years ago

I found a problem with gitgutter#async#execute() too, maybe related?

Recently my neovim starts very slowly, taking 10s or more. It turns out the root cause is that the gitgutter#utility#set_repo_path tries to call the git command asyncly (to get the path of the opened file), but the command takes too much time to complete, and gitgutter would not allow me to enter vim until the command returns error or something.

Strangely, if I use plain vim instead, it will just take at most 1s to complete the async call to git command. I'm not sure if this is a neovim bug or there's something wrong with the git command.

airblade commented 5 years ago

Ah, that’s #589.

On 8 Mar 2019, at 19:46, Zhuocheng Ding notifications@github.com wrote:

I found a problem with gitgutter#async#execute() too, maybe related?

Recently my neovim starts very slowly, taking 10s or more. It turns out the root cause is that the gitgutter#utility#set_repo_path tries to call the git command asyncly (to get the path of the opened file), but the command takes too much time to complete, and gitgutter would not allow me to enter vim until the command returns error.

Strangely, if I use plain vim instead, it will just take at most 1s to complete the async call to git command. I'm not sure if this is a neovim bug or there's something wrong with the git command.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

airblade commented 5 years ago

@tcbbd This is fixed in 064a3d6.

@benwoodward Please could you upgrade vim-gitgutter and let me know if this is still a problem?

airblade commented 5 years ago

Closing because I think this is fixed. Let me know if not.