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

Capturing and applying a pattern causes performance loss #167

Open
RedCMD opened this issue Jan 25, 2022 · 0 comments
Open

Capturing and applying a pattern causes performance loss #167

RedCMD opened this issue Jan 25, 2022 · 0 comments

Comments

@RedCMD
Copy link

RedCMD commented Jan 25, 2022

Create a syntax highlighter with the following code:
image

{
	"scopeName": "source.redcmd.syntax.lag",
	"patterns": [
		{
			"match": "a",
			"name": "keyword.control",
			"captures": {
				"0": { "patterns": [] }
			}
		}
	]
}

Create a test file, apply that syntax highlighter and type a few thousand a's
notice the increasing lag and vscode eventually giving up trying to match and just highlighting the rest of the file with the last token
image
(you may need to increase editor.maxTokenizationLineLength to 10,000 or so to see results)

Now remove "patterns": []
notice all lag disappearing and everything tokenizes correctly
image

Also notice that "patterns": [] can be empty (which would be a different bug in itself) and still causes lag
The capture group itself does need to capture something (does not happen with a empty group)
and the size of the capture text inside the group does not matter

Without "patterns": []; my machine is able to highlight almost 680,000 a's
While with patterns; it can barely highlight 6,500
Thats almost exactly 100x times faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant