Skip to content

Speed-up lookups for incremental re-parsing #101

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

Merged
merged 1 commit into from
Mar 4, 2019

Conversation

akyrtzi
Copy link
Contributor

@akyrtzi akyrtzi commented Mar 3, 2019

Previously the search for nodes to re-use was naively doing a lookup that always started from the top of the tree, every time the parser called back.
The new mechanism takes advantage of the fact that the parser continuously calls back with ascending source positions, not random ones, and keeps a "cursor" state for re-starting the lookup search from the last node position.

This commit also introduces SyntaxNode which is a more efficient representation for a syntax tree node, that SyntaxParser uses to efficiently report which syntax nodes got re-used during incremental re-parsing.

Changes result in improved performance for incremental reparsing. When using the test case from rdar://48511326, performance improves by 321x.

Previously the search for nodes to re-use was naively doing a lookup that always started from the top of the tree, every time the parser called back.
The new mechanism takes advantage of the fact that the parser continuously calls back with ascending source positions, not random ones, and keeps
a "cursor" state for re-starting the lookup search from the last node position.

This commit also introduces `SyntaxNode` which is a more efficient representation for a syntax tree node, that `SyntaxParser` uses to efficiently
report which syntax nodes got re-used during incremental re-parsing.

Changes result in improved performance for incremental reparsing. When using the test case from rdar://48511326, performance improves by 321x.
@akyrtzi
Copy link
Contributor Author

akyrtzi commented Mar 3, 2019

@swift-ci Please test

@akyrtzi akyrtzi merged commit 8e45b00 into swiftlang:master Mar 4, 2019
@akyrtzi akyrtzi deleted the opt6-incremental-parse branch March 4, 2019 21:21
@krzyzanowskim
Copy link

krzyzanowskim commented Mar 10, 2019

I've noticed that .typeIdentifier is no longer classified (it was previously). I wonder if that was intentional?

Also noticed that (sometimes) final keyword and (always) @inline(__always) is not classified now.

May it be due to this change?

@krzyzanowskim
Copy link

@akyrtzi
Copy link
Contributor Author

akyrtzi commented Mar 10, 2019

This PR is unrelated to what you are describing in SR-10074

adevress pushed a commit to adevress/swift-syntax that referenced this pull request Jan 14, 2024
Support tab based indentation in the whitespace linter.
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

Successfully merging this pull request may close these issues.

4 participants