-
Notifications
You must be signed in to change notification settings - Fork 248
Make Rule nameCache thread safe #242
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
Make Rule nameCache thread safe #242
Conversation
Alternatively I'm not sure how much time this optimization saved but we could attempt to remove it instead if that's not too costly. |
I'm also happy to try some other variants of this optimization such as not splitting on every |
Previously, we had the rule cache but weren't actually updating it, and populating the cache yielded a significant performance improvement (13fd74d#diff-850e7af4319cd80f84d3ffdc821387f341b7cc167465cbb3e3b20d4e9b7fc142) when @dylansturg fixed it. I don't recall, however, where the time profile mostly showed we were getting hit—it very well could have been the repeated heap allocations for the array result of If you'd like to explore a couple options and see what the time profiles look like, that'd be great—but I'm also happy to merge this as-is and do that exploration later. WDYT? |
I did a few tests here (not super scientifically):
Then I tried some variants using indexes, it's quite cumbersome especially considering not all strings here contain a let name = String(describing: self)
guard let dotIndex = name.lastIndex(of: ".") else {
nameCache[identifier] = name
return name
}
let splitIndex = name.index(after: dotIndex)
return String(name[splitIndex...])
And finally my favorite: with this change + the So overall I think there's a bit of a hit in this in the non-parallel case, but between other string options it does seem to be a fine version of it. |
Sorry for the delay! Let's merge this in so it's not blocking the other parallel change, and if we want to do some more rigorous testing and streamline this later, we have more flexibility to do that. But those numbers look good already. |
Thanks! |
* Display a warning for users if an input directory does not exist. * Clarify that a path should lead to a directory, not a Swift file. * Update Sources/swift-doc/Subcommands/Generate.swift * Add changelog entry for swiftlang#242 Co-authored-by: Mattt <[email protected]>
No description provided.