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-9416] Performance problem with generic protocol #51881

Open
swift-ci opened this issue Dec 5, 2018 · 1 comment
Open

[SR-9416] Performance problem with generic protocol #51881

swift-ci opened this issue Dec 5, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Dec 5, 2018

Previous ID SR-9416
Radar rdar://problem/52193387
Original Reporter rsebbe (JIRA User)
Type Bug

Attachment: Download

Environment

Swift 4.2, Xcode 10.1

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 965f7db04ca779e059daf35461f1157a

Issue Description:

Implementing a QuadraticSequence from 2 standard Sequence as a generic protocol creates code that is 30x slower than a direct Sequence/Iterator implementation. Not sure if this is expected or if there are specifics in this code that explain the situation.

I was instructed to run it through SIL tools to inspect code. You'll find the original source code, SIL outout as attachement.

Note that the source code has both the generic protocol approach and the direct implementation which can be switched easily.

Original discussion (forum): https://forums.swift.org/t/performance-of-generic-protocol-extension-30x-slower-swift-4-2/18582

Here's the test code:

func testPerformanceXLoop() { 
    self.measure {
        let indices = XQuadraticIndexRange(rows: 1000, columns: 1000) var sum = 0 for i in indices { sum += i.0+i.1 } print("sum= \(sum)") } 
}
@gottesmm
Copy link
Member

gottesmm commented Dec 5, 2018

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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
Projects
None yet
Development

No branches or pull requests

2 participants