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

Comparing a node text causes heavy cpu load #404

Closed
razzeee opened this issue Jul 30, 2019 · 3 comments
Closed

Comparing a node text causes heavy cpu load #404

razzeee opened this issue Jul 30, 2019 · 3 comments
Labels

Comments

@razzeee
Copy link
Contributor

razzeee commented Jul 30, 2019

I'm experiencing this problem after updating to wasm.

Here is an js SSCCE to replicate it https://github.com/Razzeee/tree-sitter-bounds-error/tree/cpu-compare

The things that seem important, is that the tree must have been updated and that we compare a string with our SyntaxNode.text

I tried to remove as much as possible from the example.

@maxbrunsfeld
Copy link
Contributor

Thanks for the example; that helped to explain what had happened. It looks like you re-parsed a tree after making the text shorter, but did not call edit on the old tree to make it consistent with the changed text. So the new syntax tree was in an inconsistent state with its text.

Previously, there was a bug where this inconsistency would cause an infinite loop when computing the text. I have a fix for this now. It's impossible to give the "right" text in this situation, but we can just truncate the text so that it doesn't infinite loop.

@maxbrunsfeld
Copy link
Contributor

Fixed via 9848ceb.

@razzeee
Copy link
Contributor Author

razzeee commented Jul 31, 2019

this wasn't a problem with the non-wasm version. Did it do what you fixed?
I'm only calling edit before parse in some cases https://github.com/elm-tooling/elm-language-server/blob/master/src/providers/astProvider.ts#L51
Do I need to address that?

NVM: I guess I introduced that problem some time ago.

@tree-sitter tree-sitter deleted a comment from issue-label-bot bot Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants