-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Faster tokens resolving in syntaxmap #2916
Faster tokens resolving in syntaxmap #2916
Conversation
Wow. It seems that lazy prefix suffix combination behaves strangely in Swift 5.0/Xcode 10 |
3162937
to
d36994b
Compare
@jpsim any ideas why this could fail on Swift 5.0? :( |
d36994b
to
d40b7d9
Compare
Generated by 🚫 Danger |
364cbdf
to
743abea
Compare
@marcelofabri updated. Works without even checking for Swift version. Wordpress["new": 0.5954486219999982, "old": 2.635693253000027] Swift["new": 0.475975328999993, "old": 3.679700348999993] |
Thanks again for your continued investments in SwiftLint performance @PaulTaykalo. However, I want to caution against over-optimizing parts of SwiftLint's runtime that already have a negligible impact on total lint time. In this case we're significantly increasing the complexity of this code, but because finding token indices is such a small part of the total work spent during linting, there ends up being no measurable improvement on linting overall. Here's what I measured before & after this change on a large project (~450k lines of Swift):
Maybe if we extracted the binary search logic into an extension on I don't want this to discourage your interest in making SwiftLint faster though! I'd recommend profiling complete lint runs to get a better sense of performance hotspots and optimize those for the best value. |
It's not that I'm not doing that :) Technically, this part above looks the same as the previous solution, but instead Will it work if I put the binary search part in the extension with comments and make it more abstract? Most of the time is spent on the regexes There's |
Thanks for the reply.
Yes, specifically I think a reusable binary search function on |
4896721
to
73d26bf
Compare
@jpsim So, how about this one? |
82b224f
to
f343f84
Compare
Thanks @PaulTaykalo, I've made a few small edits and will merge when CI passes. |
There's an issue with OSScheck it didn't run properly, I think it's fall out from running on MacStadium. I'm fixing it now,. |
Validating OSSCheck fixes here: #2945 |
f343f84
to
ea777be
Compare
When the request is asked which tokens are have in an intersection, the previous solution was searching for first Index (linearly) and then filtered everything that was coming after that index using
intersect function
The updated solution will search for the first token index using
binary search
Speedup
While this is only one function was updated, the next options were considered:
prefix:wihle
instead of filteringprefix:wihle
instead of filteringThe speedup highly depends on the file sizes. The bigger/longer files the bigger win is
Benchmark
Kickstarter
Swift
WordPress
Testing code
This code was tested with these parts of code (in Release build)