nvim-orgmode / orgmode

Orgmode clone written in Lua for Neovim 0.9+.
https://nvim-orgmode.github.io/
MIT License
3.03k stars 134 forks source link

Lag of 0.5-1 sec in large org files #792

Closed refaelsh closed 2 months ago

refaelsh commented 2 months ago

Describe the bug

When editing a large file (my NixOS configuration.org file is 2561 lines long) I feel a lag of 0.5-1 sec on any key press, especially in insert mode. On smaller files, there is no lag. Here is my large NixOS configuration.org file: https://gitlab.com/-/snippets/3736795.

Steps to reproduce

Just try editing a large enough Org file, you will feel the lag immidiaty.

Expected behavior

No lag when editing large Org files.

Emacs functionality

N/A

Minimal init.lua

The same thing happens with nvim -u minimal_init.lua.

Screenshots and recordings

No response

OS / Distro

NixOS unstable

Neovim version/commit

0.10.1

Additional context

Similar issue: https://github.com/nvim-orgmode/orgmode/issues/443. Not sure if its connected, but, in that issue, there was a lag of 5-6 seconds. And, when the issue was solved, the OP stated at the end:

Now it's about 1-2 seconds, when before it was about 6 seconds

kristijanhusak commented 2 months ago

Are you able to provide the org file, or at least a similar structure file with dummy content? It would be helpful to know if there are a lot of links, markup stuff (italic, bold, etc), headlines, blocks, etc.

refaelsh commented 2 months ago

Are you able to provide the org file

I've updated the very first post here. I should have done it from the begging. Good suggestion @kristijanhusak.

it would be helpful to know if there are a lot of links, markup stuff (italic, bold, etc), headlines, blocks, etc.

The only thing unusual is lots of subheadings in the Neovim section.

kristijanhusak commented 2 months ago

Can you provide some info about your hardware? I tested your file with both my configuration and minimal init, and didn't notice any slowness.

https://github.com/user-attachments/assets/74108762-8856-410a-8e6e-03fa4fa349d7

refaelsh commented 2 months ago

Can you provide some info about your hardware?

Gladly. It's a Dell laptop. Here is a screenshot from neofetch if that helps: image

kristijanhusak commented 2 months ago

Do you have similar issues when editing any other non-org bigger file that is highlighted with treesitter? Also, I see that your used memory at this point is 5.3 of 7.8 gb. What are the numbers when you open up this file in Neovim?

refaelsh commented 2 months ago

Also, I see that your used memory at this point is 5.3 of 7.8 gb.

This is how it is immediately after a fresh boot. I have 20 tabs open in Firefox (Librewolf). I am assuming this is the reason.

What are the numbers when you open up this file in Neovim?

When I open my large org file, the numbers barely change: they got from 66% percent occupied RAM to 67%.

refaelsh commented 2 months ago

Do you have similar issues when editing any other non-org bigger file that is highlighted with treesitter?

No. I just tried a 3000 lines Haskell file. No lag.

kristijanhusak commented 2 months ago

Ok, just to rule out treesitter highlighting, can you try to open up the file, disable highlighting with :lua vim.treesitter.stop() and then try to edit the file and see if there's lag?

refaelsh commented 2 months ago

Ok, just to rule out treesitter highlighting, can you try to open up the file, disable highlighting with :lua vim.treesitter.stop() and then try to edit the file and see if there's lag?

I did as you said, and there is still a lag.

kristijanhusak commented 2 months ago

Ok I just figured out that I'm testing with nightly Neovim. I do notice some lag with 0.10 and 0.10.1, I'll look into it. One more question. Did this lag start recently or it's here for a longer time now?

refaelsh commented 2 months ago

I do notice some lag with 0.10 and 0.10.1

Great! I am not crazy :-)

I'll look into it.

Thank you very much!

Did this lag start recently or it's here for a longer time now?

I've begun using this plugin, again (I tried using it once a couple of years ago, and I don't remember why I stopped), only yesterday.

kristijanhusak commented 2 months ago

I pushed a change to master that should speed up things. Can you give it a test?

refaelsh commented 2 months ago

I pushed a change to master that should speed up things. Can you give it a test?

I tested it with the latest master and there is no lag. Thank you!