Closed azuenko closed 8 months ago
There's no performance problem for me which makes it difficult for me to determine when it is fixed.
Please could you profile gitgutter? This will show exactly where the slowdown is occurring.
I'm surprised, though, because 84bc2d6 simply replaced one built-in function – split()
– with another – strridx()
– and two array slices.
Hello Andy,
Here are two profile logs, for the normal & slow versions. In both cases I opened nvim, then run 4x O<ESC>u
on a file in git repo, and closed it. Hope that it helps!
Some more info that could help you to debug the issue.
I put the debug statements
call gitgutter#debug#log(base)
call gitgutter#debug#log(bpath)
and here is what I get in the log:
0.956426 function <SNR>74_on_exit_nvim[2]..gitgutter#diff#handler[1]:
0.956426 @@ -255,0 +256,2 @@ function! gitgutter#utility#base_path(bufnr)^@@@ -256,0 +259 @@ function! gitgutter#utility#base_path(bufnr)
1.484144 CursorHold Autocommands for "*"..function gitgutter#process_buffer[23]..gitgutter#diff#run_diff[55]..gitgutter#utility#base_path[7]:
1.484144
1.485144 CursorHold Autocommands for "*"..function gitgutter#process_buffer[23]..gitgutter#diff#run_diff[55]..gitgutter#utility#base_path[8]:
1.485144 autoload/gitgutter/utility.vim
0.959054 function <SNR>74_on_exit_nvim[2]..gitgutter#diff#handler[1]:
0.959054 @@ -256,0 +257,3 @@ function! gitgutter#utility#base_path(bufnr)
1.207955 CursorHold Autocommands for "*"..function gitgutter#process_buffer[23]..gitgutter#diff#run_diff[55]..gitgutter#utility#base_path[8]:
1.207955 :autoload/gitgutter/utility.vim
1.208686 CursorHold Autocommands for "*"..function gitgutter#process_buffer[23]..gitgutter#diff#run_diff[55]..gitgutter#utility#base_path[9]:
1.208686 autoload/gitgutter/utility.vim
The notable difference is in base
var, which is set to :autoload/gitgutter/utility.vim
in the new (slow) version. I suspect the non-empty base
triggers some additional code that causes slow down.
Thanks for digging into that.
You're right: I was using substring indexes incorrectly which meant that base
wasn't empty when it should have been, which was triggering additional code including a system()
call.
I think I've got it right now...!
Thank you Andy for fixing the issue. And generally thanks for developing and supporting this small yet quite useful plugin!
I can confirm the fix does its job, I've no more performance issues with the plugin.
I'm experiencing performance issues after the latest git-gutter update https://github.com/airblade/vim-gitgutter/commit/84bc2d68c0b32440bd1b12f245607a563a9421e4
Notice how the cursor starts blinking annoyingly.
Before
After
84bc2d6