Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The move function is very slow on some large cpp files #560

Open
ngpong opened this issue Feb 4, 2024 · 2 comments
Open

The move function is very slow on some large cpp files #560

ngpong opened this issue Feb 4, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ngpong
Copy link

ngpong commented Feb 4, 2024

Describe the bug
The move function is very slow on some large cpp files. Not sure if it's a bug, but it should be an optimization option.

To Reproduce
Steps to reproduce the behavior:

  1. Prepare a large cpp file. In my case it's a file of over 1k lines
  2. call goto_* function

Output of :checkhealth nvim-treesitter

nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~

  • WARNING tree-sitter executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
  • OK node found v20.11.0 (only needed for :TSInstallFromGrammar)
  • OK git executable found.
  • OK cc executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
  • OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
machine = "x86_64",
release = "5.15.133.1-microsoft-standard-WSL2",
sysname = "Linux",
version = "#1 SMP Thu Oct 5 21:02:42 UTC 2023"
} ~

Parser/Features H L F I J

  • bash ✓ ✓ ✓ . ✓
  • c ✓ ✓ ✓ ✓ ✓
  • cmake ✓ . ✓ ✓ .
  • cpp ✓ ✓ ✓ ✓ ✓
  • json ✓ ✓ ✓ ✓ .
  • lua ✓ ✓ ✓ ✓ ✓
  • markdown ✓ . ✓ ✓ ✓
  • markdown_inline ✓ . . . ✓
  • python ✓ ✓ ✓ ✓ ✓
  • query ✓ ✓ ✓ ✓ ✓
  • regex ✓ . . . .
  • sql ✓ . . ✓ ✓
  • vim ✓ ✓ ✓ . ✓
  • vimdoc ✓ . . . ✓

Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang} ~

Paste the output here

Output of nvim --version

NVIM v0.10.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Additional context

Below is the result captured by the profiler, you can see that a single query takes close to 3s, which makes neovim appear unresponsive for 3s.

1707037303769

After more digging, I found that nvim-treesitter.query.find_best_match loops at least 2w+ times per execution, which I think may be the culprit for this issue.

@ngpong ngpong added the bug Something isn't working label Feb 4, 2024
@emmett2020
Copy link

I also encounter the same issue, hope this to be resovled.

@emmett2020
Copy link

FYI, anyone who meet the same issue may refer the workaround by @folke https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/util/plugin.lua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants