General slowness when using GitGutter
I do like GitGutter a lot, and would like to keep using it.
However, I just find it really slows down vim.
I have set these settings to try and improve things:
let g:gitgutter_realtime = 0
let g:gitgutter_eager = 0
And that does help. If I'm just editing a few "normal" sized files, I'm not really experiencing any slowness.
But when I work, I probably use vim differently to your average user. I'm always splitting windows and opening new tabs and switching between them quickly. (I often have 10 tabs and in each tab, 3-5 split windows). Sometimes I'm editing large files.
With all of this going on, GitGutter can't keep up. I try to move the cursor between split windows, and I get lag. I try to jump around a buffer and I get lag. If I'm using the movement keys to move the cursor around the buffer on a large file - tonnes of lag.
It's just frustrating because I really want vim to respond instantly (as much as is possible), but still would like something that indicates git changes on a buffer.
If I turn GitGutter off, the issue goes away, so it's definitely related to this plugin.
Not sure if anything can be done? All I really want from this plugin is for it to update the git signs in the gutter when opening or saving a file. That's it. For my use it doesn't need to do whatever "checking" it's doing now in the background...
Maybe you can add some sort of "anal poweruser" setting which reduces the background processing... ? :-)
FWIW, I'm using vim 7.4: :version VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 25 2013 20:05:26) MacOS X (unix) version Included patches: 1-52
Cheers, -adam
Sorry to hear vim-gitgutter isn't keeping up.
First of all, can you confirm you're on the latest version of the plugin? I see from your vimrc that you use Vundle; a few people have mentioned that it doesn't always fully update plugins. Perhaps you could check that it really has pulled this repo's latest changes.
With the two config settings you quoted the plugin only runs on BufRead, BufWritePost and FileChangedShellPost, i.e. when you open or save a file. There won't be any background processing and you shouldn't get any lag at all moving around windows or tabs.
To pin down the problem:
- Next time things start to slow down, please could you run
:sign placeand estimate the total number of signs? It would be useful to have a rough idea. - How large is a "large" file?
- Please could you profile one of your editing sessions? Here are instructions.
Have you had a chance to look at this further?
I haven't heard back so I'm going to close this now. I'll be happy to re-open it if you can get back to me with a profile as described above.
Sorry Andy, I do appreciate you offering to look into the issue.
I've been doing iOS programming the last week, so haven't had much of a chance to investigate the profiling stuff in Vim
I'll follow this up tomorrow when I do some Ruby work, and let you know. Definitely no issue with Vundle though - I checked that the vundle repo had all the most recent commits.
Hi Andy,
I think I'm beginning to understand the issue.
This particular file I had been working on had 16,000 lines in it (it's was for seeding data into a database).
I was working on that file, and I must have staged a few lines in the file previously, then I must have added the 16,000 lines afterwards. I.e. pasting them in from a spreadsheet.
So I have 16,000 signs in a file. I guess that is the issue - I didn't understand that displaying so many signs had such a performance overhead.
(BTW, I tried to profile Vim, but it doesn't seem to create the logfile. It did work once - but then I deleted it as I hadn't done a proper test - but then it never recreated it. Weird. Anyway, I think just the number of signs I have is the main issue.)
FWIW, I have noticed slowness before using gitgutter, but with smaller (but still large - say 2000 lines) files.
I'm wondering whether it's possible to have a g_max_signs setting, which would disable gitgutter for any file that has more than that number of signs?
Because I think if you have thousands of signs, it's not really that meaningful to show that many and just decreases performance of Vim. I mostly appreciate the signs, when there are just a few on screen, and I can clearly see which lines I've recently modified. When there are thousands of signs on screen, it just becomes noise.
16,000 signs would explain it – Vim's not the speediest at rendering signs. I haven't measured it recently but I would guess that Vim slows down enough to notice at around a few hundred signs.
Setting an upper limit on the number of signs sounds like a good idea. (It'll be next week before I get a chance to tackle it though.)
Hi, I've met similar issue, and vim profiling shows this:
FUNCTION gitgutter#utility#buffer_contents()
Called 8 times
Total time: 181.139441
Self time: 181.139441
count total (s) self (s)
8 0.000021 if &fileformat ==# "dos"
let eol = "\r\n"
elseif &fileformat ==# "mac"
let eol = "\r"
else
8 0.000013 let eol = "\n"
8 0.000005 endif
8 181.139334 return join(getbufline(s:file, 1, '$'), eol) . eol
Could this be the issue? My version: VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 4 2012 04:22:36) Included patches: 1-429
gitgutter HEAD: fed2dbad3
@Carton That's interesting. I wonder whether the bottleneck is getbufline() or join(). How many lines are there in your file(s)?
@asgeo1 The latest code (83ace20) has a g:gitgutter_max_signs setting which turns off processing when the number of signs exceeds 500 (by default).
@Carton I'm amazed that join(getbufline(s:file, 1, '$'), eol) . eol took ~22s per run. Please tell me more!
I'm closing this now because the max-signs fix has been live for a week.
@Carton I've opened a new issue (#187) for the bottleneck you encountered.