Skip to content
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

Closed
swift-ci opened this issue Jun 30, 2018 · 6 comments
Closed

[SR-8159] Performance regression from 4.1.2 to 4.2 #50691

swift-ci opened this issue Jun 30, 2018 · 6 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression SILOptimizer Area → compiler: SIL optimization passes swift 4.2

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8159
Radar rdar://problem/41684756
Original Reporter sbromberger (JIRA User)
Type Bug
Status Closed
Resolution Cannot Reproduce
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.2Regression, Optimizer
Assignee None
Priority Medium

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.

@jckarter
Copy link
Member

jckarter commented Jul 1, 2018

cc aschwaighofer@apple.com (JIRA User). Can you give us an example of code that's 2x slower in 4.2?

@jckarter
Copy link
Member

jckarter commented Jul 1, 2018

@swift-ci create

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jul 1, 2018

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

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jul 1, 2018

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.

@jckarter
Copy link
Member

jckarter commented Jul 1, 2018

No worries! 330 ms–400 ms is still a worryingly large variance between versions. I think we should still investigate.

@gottesmm
Copy link
Member

gottesmm commented Jul 2, 2018

sbromberger (JIRA User) can you give the data file? Otherwise I can't reproduce.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added SILOptimizer Area → compiler: SIL optimization passes and removed Optimizer labels Nov 3, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression SILOptimizer Area → compiler: SIL optimization passes swift 4.2
Projects
None yet
Development

No branches or pull requests

4 participants