Skip to content

Commit 66b8f35

Browse files
authored
Merge pull request #81569 from artemcm/NoBatchForYou
[Legacy Driver] Obsolete and remove batch compilation mode from the legacy driver
2 parents 61ab279 + 10cd7ba commit 66b8f35

32 files changed

+35
-1526
lines changed

include/swift/AST/DiagnosticsDriver.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ WARNING(warn_opt_remark_disabled, none,
114114
"requires a single compiler invocation: consider enabling the "
115115
"-whole-module-optimization flag", ())
116116

117-
WARNING(warn_ignoring_batch_mode,none,
118-
"ignoring '-enable-batch-mode' because '%0' was also specified", (StringRef))
119-
120117
WARNING(warn_ignoring_wmo, none,
121118
"ignoring '-wmo' because '-dump-ast' was also specified", ())
122119

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ WARNING(warning_locale_path_not_found,none,
126126
"translation is disabled", (StringRef))
127127
WARNING(warning_cannot_find_locale_file,none,
128128
"cannot find translations for '%0' at '%1': no such file", (StringRef, StringRef))
129-
WARNING(warning_cannot_multithread_batch_mode,none,
130-
"ignoring -num-threads argument; cannot multithread batch mode", ())
131129
ERROR(error_cannot_explicit_interface_build_in_mode,none,
132130
"'-explicit-interface-module-build' only supported when building a module from interface ('-compile-module-from-interface' or '-typecheck-module-from-interface')'", ())
133131
ERROR(error_unsupported_option_argument,none,

include/swift/Driver/Compilation.h

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ class Compilation {
108108
DiagnosticEngine &Diags;
109109

110110
/// The ToolChain this Compilation was built with, that it may reuse to build
111-
/// subsequent BatchJobs.
111+
/// subsequent Jobs.
112112
const ToolChain &TheToolChain;
113113

114114
/// The OutputInfo, which the Compilation stores a copy of upon
115-
/// construction, and which it may use to build subsequent batch
115+
/// construction, and which it may use to build subsequent
116116
/// jobs itself.
117117
OutputInfo TheOutputInfo;
118118

@@ -167,22 +167,6 @@ class Compilation {
167167
/// even if they returned an error status.
168168
bool ContinueBuildingAfterErrors = false;
169169

170-
/// Indicates whether groups of parallel frontend jobs should be merged
171-
/// together and run in composite "batch jobs" when possible, to reduce
172-
/// redundant work.
173-
const bool EnableBatchMode;
174-
175-
/// Provides a randomization seed to batch-mode partitioning, for debugging.
176-
const unsigned BatchSeed;
177-
178-
/// Overrides parallelism level and \c BatchSizeLimit, sets exact
179-
/// count of batches, if in batch-mode.
180-
const std::optional<unsigned> BatchCount;
181-
182-
/// Overrides maximum batch size, if in batch-mode and not overridden
183-
/// by \c BatchCount.
184-
const std::optional<unsigned> BatchSizeLimit;
185-
186170
/// True if temporary files should not be deleted.
187171
const bool SaveTemps;
188172

@@ -244,10 +228,6 @@ class Compilation {
244228
std::unique_ptr<llvm::opt::DerivedArgList> TranslatedArgs,
245229
InputFileList InputsWithTypes,
246230
size_t FilelistThreshold,
247-
bool EnableBatchMode = false,
248-
unsigned BatchSeed = 0,
249-
std::optional<unsigned> BatchCount = std::nullopt,
250-
std::optional<unsigned> BatchSizeLimit = std::nullopt,
251231
bool SaveTemps = false,
252232
bool ShowDriverTimeCompilation = false,
253233
std::unique_ptr<UnifiedStatsReporter> Stats = nullptr,
@@ -302,10 +282,6 @@ class Compilation {
302282
return DerivedOutputFileMap;
303283
}
304284

305-
bool getBatchModeEnabled() const {
306-
return EnableBatchMode;
307-
}
308-
309285
bool getContinueBuildingAfterErrors() const {
310286
return ContinueBuildingAfterErrors;
311287
}
@@ -352,14 +328,6 @@ class Compilation {
352328
return Level;
353329
}
354330

355-
unsigned getBatchSeed() const {
356-
return BatchSeed;
357-
}
358-
359-
std::optional<unsigned> getBatchCount() const { return BatchCount; }
360-
361-
std::optional<unsigned> getBatchSizeLimit() const { return BatchSizeLimit; }
362-
363331
/// Requests the path to a file containing all input source files. This can
364332
/// be shared across jobs.
365333
///
@@ -399,7 +367,7 @@ class Compilation {
399367
/// Unfortunately the success or failure of a Swift compilation is currently
400368
/// sensitive to the order in which files are processed, at least in terms of
401369
/// the order of processing extensions (and likely other ways we haven't
402-
/// discovered yet). So long as this is true, we need to make sure any batch
370+
/// discovered yet). So long as this is true, we need to make sure any
403371
/// job we build names its inputs in an order that's a subsequence of the
404372
/// sequence of inputs the driver was initially invoked with.
405373
///

include/swift/Driver/Driver.h

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,6 @@ class OutputInfo {
6767
/// A compilation using a single frontend invocation without -primary-file.
6868
SingleCompile,
6969

70-
/// A single process that batches together multiple StandardCompile Jobs.
71-
///
72-
/// Note: this is a transient value to use _only_ for the individual
73-
/// BatchJobs that are the temporary containers for multiple StandardCompile
74-
/// Jobs built by ToolChain::constructBatchJob.
75-
///
76-
/// In particular, the driver treats a batch-mode-enabled Compilation as
77-
/// having OutputInfo::CompilerMode == StandardCompile, with the
78-
/// Compilation::BatchModeEnabled flag set to true, _not_ as a
79-
/// BatchModeCompile Compilation. The top-level OutputInfo::CompilerMode for
80-
/// a Compilation should never be BatchModeCompile.
81-
BatchModeCompile,
82-
8370
/// Invoke the REPL
8471
REPL,
8572

@@ -171,7 +158,7 @@ class Driver {
171158
/// allowable OutputInfo::Mode values.
172159
enum class DriverKind {
173160
Interactive, // swift
174-
Batch, // swiftc
161+
Standard, // swiftc
175162
SILOpt, // sil-opt
176163
SILFuncExtractor,// sil-func-extractor
177164
SILNM, // sil-nm
@@ -313,14 +300,12 @@ class Driver {
313300
///
314301
/// \param TC The current tool chain.
315302
/// \param Args The input arguments.
316-
/// \param BatchMode Whether the driver has been explicitly or implicitly
317-
/// instructed to use batch mode.
318303
/// \param Inputs The inputs to the driver.
319304
/// \param[out] OI The OutputInfo in which to store the resulting output
320305
/// information.
321306
void buildOutputInfo(const ToolChain &TC,
322307
const llvm::opt::DerivedArgList &Args,
323-
const bool BatchMode, const InputFileList &Inputs,
308+
const InputFileList &Inputs,
324309
OutputInfo &OI) const;
325310

326311
/// Construct the list of Actions to perform for the given arguments,
@@ -472,11 +457,8 @@ class Driver {
472457
/// there is an actual conflict.
473458
/// \param Args The input arguments.
474459
/// \param Inputs The inputs to the driver.
475-
/// \param BatchModeOut An out-parameter flag that indicates whether to
476-
/// batch the jobs of the resulting \c Mode::StandardCompile compilation.
477460
OutputInfo::Mode computeCompilerMode(const llvm::opt::DerivedArgList &Args,
478-
const InputFileList &Inputs,
479-
bool &BatchModeOut) const;
461+
const InputFileList &Inputs) const;
480462
};
481463

482464
} // end namespace driver

include/swift/Driver/Job.h

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,7 @@ class Job {
389389
StringRef Terminator = "\n") const;
390390

391391
/// Call the provided Callback with any Jobs (and their possibly-quasi-PIDs)
392-
/// contained within this Job; if this job is not a BatchJob, just pass \c
393-
/// this and the provided \p OSPid back to the Callback.
392+
/// contained within this Job;
394393
virtual void forEachContainedJobAndPID(
395394
llvm::sys::procid_t OSPid,
396395
llvm::function_ref<void(const Job *, Job::PID)> Callback) const {
@@ -411,51 +410,6 @@ class Job {
411410
StringRef getFirstSwiftPrimaryInput() const;
412411
};
413412

414-
/// A BatchJob comprises a _set_ of jobs, each of which is sufficiently similar
415-
/// to the others that the whole set can be combined into a single subprocess
416-
/// (and thus run potentially more-efficiently than running each Job in the set
417-
/// individually).
418-
///
419-
/// Not all Jobs can be combined into a BatchJob: at present, only those Jobs
420-
/// that come from CompileJobActions, and which otherwise have the exact same
421-
/// input file list and arguments as one another, aside from their primary-file.
422-
/// See ToolChain::jobsAreBatchCombinable for details.
423-
424-
class BatchJob : public Job {
425-
426-
/// The set of constituents making up the batch.
427-
const SmallVector<const Job *, 4> CombinedJobs;
428-
429-
/// A negative number to use as the base value for assigning quasi-PID to Jobs
430-
/// in the \c CombinedJobs array. Quasi-PIDs count _down_ from this value.
431-
const Job::PID QuasiPIDBase;
432-
433-
public:
434-
BatchJob(const JobAction &Source, SmallVectorImpl<const Job *> &&Inputs,
435-
std::unique_ptr<CommandOutput> Output, const char *Executable,
436-
llvm::opt::ArgStringList Arguments,
437-
EnvironmentVector ExtraEnvironment, std::vector<FilelistInfo> Infos,
438-
ArrayRef<const Job *> Combined, Job::PID &NextQuasiPID,
439-
std::optional<ResponseFileInfo> ResponseFile = std::nullopt);
440-
441-
ArrayRef<const Job*> getCombinedJobs() const {
442-
return CombinedJobs;
443-
}
444-
445-
/// Call the provided callback for each Job in the batch, passing the
446-
/// corresponding quasi-PID with each Job.
447-
void forEachContainedJobAndPID(
448-
llvm::sys::procid_t OSPid,
449-
llvm::function_ref<void(const Job *, Job::PID)> Callback) const override {
450-
Job::PID QPid = QuasiPIDBase;
451-
assert(QPid < 0);
452-
for (auto const *J : CombinedJobs) {
453-
assert(QPid != std::numeric_limits<Job::PID>::min());
454-
Callback(J, QPid--);
455-
}
456-
}
457-
};
458-
459413
} // end namespace driver
460414
} // end namespace swift
461415

include/swift/Driver/ToolChain.h

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class ToolChain {
9898
bool shouldUseSupplementaryOutputFileMapInFrontendInvocation() const;
9999

100100
/// Reify the existing behavior that SingleCompile compile actions do not
101-
/// filter, but batch-mode and single-file compilations do. Some clients are
101+
/// filter, single-file compilations do. Some clients are
102102
/// relying on this (i.e., they pass inputs that don't have ".swift" as an
103103
/// extension.) It would be nice to eliminate this distinction someday.
104104
bool shouldFilterFrontendInputsByType() const;
@@ -281,33 +281,6 @@ class ToolChain {
281281
std::unique_ptr<CommandOutput> output,
282282
const OutputInfo &OI) const;
283283

284-
/// Return true iff the input \c Job \p A is an acceptable candidate for
285-
/// batching together into a BatchJob, via a call to \c
286-
/// constructBatchJob. This is true when the \c Job is a built from a \c
287-
/// CompileJobAction in a \c Compilation \p C running in \c
288-
/// OutputInfo::Mode::StandardCompile output mode, with a single \c TY_Swift
289-
/// \c InputAction.
290-
bool jobIsBatchable(const Compilation &C, const Job *A) const;
291-
292-
/// Equivalence relation that holds iff the two input Jobs \p A and \p B are
293-
/// acceptable candidates for combining together into a \c BatchJob, via a
294-
/// call to \c constructBatchJob. This is true when each job independently
295-
/// satisfies \c jobIsBatchable, and the two jobs have identical executables,
296-
/// output types and environments (i.e. they are identical aside from their
297-
/// inputs).
298-
bool jobsAreBatchCombinable(const Compilation &C, const Job *A,
299-
const Job *B) const;
300-
301-
/// Construct a \c BatchJob that subsumes the work of a set of Jobs. Any pair
302-
/// of elements in \p Jobs are assumed to satisfy the equivalence relation \c
303-
/// jobsAreBatchCombinable, i.e. they should all be "the same" job in in all
304-
/// ways other than their choices of inputs. The provided \p NextQuasiPID
305-
/// should be a negative number that persists between calls; this method will
306-
/// decrement it to assign quasi-PIDs to each of the \p Jobs passed.
307-
std::unique_ptr<Job> constructBatchJob(ArrayRef<const Job *> Jobs,
308-
int64_t &NextQuasiPID,
309-
Compilation &C) const;
310-
311284
/// Return the default language type to use for the given extension.
312285
/// If the extension is empty or is otherwise not recognized, return
313286
/// the invalid type \c TY_INVALID.

include/swift/Option/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def ModuleWrapOption : OptionFlag;
3333
def NoDriverOption : OptionFlag;
3434

3535
// Some options should not be available depending on whether this is the
36-
// interactive driver 'swift', or the batch compiler 'swiftc'.
36+
// interactive driver 'swift', or the aot compiler 'swiftc'.
3737
def NoInteractiveOption : OptionFlag;
3838
def NoBatchOption : OptionFlag;
3939

0 commit comments

Comments
 (0)