junegunn / fzf.vim

fzf :heart: vim
MIT License
9.62k stars 584 forks source link

:Buffers and :Files slow to open when large file is in buffer #875

Open MichaelAquilina opened 5 years ago

MichaelAquilina commented 5 years ago

Tested with nvim where fzf and fzf.vim were the two only plugins loaded.

When a large file is open in a buffer (e.g. in my case 44M of JSON), the commands :Files and :Buffers take multiple seconds to open.

neovim seems very responsive to every other operation.

dagadbm commented 4 years ago

i have the same problem but i dont even have large files... i do use Rg as the find command though

marcusbuffett commented 4 years ago

Just chiming in to say I've got the same thing, I ran the profiler and found this:

FUNCTION  <SNR>17_open()
    Defined: ~/.fzf/plugin/fzf.vim:204
Called 1 time
Total time:  25.030427
 Self time:  25.012566

count  total (s)   self (s)
    1   0.000198   0.000018   if stridx('edit', a:cmd) == 0 && s:fzf_fnamemodify(a:target, ':p') ==# s:fzf_expand('%:p')
                                return
    1              0.000001   endif
    1  25.030226  25.012545   execute a:cmd s:escape(a:target)

25s for one file, granted it's a massive file, but vim opens it instantly when I do :e, I would have thought fzf would just be calling that.

There's also this:

FUNCTION  <SNR>17_common_sink()
    Defined: ~/.fzf/plugin/fzf.vim:211
Called 1 time
Total time:  25.030736
 Self time:   0.000249

count  total (s)   self (s)
    1              0.000003   if len(a:lines) < 2
                                return
    1              0.000001   endif
    1              0.000004   let key = remove(a:lines, 0)
    1              0.000008   let Cmd = get(a:action, key, 'e')
    1              0.000009   if type(Cmd) == type(function('call'))
                                return Cmd(a:lines)
    1              0.000001   endif
    1              0.000002   if len(a:lines) > 1
                                augroup fzf_swap
                                  autocmd SwapExists * let v:swapchoice='o'| call s:warn('fzf: E325: swap file exists: '.s:fzf_expand('<afile>'))
                                augroup END
    1              0.000001   endif
    1              0.000001   try
    1   0.000044   0.000019     let empty = empty(s:fzf_expand('%')) && line('$') == 1 && empty(getline(1)) && !&modified
    1              0.000003     let autochdir = &autochdir
    1   0.000023   0.000010     set noautochdir
    2              0.000005     for item in a:lines
    1              0.000001       if empty
                                    execute 'e' s:escape(item)
                                    let empty = 0
    1              0.000001       else
    1  25.030457   0.000029         call s:open(Cmd, item)
    1              0.000008       endif
    1              0.000016       if !has('patch-8.0.0177') && !has('nvim-0.2') && exists('#BufEnter') && isdirectory(item)
                                    doautocmd BufEnter
    1              0.000001       endif
    2              0.000005     endfor
                              catch /^Vim:Interrupt$/
    1              0.000001   finally
    1   0.000034   0.000012     let &autochdir = autochdir
    1              0.000058     silent! autocmd! fzf_swap
    1              0.000002   endtry

not sure if that's helpful, I barely know how to read these profile things

darksworm commented 4 years ago

I'm also experiencing the same issue, using Ag, opening rather small files takes 1-2 seconds.

The attached profile log might help. Search for total time:(three spaces)1 profile.log