-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[InterfaceFile] Improve flag extraction from interface file #72093
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
[InterfaceFile] Improve flag extraction from interface file #72093
Conversation
@swift-ci please smoke test |
StringRef prefix) { | ||
StringRef line; | ||
unsigned lineCount = 0; | ||
const unsigned maxLine = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit of a shame that we need a magic constant here, I wonder if there's anything we can do to make sure this is a valid precondition. Maybe asserting on textual interface printing or verification that this always holds true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me see what I can do. I am not really eager to land this since I don't see this really impact performance in any significant way in a real world compilation but more performance is always good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I revisited this patch. Remove the magic number but only parses the first comment block instead.
I don't know what is a good place to implement a diagnostics though. Ideally it should be interface compilation and model comments in swift AST?
Looks reasonable, I'm not surprised that regex is a bottleneck here. |
bb6852e
to
a0e1c35
Compare
@swift-ci please smoke test |
a0e1c35
to
e92e66f
Compare
@swift-ci please smoke test |
e92e66f
to
b296013
Compare
@swift-ci please smoke test |
Improve the version/flags extract from interface file by moving away from using Regex and limiting the search to the beginning of the file. Switch away from Regex will give 5-10% improvement in time and instruction counts, and limiting the search lines can save a lot of time if the swiftinterface is large. For example, the extract time for Swift stdlib is 10x faster after the patch. Current strategey for limiting the line to search is by only parsing the first comment block.
b296013
to
8150fb0
Compare
@swift-ci please smoke test |
@swift-ci please smoke test windows platform |
Improve the version/flags extract from interface file by moving away from using Regex and limiting the search to the beginning of the file.
Switch away from Regex will give 5-10% improvement in time and instruction counts, and limiting the search lines can save a lot of time if the swiftinterface is large. For example, the extract time for Swift stdlib is 10x faster after the patch.