Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks
eyalk11 opened this issue May 17, 2024 · 4 comments
Closed
4 tasks

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

eyalk11 opened this issue May 17, 2024 · 4 comments

Comments

@eyalk11
Copy link

eyalk11 commented May 17, 2024

  • vim or neovim?

    • vim
    • [x ] neovim
  • Output of vim --version or nvim --version:

  • Output of :echo has("python"):

  • Output of :echo has("python3"):

  • Output of :py print(sys.version):

  • Output of :py3 print(sys.version):



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)]



  • Operating system:
    • Linux
    • Mac OS X
    • [ X] Windows
    • Etc.
  • Configurations related to LeaderF in vimrc:
command! LeaderfEnablePreview let g:Lf_PreviewResult = {
			\ 'File': 1,
			\ 'Buffer': 1,
			\ 'Mru': 0,
			\ 'Tag': 0,
			\ 'BufTag': 1,
			\ 'Function': 1,
			\ 'Line': 1,
			\ 'Colorscheme': 0,
			\ 'Rg' : 1
			\}

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()"<CR>"zp']],

"			\'Line':[['I','exec g:Lf_py "call win_execute(%d, "exec ''norm! "zyy''")" % (lineExplManager._preview_winid)<CR>:exec g:Lf_py "lineExplManager.quit()"<CR>"zp']]
let g:Lf_NormalMap ={ 
			\ 'Line':[['I','"zyt[:exec g:Lf_py "lineExplManager.quit()"<CR>"zp']],
			\ 'File':[['I','"zyy:exec g:Lf_py "lineExplManager.quit()"<CR>"zp']],
		\ 'History' :[['I','"zyy:exec g:Lf_py "lineExplManager.quit()"<CR>"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 = {'<C-k>':['<C-h>'], '<C-j>':['<C-l>'], '<Down>': ['<C-j>','<Down>'], '<UP>': ['<C-k>','<UP>']}

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).

e67d7b5 (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 <nowait> , <CMD>Leaderf line<CR>

This is my mapping^

For debug

nmap <nowait> , <CMD>call Lff()<CR>
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 eyalk11 changed the title Leaderf line is very slow Leaderf line is very slow to open May 17, 2024
@eyalk11
Copy link
Author

eyalk11 commented May 17, 2024

output.pstats.txt

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

@eyalk11 eyalk11 changed the title Leaderf line is very slow to open Leaderf line is slow to open (3-5 seconds) May 17, 2024
@eyalk11
Copy link
Author

eyalk11 commented May 17, 2024

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

@Yggdroot
Copy link
Owner

What about using :Leaderf line directly?

@eyalk11
Copy link
Author

eyalk11 commented May 17, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants