Skip to content

Commit 7ba9d48

Browse files
[Planning] Avoid batching compile job twice
When using incremental build, the FirstWaveComputer has already batched all the compile jobs. `planStandardCompile()` can just reuse the batch job information from incremental state to construct the jobs.
1 parent 9064163 commit 7ba9d48

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Sources/SwiftDriver/Jobs/Planning.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,17 @@ extension Driver {
9090
incrementalCompilationState = nil
9191
}
9292

93-
return try (
94-
// For compatibility with swiftpm, the driver produces batched jobs
95-
// for every job, even when run in incremental mode, so that all jobs
96-
// can be returned from `planBuild`.
97-
// But in that case, don't emit lifecycle messages.
98-
formBatchedJobs(jobsInPhases.allJobs,
99-
showJobLifecycle: showJobLifecycle && incrementalCompilationState == nil,
100-
jobCreatingPch: jobsInPhases.allJobs.first(where: {$0.kind == .generatePCH})),
101-
incrementalCompilationState
102-
)
93+
let batchedJobs: [Job]
94+
// If the jobs are batched during the incremental build, reuse the computation rather than computing the batches again.
95+
if let incrementalState = incrementalCompilationState {
96+
batchedJobs = incrementalState.mandatoryJobsInOrder + incrementalState.jobsAfterCompiles
97+
} else {
98+
batchedJobs = try formBatchedJobs(jobsInPhases.allJobs,
99+
showJobLifecycle: showJobLifecycle,
100+
jobCreatingPch: jobsInPhases.allJobs.first(where: {$0.kind == .generatePCH}))
101+
}
102+
103+
return (batchedJobs, incrementalCompilationState)
103104
}
104105

105106
/// If performing an explicit module build, compute an inter-module dependency graph.

0 commit comments

Comments
 (0)