Skip to content

[sourcekitd] Replace a slow std::regex with custom parsing #5350

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
Oct 18, 2016

Conversation

benlangmuir
Copy link
Contributor

This gave a roughly 40-45% improvement in sourcekitd's incremental
syntax-only parse time in files with a lot of doc comments (test case
was ~6000 lines, with ~780 lines being doc comments). This is on the
critical path for every edit.

While there were a few smaller improvements we could have made to the
original code, ultimately std::regex is slow, and it was better to just
use a custom parser for these simple patterns.

rdar://problem/28809397

This gave a roughly 40-45% improvement in sourcekitd's incremental
syntax-only parse time in files with a lot of doc comments (test case
was ~6000 lines, with ~780 lines being doc comments). This is on the
critical path for every edit.

While there were a few smaller improvements we could have made to the
original code, ultimately std::regex is slow, and it was better to just
use a custom parser for these simple patterns.

rdar://problem/28809397
@benlangmuir
Copy link
Contributor Author

@swift-ci Please smoke test

@benlangmuir
Copy link
Contributor Author

@bitjammer could you review this for me?

@bitjammer
Copy link
Contributor

Awesome. Looking.

@bitjammer
Copy link
Contributor

Looks good to me! I wonder if, at some point, we should take advantage of the parsed structure of the doc comment, provided it's not parsed over and over again and we wire up source ranges, but that's for another day.

Got rid of a regex! Now we have two fewer problems!

@benlangmuir benlangmuir merged commit 569687e into swiftlang:master Oct 18, 2016
@benlangmuir benlangmuir deleted the slow-regex branch October 18, 2016 19:45
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