Skip to content

Commit

Permalink
Do not assume that we can always utilize all hyperthreads
Browse files Browse the repository at this point in the history
  • Loading branch information
Witiko committed Aug 20, 2023
1 parent 477b7e9 commit 2df8a96
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,13 @@ def run_tests(testfiles: Iterable[TestFile], fail_fast: bool) -> Iterable[TestRe
num_batches = int(ceil(len(testfiles) / testfile_batch_size))

if num_batches > 1 and num_batches - 1 < NUM_PROCESSES:
testfile_batch_size = int(ceil(len(testfiles) / (NUM_PROCESSES + 1)))
num_batches = int(ceil(len(testfiles) / testfile_batch_size))
assert num_batches - 1 == NUM_PROCESSES
LOGGER.debug(f'Reducing batch size to {testfile_batch_size} in order to fully utilize {NUM_PROCESSES} hyperthreads.')
updated_testfile_batch_size = int(ceil(len(testfiles) / (NUM_PROCESSES + 1)))
updated_num_batches = int(ceil(len(testfiles) / testfile_batch_size))
assert updated_num_batches - 1 <= NUM_PROCESSES
assert updated_testfile_batch_size <= testfile_batch_size
if updated_testfile_batch_size < testfile_batch_size:
LOGGER.debug(f'Reducing batch size to {updated_testfile_batch_size} in order to fully utilize {NUM_PROCESSES} hyperthreads.')
testfile_batch_size, num_batches = updated_testfile_batch_size, updated_num_batches

testfile_batches: List[TestFileBatch] = list(chunked(testfiles, testfile_batch_size))
assert len(testfile_batches) == num_batches
Expand Down

0 comments on commit 2df8a96

Please sign in to comment.