Description
Describe the bug
Since Swift 5.6 and continuing through the present, when a function containing more than ~100-150 independent uses of await
is compiled in Xcode, the runtime for the swift-frontend invocation which includes the appropriate file increases extremely rapidly for each additional use of await
- for a method with ~200 await
s, the build time reached over 20 minutes.
The method exhibiting this behavior in my direct experience was a test method in an XCTestCase
, belonging to a test target in an SPM package. I have not had a chance to verify whether the problem is specific to test methods, nor to narrow down a repro case. From the investigations I have had a chance to make, the problem appears to be during the coroutine splitting pass and seems related to a considerable amount of repeated copying of instances of an LLVM container type.
Moving the implementation of the method in question into three private methods invoked sequentially was sufficient to reduce the build time to a bit under 20 seconds. I have not yet been able to look into it further.
Steps To Reproduce
Steps to reproduce the behavior:
- N/A
Expected behavior
Reasonable build time.
Environment (please fill out the following information)
- OS: macOS Monterey
- Xcode Version/Tag/Branch: Xcode 14.0 - 14.1 and some versions of 13.x.