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-4430] Extremely slow Dictionary literal compilation in Swift 3.1 #47007

Open
swift-ci opened this issue Mar 30, 2017 · 0 comments
Open

[SR-4430] Extremely slow Dictionary literal compilation in Swift 3.1 #47007

swift-ci opened this issue Mar 30, 2017 · 0 comments

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Mar 30, 2017

Previous ID SR-4430
Radar None
Original Reporter fotidim (JIRA User)
Type Bug
Environment

Swift 3.1
Xcode 10.3
MacOS 10.12.4 (16E195)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 3.1Regression, Performance, TypeChecker
Assignee None
Priority Medium

md5: dbda91eab7f9b5464c8e7ffbfdeb08b5

Issue Description:

Starting with Xcode 10.3 and Swift 3.1 we have an extremely huge increase in our compilation time. We tracked down the issue to be compiling Dictionary literals that have multiple nested levels.

Example:

let dataRemoveCart  = [
            TrackingService.GoogleValuesKey: [
                
                "time": Date().timeIntervalSince1970 ,
                "name": cartItem.nameShop ?? "" ,
                "price": formatPriceForTracking(cartItem.grossRetailPrice),
                "category": cartItem.nameCategoryTag ?? "",
                "variant": cartItem.nameColor,
                "qantity": "1",
                "productCampaign": cartItem.campaignCode,
                "productCategory": cartItem.nameCategoryTag ?? "",
                "productGender": "",
                "productName": cartItem.name ?? "",
                "productPrice": formatPriceForTracking(cartItem.grossRetailPrice),
                "productDiscount": formatPriceForTracking(discount),
                "productQty": "1",
                "productBrandName": cartItem.brandName ?? "" ,
                "productSeason": "",
                "productSku": cartItem.configSku,
                "productBrandCode": productBrandCode,
                "productSpecialPrice": formatPriceForTracking(cartItem.suggestedRetailPrice),
                
                "ecommerce": [
                    "currencyCode": Config.currentConfig.currencyCode,
                    "remove": [
                        "products": [[
                            "name": cartItem.nameShop ?? "" ,
                            "id": cartItem.configSku ?? "",
                            "price": formatPriceForTracking(cartItem.grossRetailPrice),
                            "brand": cartItem.brandName ?? "",
                            "category": cartItem.nameCategoryTag ?? "",
                            "variant": cartItem.nameColor,
                            "quantity": "1"
                            ]]
                    ]
                ],
            ]
        ]

Some observations:

  • The above code compiles in almost 3 minutes in Xcode 10.3 and in 27 seconds in Xcode 10.2.1. That is a 650% increase.

  • Adding top level keys to a 2 level nested dictionary slows compilation down

  • Defining types and not having them inferred speeds up the compiler only if the dictionary literal is not too complex, not in the case above.

  • If I change a single line in a totally unrelated file under the same module (incremental build) the Dictionary is compiled again. This is so annoying that you can barely work with Xcode anymore.

@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
Projects
None yet
Development

No branches or pull requests

1 participant