nvim-neorg / neorg

Modernity meets insane extensibility. The future of organizing your life in Neovim.
GNU General Public License v3.0
6.32k stars 209 forks source link

debounce neorg when it becomes slow #873

Open champignoom opened 1 year ago

champignoom commented 1 year ago

Issues

Feature description

Say we have a large note with 100k headers:

seq 100000 | sed 's/^/*** /' >note.norg

Any keypress in insert mode takes about half of second to respond. This should be fixed if dealing with large files is a real concern.

https://github.com/nvim-neorg/neorg/blob/a7291f4662664d0c3be3016adff6767dc52f907d/lua/neorg/modules/core/concealer/module.lua#L1292-L1294

Help

Yes

Implementation help

No response

max397574 commented 1 year ago

https://github.com/nvim-treesitter/nvim-treesitter#modules image

vhyrro commented 1 year ago

The only thing I can imagine taking a toll on the performance (at least from the concealer side) is the recalculation of code blocks (the logic that deals with dimming their backgrounds, as it's not very incremental). Everything else is done incrementally and therefore doesn't contribute to the slowdown. Neovim itself also slows down with large files, which can be seen e.g. when creating a markdown document of the same size. Treesitter itself can't just be disabled, otherwise all of Neorg breaks :)

champignoom commented 1 year ago

The only thing I can imagine taking a toll on the performance (at least from the concealer side) is the recalculation of code blocks ...

I forgot to mention that the experiment above was done with concealer being intentionally disabled for debugging and profiling purpose. It turned out that it was slow even without concealer. Until this is fixed or at least clarified, concealer should probably not be optimized prematurely.

Treesitter itself can't just be disabled, otherwise all of Neorg breaks :)

I should have probably s/disable/debounce/ and s/treesitter/neorg/: temporarily disable neorg for a few seconds, let the user type without lags, then restart neorg upon e.g. CursorHold.

Of course, again, this is relevant only if editing large files is a real concern.