Skip to content

Conversation

@Iron-Ham
Copy link
Contributor

@Iron-Ham Iron-Ham commented Dec 29, 2025

Summary

Depends on #354

Processes multiple directories concurrently using Taskgroup, where each directory runs its full formatting pipeline independently (SwiftFormat → SwiftLint autocorrect → SwiftLint lint).

Key changes:

  • Updates swift-argument-parser to 1.7.0 for AsyncParsableCommand support.
  • AirbnbSwiftFormatTool is updated to use AsyncParsableCommand.
  • Updates tests for async execution.
  • Updates macOS 10 minimum version to 10.15 for Swift Concurrency support.

Reasoning

Hypothesis

For projects of a larger size than this one, the parallel approach would be significantly faster – especially for projects with many modules. Projects with few folders / files would still see higher performance from what's in master.

Experiment

Benchmark 5 runs of master vs this branch against my IronUI project.

Results
Configuration Run 1 Run 2 Run 3 Run 4 Run 5 Avg
Parallel: 3 dirs (Sources, Apps, Tests) 0.657s 0.574s 0.567s 0.573s 0.568s ~0.59s
Parallel: 21 dirs (per-module) 0.638s 0.573s 0.568s 0.570s 0.569s ~0.58s
Master: 3 dirs 0.574s ~0.57s ~0.57s ~0.57s ~0.57s ~0.57s
Conclusion

No significant difference. I would have to imagine that both SwiftFormat and SwiftLint are both highly parallel internally, regardless of what directories are passed to them as arguments. Probably should've looked into that before committing to this, but hey – learned something, I guess.

@Iron-Ham Iron-Ham marked this pull request as draft December 29, 2025 20:31
@Iron-Ham Iron-Ham force-pushed the feat/parallel-directory-formatting branch from 71d9ca2 to 8afc99b Compare December 29, 2025 20:34
Process multiple directories concurrently using Swift's TaskGroup,
where each directory runs its full formatting pipeline independently:
SwiftFormat → SwiftLint autocorrect → SwiftLint lint.

## Changes

- Convert AirbnbSwiftFormatTool to AsyncParsableCommand
- Add Command.runAsync() using Task.detached for true parallelism
- Add DirectoryResult struct for per-directory exit code aggregation
- Use withTaskGroup (not withThrowingTaskGroup) to process ALL directories
  even when some fail, giving users complete feedback
- Add directory context to error messages (e.g., "Lint failures in: DirA, DirC")
- Update tests to support async execution
- Add tests for mixed success/failure scenarios across directories
- Update ArgumentParser to 1.7.0 for AsyncParsableCommand support
- Update minimum macOS to 10.15 for Swift Concurrency

## Benchmark Results (IronUI - 141 files, 3 directories)

| Version    | Wall-clock Time | Speedup      |
|------------|-----------------|--------------|
| Sequential | 1.494s          | baseline     |
| Parallel   | 0.686s          | 2.18x faster |
@Iron-Ham Iron-Ham force-pushed the feat/parallel-directory-formatting branch from 8afc99b to d6d3440 Compare December 29, 2025 20:38
@Iron-Ham Iron-Ham marked this pull request as ready for review December 29, 2025 20:40
@Iron-Ham Iron-Ham marked this pull request as draft December 29, 2025 20:58
@Iron-Ham Iron-Ham closed this Dec 29, 2025
@calda
Copy link
Member

calda commented Dec 30, 2025

Thanks for giving this a go! Appreciate the investigation.

I would have to imagine that both SwiftFormat and SwiftLint are both highly parallel internally,

Yeah, SwiftFormat spawns as many parallel threads as possible, so it makes sense that we've already achieved max parallelism.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants