airblade / vim-gitgutter

A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nvim hangs on opening a 3MB json file

TisnKu opened this issue · comments

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

What vim/nvim version are you on?
v0.7.2

When opening the 3MB json file attached below, my nvim hangs indefinitely. I have to kill the whole terminal window.
If I remove the plugin, it is normal again.

pairs.json.zip

Hmm, it's instantaneous for me on nvim v0.6.0. I'll upgrade nvim and try again.

In the meantime, perhaps you could turn on logging (let g:gitgutter_log=1), open the json file, and post the gitgutter.log file (which will be in the directory where gitgutter is installed) here.

And/or you could profile gitgutter.

Just tried with nvm v0.7.2 and it's still instantaneous.

When you open the json file and nvim hangs, does the file have any changes? (I assume it's in a git repo.)

The file was an empty file and the whole content was then added and not yet staged. I'll try to the log later.

Below is the log.
gitgutter.log

Thanks for the log. I also profiled the process.

The profile shows that running the diff and processing the diff's output are fast. At this point we have a list of 400,001 elements: one per added line.

Each one of those elements requires a sign. The code tells nvim/vim to add the signs with the built-in function sign_placelist(list). And this built-in function is taking 99% of the time.

So the time is spent inside nvim/vim, not the plugin.

In this case I suggest configuring the plugin to stop when the number of signs exceeds a threshold. For example:

let g:gitgutter_max_signs = 500

See :help g:gitgutter_max_signs.

I see, thanks.