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-14532] 9x regression in compilation time of large classes in Swift 5.4 #56884

Closed
kylebshr opened this issue Apr 27, 2021 · 4 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@kylebshr
Copy link

Previous ID SR-14532
Radar rdar://problem/77217125
Original Reporter @kylebshr
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Swift 5.4 / Xcode 12.5 / MacBook Pro (15-inch, 2019) 2.4 GHz 8-Core Intel Core i9

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

md5: 21019f6eabe58038bcaec8824ea2ecfb

Issue Description:

We have a generated class in our code base with over 3,000 properties, which took a long but somewhat reasonable time to compile in Swift <= 5.3.2. With the release of Swift 5.4 we noticed a huge increase in compile time for our project.

I reduced the repro case to a simple class with 3,000 Int properties, and an init that sets each of those properties, similar to our generated code. Compiling this file takes ~139s with Swift 5.3.2 and ~1278s with Swift 5.4 - nearly a 10x slow down.

➜  huge_class swiftc -v
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Target: x86_64-apple-darwin20.3.0
➜  huge_class swiftc -driver-time-compilation main.swift
===-------------------------------------------------------------------------===
                            Driver Compilation Time
===-------------------------------------------------------------------------===
  Total Execution Time: 0.0002 seconds (139.6951 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   0.0000 ( 60.6%)   0.0000 ( 36.3%)   0.0001 ( 46.2%)  139.4823 ( 99.8%)  {compile: main-9f2913.o <= main.swift}
   0.0000 ( 39.4%)   0.0001 ( 63.7%)   0.0001 ( 53.8%)   0.2128 (  0.2%)  {link: main <= main-9f2913.o}
   0.0001 (100.0%)   0.0001 (100.0%)   0.0002 (100.0%)  139.6951 (100.0%)  Total

➜  huge_class sudo xcode-select -s /Applications/Xcode.app      
Password:
➜  huge_class swiftc -v                                 
Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
Target: x86_64-apple-darwin20.3.0
➜  huge_class swiftc -v
Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
Target: x86_64-apple-darwin20.3.0
➜  huge_class swiftc -driver-time-compilation main.swift  
===-------------------------------------------------------------------------===
                            Driver Compilation Time
===-------------------------------------------------------------------------===
  Total Execution Time: 0.0001 seconds (1278.5112 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   0.0000 ( 74.0%)   0.0000 ( 50.8%)   0.0001 ( 61.1%)  1278.2003 (100.0%)  {compile: main-018ae1.o <= main.swift}
   0.0000 ( 26.0%)   0.0000 ( 49.2%)   0.0000 ( 38.9%)   0.3109 (  0.0%)  {link: main <= main-018ae1.o}
   0.0000 (100.0%)   0.0001 (100.0%)   0.0001 (100.0%)  1278.5112 (100.0%)  Total
@kylebshr
Copy link
Author

I'd like to note that it seems like the slowdown is exponential as you add properties. 100 properties takes 0.24s, 200: 0.45s, 400: 2.01s and 800: 16s.

@rintaro
Copy link
Mannequin

rintaro mannequin commented Apr 27, 2021

@swift-ci create

@rjmccall
Copy link
Member

There's a lot more we could do to speed up this test case, but I fixed the biggest problem in #37328

@kylebshr
Copy link
Author

Awesome, thank you @rjmccall!

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

No branches or pull requests

2 participants