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
Build performance issue of swift-testing #2414
Comments
Thanks for opening this issue. swift-testing does not support Swift 5.9, and Swift 5.10 support is temporary, so we'd want to see what your results look like in Swift 5.11 (i.e. using a main development toolchain.) Is it possible the times you're seeing include the time to build the testing library itself? XCTest is built into Xcode and the Swift toolchain, so it doesn't need to be built with your package or test target; the testing library is an experimental Swift package and must be built from source along with swift-syntax, and those packages can take a noticeable amount of time to build before your package can start building. If the times above do not include the time to build swift-syntax or swift-testing, then I think we need to confirm the issue persists in Swift 5.11. Since we don't have access to your test code, we can't reproduce the results you're seeing locally and are not able to profile the build process to see where time is being lost. Are you able to share access to your repository? If not, are you able to provide a reduced test function that is significantly slower to build with swift-testing than with XCTest? |
Yes, I highly suspect it too.
Is there a Xcode Beta version available for us to try it? (I do not know whether the latest public beta version - Xcode 15.2 Beta is capable of it.) Another thing I'd like to complain is that I can't run a single test with Xcode currently. I can only choose to run final class AllTests: XCTestCase {
func testAll() async {
await XCTestScaffold.runAllTests(hostedBy: self)
}
} Or we can only use the nightly Swift Toolchain via Anyway I'll give it a try with the nightly toolchain locally and report back the result later. |
swift-testing is an experimental open-source package. If you'd like to see Apple add support for it to Xcode, I would encourage you to file feedback with them. 😁
|
Does this only supported on macOS or I have missed something else here? I have tried it with the latest Swift nightly toolchain(2023-12-21-a) with Ubuntu 22.04. Still can't find Note On my test branch for Swift 5.11, I have commented the following line on my Pacakge.swift file as I thought they are no longer needed on Swift 5.11 toolchain
Update
I thought swift-testing is already bundled into the toolchain just like XCTest. I added the dependency back and then have a successful build on 5.11. But the test release build time issue still remains the same probably due to the build time on swift-testing and swift-syntax. |
Time statistics on my local machine > time swift test --enable-experimental-swift-testing
swift test --enable-experimental-swift-testing 171.38s user 9.40s system 238% cpu 1:15.85 total
> time swift test -c release --enable-experimental-swift-testing
swift test -c release --enable-experimental-swift-testing 527.19s user 10.92s system 150% cpu 5:56.43 total Note
The SwiftSyntax issue may exist for all macro package. But it is especially fatal for testing frameworks like swift-testing. |
swift-testing is not built into any toolchains. It is an experimental package. Sorry if my previous comments were confusing! If you're seeing most of the time spent in swift-syntax, we can send this issue over to that repository and have our colleagues look at it. I don't know what's in Empty.swift that would cause long build times. |
The underlying issue here is that swift-syntax needs to be built to use the macros in swift-testing and that release builds of swift-syntax take a while (#1194). |
Tracked in Apple’s issue tracker as rdar://120672412 |
The time has greatly improved with the new macOS 14 runner + Xcode 15.3 + Swift 5.10 It may be a combination of the upgrade of the GitHub macOS 14 image to a 4-core CPU and Swift-syntax optimization.
Although there is still a gap with the original XCTest branch, the current time result has fallen back to our acceptable range. |
Description
Before migrating to use "swift-testing", one of my package's average CI time is as the following
Most the job will do its job less in 1 min.
However after fully migrate all my test case to swift-testing, the CI time exploded especially with Release configuration.
Expected behavior
It is expected the build time will increase due to the usage of swift macro. And 2~3 min looks normal and acceptable.
Increased to more than 10 min is definitely means something is wrong here IMO.
And my question is the following:
Actual behavior
Steps to reproduce
No response
swift-testing version/commit hash
swift-testing 0.2
Swift & OS version (output of
swift --version ; uname -a
)Swift 5.9.2
The text was updated successfully, but these errors were encountered: