nvim-orgmode/orgmode

Huge performance drop after tree-sitter drop

Closed this issue · 9 comments

Describe the bug

After the upgrade to dafe433 I've seen a huge performance drop until the point of being unusable. Some examples:

  • Moving around an orgmode file (jk), entering in insert mode (ioa) has a delay of 1 or 2 seconds.
  • Open Telescope to find files has a 10 seconds delay and shows errors

Steps to reproduce

  • Upgrade to the latest version
  • Remove the tree-sitter configuration

Expected behavior

  • Performance should not change

Emacs functionality

No response

Minimal init.lua

-- Enter your minimal_init.lua here

Screenshots and recordings

No response

OS / Distro

Debian

Neovim version/commit

v0.9.5

Additional context

If I rollback to 0.3.1 I don't see any errors and performance goes back to normal

If I rollback to 0.3.1 I don't see any error

What errors did you get?
Also, can you try all of the commits after 0.3.1? Maybe something in between is causing the issue.

Are you using nvim-treesitter for other things? Did you follow instructions on ignoring the org filetype if you are using ensure_installed = 'all' on nvim-treesitter? If yes, try this:

: TSUninstall org
:lua require('orgmode.config'):reinstall_grammar()

Thanks for the quick answer @kristijanhusak as always. I did follow the instructions but didn't run the last snippet you mentioned. I've done it now and at a first glance it looks to be working just fine.

Nevertheless I'll do further performance tests tomorrow and close the issue if it's solved

Definitely that solved the performance issue. Nevertheless when I open Telescope I'm randomly seeing this error:

stack traceback:
	[C]: in function 'error'
	...M/usr/share/nvim/runtime/lua/vim/treesitter/language.lua:93: in function 'add'
	...r/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:98: in function 'new'
	...nvimvoyQiM/usr/share/nvim/runtime/lua/vim/treesitter.lua:61: in function '_create_parser'
	...nvimvoyQiM/usr/share/nvim/runtime/lua/vim/treesitter.lua:131: in function 'get_parser'
	.../.local/share/nvim/lazy/orgmode/lua/orgmode/org/fold.lua:23: in function 'fn'
	.../nvim/lazy/orgmode/lua/orgmode/utils/treesitter/init.lua:154: in function 'folds_levels'
	.../.local/share/nvim/lazy/orgmode/lua/orgmode/org/fold.lua:103: in function <.../.local/share/nvim/lazy/orgmode/lua/orgmode/org/fold.lua:101>
	[C]: in function 'nvim_buf_set_lines'
	...hare/nvim/lazy/nvim-notify/lua/notify/render/default.lua:18: in function <...hare/nvim/lazy/nvim-notify/lua/notify/render/default.lua:4>
	...e/nvim/lazy/noice.nvim/lua/noice/view/backend/notify.lua:77: in function <...e/nvim/lazy/noice.nvim/lua/noice/view/backend/notify.lua:75>
	...
	...ocal/share/nvim/lazy/nvim-notify/lua/notify/instance.lua:77: in function <...ocal/share/nvim/lazy/nvim-notify/lua/notify/instance.lua:41>
	...e/nvim/lazy/noice.nvim/lua/noice/view/backend/notify.lua:169: in function '_notify'
	...e/nvim/lazy/noice.nvim/lua/noice/view/backend/notify.lua:199: in function <...e/nvim/lazy/noice.nvim/lua/noice/view/backend/notify.lua:176>
	[C]: in function 'xpcall'
	...local/share/nvim/lazy/noice.nvim/lua/noice/util/call.lua:149: in function 'try'
	...local/share/nvim/lazy/noice.nvim/lua/noice/view/init.lua:140: in function 'display'
	.../share/nvim/lazy/noice.nvim/lua/noice/message/router.lua:215: in function <.../share/nvim/lazy/noice.nvim/lua/noice/message/router.lua:155>
	[C]: in function 'xpcall'
	...local/share/nvim/lazy/noice.nvim/lua/noice/util/call.lua:149: in function 'try'
	.../.local/share/nvim/lazy/noice.nvim/lua/noice/ui/init.lua:98: in function <.../.local/share/nvim/lazy/noice.nvim/lua/noice/ui/init.lua:74>
...M/usr/share/nvim/runtime/lua/vim/treesitter/language.lua:93: no parser for 'notify' language, see :help treesitter-parsers

I don't know how to read the issue so I'm not sure if it's related with nvim-orgmode. If it's not feel free to close the issue. Or if you prefer I can migrate this case to a new one

I'm also seeing this traceback. When it happens nvim get's stuck for minutes until I can regain control:

stack traceback:
	[C]: in function 'error'
	...nvimgQZIVv/usr/share/nvim/runtime/lua/vim/treesitter.lua:121: in function 'get_parser'
	.../.local/share/nvim/lazy/orgmode/lua/orgmode/org/fold.lua:23: in function 'fn'
	.../nvim/lazy/orgmode/lua/orgmode/utils/treesitter/init.lua:154: in function 'folds_levels'
	.../.local/share/nvim/lazy/orgmode/lua/orgmode/org/fold.lua:103: in function <.../.local/share/nvim/lazy/orgmode/lua/orgmode/org/fold.lua:101>
	[C]: in function 'nvim_buf_set_lines'
	...z/.local/share/nvim/lazy/nui.nvim/lua/nui/utils/init.lua:283: in function 'render_lines'
	....local/share/nvim/lazy/nui.nvim/lua/nui/popup/border.lua:555: in function 'mount'
	...z/.local/share/nvim/lazy/nui.nvim/lua/nui/popup/init.lua:245: in function 'mount'
	....local/share/nvim/lazy/noice.nvim/lua/noice/view/nui.lua:143: in function 'mount'
	....local/share/nvim/lazy/noice.nvim/lua/noice/view/nui.lua:130: in function 'create'
	....local/share/nvim/lazy/noice.nvim/lua/noice/view/nui.lua:287: in function <....local/share/nvim/lazy/noice.nvim/lua/noice/view/nui.lua:281>
	[C]: in function 'xpcall'
	...local/share/nvim/lazy/noice.nvim/lua/noice/util/call.lua:149: in function 'try'
	...local/share/nvim/lazy/noice.nvim/lua/noice/view/init.lua:140: in function 'display'
	.../share/nvim/lazy/noice.nvim/lua/noice/message/router.lua:215: in function <.../share/nvim/lazy/noice.nvim/lua/noice/message/router.lua:155>
	[C]: in function 'xpcall'
	...local/share/nvim/lazy/noice.nvim/lua/noice/util/call.lua:149: in function 'try'
	.../.local/share/nvim/lazy/noice.nvim/lua/noice/ui/init.lua:98: in function <.../.local/share/nvim/lazy/noice.nvim/lua/noice/ui/init.lua:74> function: builtin#18 ...nvimgQZIVv/usr/share/nvim/runtime/lua/vim/treesitter.lua:121: There is no parser available for buffer 41 and one could not be created because lang could not be determined. Either pass lang or set the buffer filetype

And I've noticed that if I open big org files for a long time it starts to go slower for example when opening the agenda (also minutes). If I close nvim, restore the session and then open the agenda it takes tens of seconds

First stacktrace shows no parser for 'notify' language, so you probably need to install some ts grammar.
For 2nd, I'm not sure what it is.

And I've noticed that if I open big org files for a long time it starts to go slower for example when opening the agenda (also minutes). If I close nvim, restore the session and then open the agenda it takes tens of seconds

Can you try minimal init and see if it happens with it? I see that you are using noice, so I'm suspecting it's interfering with something.

I've deactivated noice for the time being to see if it fixes it. What misled me was that orgmode was shown in the trace itself.

Anyway as it turns out is not related with orgmode I'm closing it and if it gets reproduced again I'll open an issue with the minimal init.

Thanks :)

@lyz-code do you have these issues with version 0.3.1 (with nvim-treesitter requirement)? If not, then maybe I need to look into this.

I pushed a small change that should maybe fix the 2nd issue for you, please give it at try.

Will do both and report back if there are any interesting findings