fix(treesitter): remove default match limit#39696
Merged
Merged
Conversation
fb08646 to
9f2bc70
Compare
clason
reviewed
May 9, 2026
Recent updates to tree-sitter improved the iteration speed of captures that previously led to catastrophic performance cliffs. This limit should (hopefully) no longer be necessary.
9f2bc70 to
5502656
Compare
Contributor
Author
|
Also, this issue looks related: #26325 |
lewis6991
approved these changes
May 9, 2026
Member
|
Oh, yeah, meant to link that! |
Member
|
This PR seems to have exposed that some queries can create a combinatorial explosion of matches. The old default The issue I specifically hit was with a dodgy python injection query which I've fixed here, but it's likely the match limit was probably masking similar queries in other languages. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Iterating over query captures previously had catastrophic performance cliffs, leading to unacceptable pauses, lag, etc. in editor.
Solution
In tree-sitter/tree-sitter#5548, capture iteration in tree-sitter was greatly improved. Neovim bumped its tree-sitter dependency to include this change in #39442.
The Numbers
I did some basic testing locally with captures from the tree-sitter-zig grammar, using the reproducer file from the original tree-sitter issue.
VIMRUNTIME=/home/lillis/projects/neovim/runtime \ timeout 1800 build/bin/nvim --clean --headless \ -c "luafile bench_zig.lua" -c "qa!"bench_zig.lua
Without the perf improvement in tree-sitter:
match_limit)With the perf improvement in tree-sitter:
Given this speedup, it seems like raising the match limit is worth a try.
Fixes #26325
AI DISCLAIMER: I used AI to figure out how to conduct this benchmark. Any issues with it are due to my own ignorance of Neovim internals.