Explain the issue
neovim CursorHold autocmd is 2x to 5x slower than vim when using vim-matchup
Minimal vimrc file
call plug#begin('~/.vim/plugins')
Plug 'andymass/vim-matchup'
call plug#end()
set nocompatible
set updatetime=100
function s:Start() abort
let g:start_time = reltimefloat(reltime())
endfunction
function s:End() abort
let g:end_time = reltimefloat(reltime())
let g:diff_time = g:end_time - g:start_time
echom g:diff_time
endfunction
autocmd CursorMoved * call s:Start()
autocmd CursorHold * call s:End()
let g:matchup_matchparen_deferred = 1
Expected Behavior
diff_time should be 100ms since set updatetime=100.
Actual Behavior
For this example:
vim diff_time is constantly around 100ms.
neovim diff_time varies a lot from 150ms to more than 200ms on my PC
On my full vimrc:
neovim diff_time goes from 150ms to 500ms ❗
- when disabling
vim-matchup, both vim and neovim have the same performance (~100ms)
My config:
- OS: Debian Testing
- vim-matchup: up to date
- nvim:
NVIM v0.5.0-575-g225f0bcd9
Build type: Release
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 12 2020 02:37:13)
Included patches: 1-716
Possible Explanations
It might be because:
vim and neovim don't trigger the same code in vim-matchup
- some
neovim issue/different behavior regarding CursorHold
Regarding 1., I tried to comment out the neovim specific code from vim-matchup and still observed the same slowdown for neovim.
Regarding 2., it might be related to timers, maybe neovim wait for timer to return before executing CursorHold?
What do you think, do you know where the slowdown is coming from?
Also, thank a lot for creating this plugin, it is absolutely amazing ❤️
Thanks,
Antoine
Explain the issue
neovimCursorHoldautocmd is 2x to 5x slower thanvimwhen usingvim-matchupMinimal vimrc file
Expected Behavior
diff_time should be 100ms since
set updatetime=100.Actual Behavior
For this example:
vimdiff_time is constantly around 100ms.neovimdiff_time varies a lot from 150ms to more than 200ms on my PCOn my full vimrc:
neovimdiff_time goes from 150ms to 500ms ❗vim-matchup, bothvimandneovimhave the same performance (~100ms)My config:
Possible Explanations
It might be because:
vimandneovimdon't trigger the same code invim-matchupneovimissue/different behavior regardingCursorHoldRegarding 1., I tried to comment out the neovim specific code from
vim-matchupand still observed the same slowdown forneovim.Regarding 2., it might be related to
timers, maybeneovimwait for timer to return before executingCursorHold?What do you think, do you know where the slowdown is coming from?
Also, thank a lot for creating this plugin, it is absolutely amazing ❤️
Thanks,
Antoine