Skip to content

SPM tests are creating thousands of processes, blocking on system resources for extended periods. #9245

@kcieplak

Description

@kcieplak

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

Tests, specifically swift-testing based tests that spawn a "swift build|test|run", cause hundreds if not thousands of subprocesses executing at the same time. This causes tests to take a really long time to complete, and in some cases not output anything to stdout/stderr for hours at a time as every process is competing for CPU and other resources. There are some out of band pipelines we run that have timeouts when there is no activity, and we are hitting them.

Suite ArchiveSourceTests passed after 9118.433 seconds

For example during a test run of just swift-testing tests, at a random point, thereafter are 278 invocations of "swift-package" running.

ps | grep swift-package | wc -l
278

Under the covers swift-testing uses swift concurrency to execute parallel tests, this means that all tests are added as tasks to a group, and execute using job threads. See attached concurrency details.

concurrency-inspect-x86_64-2.txt

There are 6537 tasks, and a thread execution pool of 16.

SPM stests where swift-* is invoked are very expensive causing many other subprocesses to be started.
Further to this many tests are argument type tests with a matrix across debug/release and native/swiftbuild/Xcode, creating even more tests that run in parallel.

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

No response

Swift Package Manager version/commit hash

No response

Swift & OS version (output of swift --version ; uname -a)

No response

Metadata

Metadata

Assignees

Labels

bugperformancePerformance optimizations and improvements

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions