Skip to content

Neovim performance issues with CursorHold autocmd #100

Description

@antoinemadec

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:
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:

  1. vim and neovim don't trigger the same code in vim-matchup
  2. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions