Skip to content

Add target-aware process-isolated analyzer scheduling - #6902

Open
dpearson2699 wants to merge 1 commit into
realm:mainfrom
dpearson2699:codex/target-aware-analyzer-upstream
Open

Add target-aware process-isolated analyzer scheduling#6902
dpearson2699 wants to merge 1 commit into
realm:mainfrom
dpearson2699:codex/target-aware-analyzer-upstream

Conversation

@dpearson2699

Copy link
Copy Markdown

Summary

swiftlint analyze currently treats a compiler log as one workload. Large workspaces have no supported way to schedule analyzer work by target or split rules that can safely process requested source subsets.

This pull request adds an opt-in, versioned target-plan mode:

  • --target-plan describes each target, its complete source inventory, compilation database, configured analyzer rules, and requested-source batches.
  • --jobs sets one global process limit.
  • --execution-evidence writes a versioned record of the completed run.
  • Each job runs in a separate SwiftLint child process. The coordinator forwards termination signals, stops descendants after cancellation or failure, and merges successful results in plan order.

Existing swiftlint analyze behavior is unchanged when no target plan is supplied.

Rule safety

Collecting analyzer rules always run as whole-target jobs. Other rules can use batches only when they adopt the package-only batching capability. unused_import is the only initial adopter and accepts at most 32 requested files per job.

A batched worker still receives the complete target source inventory and compilation database. The coordinator validates ordered batch coverage and rejects missing, overlapping, duplicate, extra, or unsupported batches.

Relationship to #6886

Related to #3020.

#6886 serializes analyzer rule scheduling inside the existing invocation. This pull request addresses a different layer: bounded process isolation across explicit targets and safe batches. It does not include the commits from #6886.

Qualification

On the downstream qualification workload, --jobs 1 and --jobs 4 produced the same 304 findings with identical reporter output. The four-job run reduced wall time by 69.3% in that paired measurement. This is one workload measurement, not a general SwiftLint benchmark.

Validation

  • swift test --filter AnalyzerProcessCoordinatorTests (23 tests)
  • swift test --filter CollectingRuleTests (4 tests)
  • swift test --filter LintOrAnalyzeOptionsTests (1 test)
  • swift test --no-parallel (1,110 tests in 375 suites)
  • swift run swiftlint lint --strict (0 violations across 714 files)
  • xcodebuild -scheme swiftlint test -destination 'platform=macOS'
  • make bazel_test (19 test targets)
  • Docker test, left to CI

@SwiftLintBot

Copy link
Copy Markdown
1 Warning
⚠️ Big PR
20 Messages
📖 Building this branch resulted in a binary size of 28943.4 KiB vs 28415.46 KiB when built on main (1% larger).
📖 Linting Aerial with this PR took 0.68 s vs 0.67 s on main (1% slower).
📖 Linting Alamofire with this PR took 0.97 s vs 0.98 s on main (1% faster).
📖 Linting Brave with this PR took 6.28 s vs 6.24 s on main (0% slower).
📖 Linting Brigade with this PR took 18.18 s vs 18.26 s on main (0% faster).
📖 Linting DuckDuckGo with this PR took 29.54 s vs 29.45 s on main (0% slower).
📖 Linting Firefox with this PR took 11.37 s vs 11.37 s on main (0% slower).
📖 Linting Kickstarter with this PR took 7.31 s vs 7.31 s on main (0% slower).
📖 Linting Moya with this PR took 0.38 s vs 0.38 s on main (0% slower).
📖 Linting NetNewsWire with this PR took 2.52 s vs 2.51 s on main (0% slower).
📖 Linting Nimble with this PR took 0.56 s vs 0.56 s on main (0% slower).
📖 Linting PocketCasts with this PR took 7.39 s vs 7.41 s on main (0% faster).
📖 Linting Quick with this PR took 0.36 s vs 0.36 s on main (0% slower).
📖 Linting Realm with this PR took 2.97 s vs 2.99 s on main (0% faster).
📖 Linting Sourcery with this PR took 1.6 s vs 1.64 s on main (2% faster).
📖 Linting Swift with this PR took 4.53 s vs 4.5 s on main (0% slower).
📖 Linting SwiftLintPerformanceTests with this PR took 0.18 s vs 0.18 s on main (0% slower).
📖 Linting VLC with this PR took 1.3 s vs 1.3 s on main (0% slower).
📖 Linting Wire with this PR took 16.33 s vs 16.2 s on main (0% slower).
📖 Linting WordPress with this PR took 10.47 s vs 10.42 s on main (0% slower).

Generated by 🚫 Danger

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