Skip to content

[4.1][AST] Retrive EndLine after StartLineAndColumn for SingleRawComment #14735

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
Feb 21, 2018

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Feb 20, 2018

Cherry-pick of #14733 to swift-4.1-branch

Explanation: llvm::SourceMgr caches the position and the line number of the last query. For subsequent queries, It usually scans from that position. However, if the query is for a position ahead of the last query, it re-scan from the top of the whole buffer. This significantly slows down the performance.
This change reorder the queries to llvm::SourceMgr so that they aligns the order of appearance in the source file. This change effectively mitigate performance regression introduced in #11264 without functional changes.
Scope: SourceKit and ASTSerialization. Changes are localized in SingleRawComment class, no interface change.
Radar/SR: rdar://problem/37570893
Risk: Low. No API change. This change is just for utilizing cache functionality of llvm::SourceMgr
Testing: Passes all tests.
Reviewer: @akyrtzi @benlangmuir

llvm::SourceMgr caches the line and column of the last query. It
usually scans from that position for subsequent queries. However, if the
query is for a position ahead of the last query, it re-scan from the top
of the whole buffer. This significally slows down the performance.

This change effectively mitigate performance regression introduced in
swiftlang#11264 without functional changes.
@rintaro
Copy link
Member Author

rintaro commented Feb 20, 2018

@swift-ci Please test

@rintaro rintaro changed the title [AST] Retrive EndLine after StartStartLineAndColumn for SingleRawComment [4.1][AST] Retrive EndLine after StartStartLineAndColumn for SingleRawComment Feb 20, 2018
@rintaro rintaro requested a review from akyrtzi February 20, 2018 08:12
@rintaro rintaro changed the title [4.1][AST] Retrive EndLine after StartStartLineAndColumn for SingleRawComment [4.1][AST] Retrive EndLine after StartLineAndColumn for SingleRawComment Feb 20, 2018
Copy link
Contributor

@akyrtzi akyrtzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM to merge, but please give it a thought for potential improvement on master on how we could ensure that we don't regress again for this, is there maybe a way to add an assertion hit that triggers if a re-scan occurs ?

@rintaro
Copy link
Member Author

rintaro commented Feb 21, 2018

is there maybe a way to add an assertion hit that triggers if a re-scan occurs

I don't think there's simple way to assert it.
We probably should setup some performance tests to detect regression.

@rintaro rintaro merged commit d2aeb27 into swiftlang:swift-4.1-branch Feb 21, 2018
@rintaro rintaro deleted the 4.1-ast-comment-endline branch February 21, 2018 01:17
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.

2 participants