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
[SR-8159] Performance regression from 4.1.2 to 4.2 #50691
Comments
cc aschwaighofer@apple.com (JIRA User). Can you give us an example of code that's 2x slower in 4.2? |
@swift-ci create |
Comment by Seth Bromberger (JIRA) Sure. If you build https://github.com/sbromberger/SwiftGraphs, and then use it in this code: import Dispatch
import Foundation
import SwiftGraphs
let ms = 1_000_000.0
extension Double {
func truncate(places: Int) -> Double {
return Double(floor(pow(10.0, Double(places)) * self) / pow(10.0, Double(places)))
}
}
if #available(macOS 10.13, *) {
var start = DispatchTime.now()
let g = Graph<UInt32>(fromBinaryFile: FileManager.default.homeDirectoryForCurrentUser.path + "/dev/swift/SwiftGraphs/data/indptrvecs-4m-30m.0based.bin")
var end = DispatchTime.now()
print("graph load took \(Double(end.uptimeNanoseconds - start.uptimeNanoseconds) / 1_000_000.0) ms")
print(g)
exit(0)
} with the binary file that represents a graph with 4m vertices and 30m edges, you will get the following times: seth@schroeder:~/dev/swift/SGExe$ .build/release/SwiftGraphs
graph load took 676.161681 ms
{4000000, 30000000} Graph
seth@schroeder:~/dev/swift/SGExe$ swift --version
Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
Target: x86_64-apple-darwin17.6.0 but: seth@schroeder:~/dev/swift/SGExe$ ./.build/release/SwiftGraphs
graph load took 330.222808 ms
{4000000, 30000000} Graph
seth@schroeder:~/dev/swift/SGExe$ swift --version
Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0 |
Comment by Seth Bromberger (JIRA) On second examination, close this out for now. I may be hitting disk caching issues. Successive file loads with 4.2 are in the 400-480ms range, which is probably close enough given the variance. Sorry for the noise. |
No worries! 330 ms–400 ms is still a worryingly large variance between versions. I think we should still investigate. |
sbromberger (JIRA User) can you give the data file? Otherwise I can't reproduce. |
Additional Detail from JIRA
md5: 6976d8f5b9d2e4f21f775416a8e0facc
Issue Description:
I apologize for not having a MWE of this.
`@inlinable` and `@usableFromInline` are new features in 4.2, and these annotations provide the necessary speedups for cross-module optimization. However, in the case where they are NOT used, there is actually a large (2x) performance regression from the same code in 4.1.2.
Relevant forum post is at https://forums.swift.org/t/performance-issues-when-using-a-library-vs-including-in-code/14117.
The text was updated successfully, but these errors were encountered: