Skip to content

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Nov 4, 2025

This PR adds an upper bound, NCORES * 2, on the number of test cases we run in parallel. Depending on the exact nature of your tests, this can significantly reduce the maximum amount of dirty memory needed, but does not generally impact execution time.

As an example, Swift Testing's own tests go from > 300MB max memory usage to around 60MB.

You can configure a different upper bound by setting the "SWT_EXPERIMENTAL_MAXIMUM_PARALLELIZATION_WIDTH" environment variable (look, naming is hard okay?)

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR adds an upper bound, `NCORES * 2`, on the number of test cases we run in
parallel. Depending on the exact nature of your tests, this can significantly
reduce the maximum amount of dirty memory needed, but does not generally impact
execution time.

You can configure a different upper bound by setting the
`"SWT_EXPERIMENTAL_MAXIMUM_PARALLELIZATION_WIDTH"` environment variable (look,
naming is hard okay?)
@grynspan grynspan added this to the Swift 6.x (main) milestone Nov 4, 2025
@grynspan grynspan self-assigned this Nov 4, 2025
@grynspan grynspan added enhancement New feature or request tools integration 🛠️ Integration of swift-testing into tools/IDEs performance 🏎️ Performance issues labels Nov 4, 2025
@grynspan grynspan requested a review from stmontgomery November 7, 2025 21:07
private var _continuations = [CheckedContinuation<Void, Never>]()

init(maximumWidth: Int = 1) {
self.maximumWidth = maximumWidth
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we precondition on maximumWidth > 0 here? I think run blocks forever if the user sets a width of zero, so it doesn't really make sense to allow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eeeeh okay.

@jerryjrchen jerryjrchen self-requested a review November 7, 2025 22:52
Copy link
Contributor

@jerryjrchen jerryjrchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. The only concern I have is over the naming for Serializer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request performance 🏎️ Performance issues tools integration 🛠️ Integration of swift-testing into tools/IDEs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants