Yggdroot / LeaderF

An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly for both vim and neovim.
Apache License 2.0
2.14k stars 180 forks source link

Leaderf line is slow to open (3-5 seconds) #1069

Closed eyalk11 closed 3 months ago

eyalk11 commented 3 months ago

NVIM v0.10.0-dev-3122+ga0a189a8e
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068
Run ":verbose version" for more info
0
1
3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)]
3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)]

command LeaderfDisablePreview let g:Lf_PreviewResult = { \ 'File': 0, \ 'Buffer': 0, \ 'Mru': 0, \ 'Tag': 0, \ 'BufTag': 0, \ 'Function': 0, \ 'Line': 0, \ 'Colorscheme': 0, \ 'Rg' : 0 }

let g:Lf_DevIconsFont = "DroidSansMono Nerd Font Mono"

set ambiwidth=double let g:Lf_PreviewResult = { \ 'File': 0, \ 'Buffer': 1, \ 'Mru': 0, \ 'Tag': 0, \ 'BufTag': 1, \ 'Function': 1, \ 'Line': 1, \ 'Colorscheme': 0, \ 'Rg' : 1 } let g:Lf_PopupPreviewPosition='top' "When you go to normal mode , doing I inserts the line "call win_execute(%d, "exec 'norm! %yy'")""" % (self._preview_winid, line_nr)) "\'Line':[['I','"zyy:exec g:Lf_py "lineExplManager.quit()""zp']],

" \'Line':[['I','exec g:Lf_py "call win_execute(%d, "exec ''norm! "zyy''")" % (lineExplManager._preview_winid):exec g:Lf_py "lineExplManager.quit()""zp']] let g:Lf_NormalMap ={ \ 'Line':[['I','"zyt[:exec g:Lf_py "lineExplManager.quit()""zp']], \ 'File':[['I','"zyy:exec g:Lf_py "lineExplManager.quit()""zp']], \ 'History' :[['I','"zyy:exec g:Lf_py "lineExplManager.quit()""zp']] }

let g:Lf_StlSeparator = { 'left': '', 'right': '' }

let g:Lf_StlColorscheme = 'powerline' "Make c-h , c-l a valid option in leaderf let g:Lf_CommandMap = {'':[''], '':[''], '': ['',''], '': ['','']}

let g:Lf_MruMaxFiles=100000 let g:Lf_ShowHidden = 1 let g:Lf_MaxCount = 0 let g:Lf_PreviewInPopup =0

let g:Lf_PopupHeight =0.5 let g:Lf_PopupWidth =0.9 let g:Lf_WindowPosition = 'popup'

""ideally would be called each time let g:Lf_PopupPosition=[max([float2nr(&lines * 0.4),10]),1] let g:Lf_CacheDirectory = "c:\users\ekarni\.vim\lcache" let g:Lf_IndexTimeLimit =7 let g:Lf_RgConfig = [ "--max-columns=150"] let g:Lf_WorkingDirectoryMode = 'c'

### Describe your question, feature request, or bug.

Very slow to start and takes around 3 secs until appears. 

I did some profiling both in python and in neovim (see attached) 

10 1.566076 provider#python3#Call() 1 1.561781 0.000023 leaderf#Any#start() 1 1.561758 1.504095 leaderf#LfPy()

FUNCTION provider#python3#Call() Defined: ~\nvim-lasttempxx\nvim-temp\share\nvim\runtime\autoload\provider\python3.vim:26 Called 12 times Total time: 1.783535 Self time: 1.783535

count total (s) self (s) 12 0.000052 if s:err != '' return 12 0.000009 endif 12 0.000047 if !exists('s:host') let s:rpcrequest = function('rpcrequest')

                            " Ensure that we can load the Python3 host before bootstrapping
                            try
                              let s:host = remote#host#Require('legacy-python3-provider')
                            catch
                              let s:err = v:exception
                              echohl WarningMsg
                              echomsg v:exception
                              echohl None
                              return
                            endtry

12 0.000006 endif 12 0.326054 return call(s:rpcrequest, insert(insert(a:args, 'python_'.a:method), s:host))

---

I did the profiling on slightly different version (on key mapping only)  , but checked it on the last one (from today). 

e67d7b5286932823b8ba925151402a231ba3b0e6 (last commit I have , 17 days ago ) 

### Steps to reproduce

IDK, I tried with leaderf as only plugin and it did OK (didn't happen)_

I tried just disabling all au and it was slow. 
I tried disabling popup and it was slow. 
Tried closing all other buffers.

nmap , Leaderf line

This is my mapping^

For debug 

nmap , call Lff() function! Lff() py3 << EOF import cProfile import pstats profiler = cProfile.Profile() profiler.enable() anyHub.start('line') profiler.disable() stats = pstats.Stats(profiler).sort_stats('cumulative') stats.dump_stats('output.pstats') EOF endfunction



### Actual behaviour

### Expected behaviour
eyalk11 commented 3 months ago

output.pstats.txt

That is python pstat file. IIRC the wait time is mainly when waiting for vim. RPC

eyalk11 commented 3 months ago

Apparently, it is reasonable after I removed some mappings. The nowait had limited effected for some reason. Still takes around 1.5 sec

Yggdroot commented 3 months ago

What about using :Leaderf line directly?

eyalk11 commented 3 months ago

It should be probably 1.5 sec as well. Now it seems fine. I just have to open bug sometimes for something to be solved.