File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -302,12 +302,23 @@ extension Driver {
302
302
// pre-batch-mode 1000. I.e. it's still running 96% fewer
303
303
// subprocesses than before. And significantly: it's doing so while
304
304
// not exceeding the RAM of a typical 2-core laptop.
305
+
306
+ // An explanation of why the partition calculation isn't integer
307
+ // division. Using an example, a module of 26 files exceeds the
308
+ // limit of 25 and must be compiled in 2 batches. Integer division
309
+ // yields 26/25 = 1 batch, but a single batch of 26 exceeds the
310
+ // limit. The calculation must round up, which can be calculated
311
+ // using: `(x + y - 1) / y`
312
+ let divideRoundingUp = { num, div in
313
+ return ( num + div - 1 ) / div
314
+ }
315
+
305
316
let defaultSizeLimit = 25
306
317
let numInputFiles = swiftInputFiles. count
307
318
let sizeLimit = info. sizeLimit ?? defaultSizeLimit
308
319
309
320
let numTasks = numParallelJobs ?? 1
310
- return max ( numTasks, numInputFiles / sizeLimit)
321
+ return max ( numTasks, divideRoundingUp ( numInputFiles, sizeLimit) )
311
322
}
312
323
313
324
/// Describes the partitions used when batching.
You can’t perform that action at this time.
0 commit comments