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-11736] Type checking is unacceptably slow, and got significantly worse with Xcode 11 #54143

Open
swift-ci opened this issue Nov 8, 2019 · 1 comment
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself performance type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Nov 8, 2019

Previous ID SR-11736
Radar None
Original Reporter mluisbrown (JIRA User)
Type Bug

Attachment: Download

Environment

macOS Catalina 10.15.1

Xcode 11.1

MacBook Pro 15 (2018), 2.9 GHz 6-Core Intel Core i9, 32GB of RAM

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, TypeChecker
Assignee @harlanhaskins
Priority Medium

md5: 255a6b937472bfd319b643906829143f

Issue Description:

Xcode 11 / Swift 5.1 introduced significant increases in the time taken to type check Swift code. Even quite simple expressions can now take longer than 100ms.

This problem was first raised on twitter by my colleague David Rodrigues: https://twitter.com/dmcrodrigues/status/1192136776212713472

The example project attached (Type Checking Issues.zip) has a number of examples taken from a larger project where the number of "time to type-check" warnings has skyrocketed from 2 or 3 to 40 or 50 since we migrated to Xcode 11.

An example warning output is this

As you move the selection through these warnings, Xcode also seems to be continuously re-compiling the code (even though nothing has changed) and regenerating new type check time warnings as shown in this video:

XcodeTypeCheck.mov

Two of the worst examples are the following:

import UIKit

class SomeViewController: UIViewController {

    private func updatePreferredContentSize() {
        preferredContentSize = CGSize(
            width: view.bounds.width,
            height: (view.subviews.map { $0.frame.height }.reduce(+) ?? 0) + 20.0
        )
    }
}

and this one:

import Foundation

extension Int {

    public var days: TimeInterval {
        return TimeInterval(self) * 24.hours
    }

    public var hours: TimeInterval {
        return TimeInterval(self) * 60.minutes
    }

    public var minutes: TimeInterval {
        return TimeInterval(self) * 60.seconds
    }

    public var seconds: TimeInterval {
        return TimeInterval(self)
    }
}

These type checker performance degradations have also significantly increased overall build times, which have increased between 15-20% since we moved to Xcode 11.

Note: building the project using xcodebuild -configuration Debug -sdk iphonesimulator the type check times are not as bad, but still there.

@theblixguy
Copy link
Collaborator

I think this includes time spent on other things as well (such as deserializing) and not just purely type checking, so it's not accurate or reliable enough. But still, I would be good to track down where that extra time is being spent and why.

@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 performance type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants