File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1361,11 +1361,20 @@ namespace driver {
1361
1361
// subprocesses than before. And significantly: it's doing so while
1362
1362
// not exceeding the RAM of a typical 2-core laptop.
1363
1363
1364
+ // An explanation of why the partition calculation isn't integer division.
1365
+ // Using an example, a module of 26 files exceeds the limit of 25 and must
1366
+ // be compiled in 2 batches. Integer division yields 26/25 = 1 batch, but
1367
+ // a single batch of 26 exceeds the limit. The calculation must round up,
1368
+ // which can be calculated using: `(x + y - 1) / y`
1369
+ auto DivideRoundingUp = [](size_t Num, size_t Div) -> size_t {
1370
+ return (Num + Div - 1 ) / Div;
1371
+ };
1372
+
1364
1373
size_t DefaultSizeLimit = 25 ;
1365
1374
size_t NumTasks = TQ->getNumberOfParallelTasks ();
1366
1375
size_t NumFiles = PendingExecution.size ();
1367
1376
size_t SizeLimit = Comp.getBatchSizeLimit ().getValueOr (DefaultSizeLimit);
1368
- return std::max (NumTasks, NumFiles / SizeLimit);
1377
+ return std::max (NumTasks, DivideRoundingUp ( NumFiles, SizeLimit) );
1369
1378
}
1370
1379
1371
1380
// / Select jobs that are batch-combinable from \c PendingExecution, combine
You can’t perform that action at this time.
0 commit comments