Skip to content

Commit b57f636

Browse files
committed
common/CI: Run PackageBumped check in package_checks.py concurrently
Quick n' Dirty Benchmarks time common/CI/package_checks.py --base=origin/ninja-progress (Branch that is several months out of date and not rebased) Before: 1m9.126s | Now: 0m35.721s time common/CI/package_checks.py --base=origin/auto-python-updates (Branch that is just a few commits behind origin/main) Before: 0m0.696s | Now: 0m0.602s
1 parent 860b03b commit b57f636

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

common/CI/package_checks.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import re
99
import subprocess
1010
import sys
11+
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor, as_completed
1112
from dataclasses import dataclass
1213
from datetime import datetime, timezone
1314
from enum import Enum
@@ -440,13 +441,26 @@ class PackageBumped(PullRequestCheck):
440441
def run(self) -> List[Result]:
441442
commits = self.commits or ['HEAD']
442443
files = set(self.files) & set(self.git.untracked_files() + self.git.modified_files())
443-
results = [self._check_commit(commit, file)
444-
for commit in commits
445-
for file in self.git.files_in_commit(commit)]
446-
results += [self._check_commit(None, file)
447-
for file in files]
448444

449-
return [result for result in results if result is not None]
445+
results = []
446+
with ThreadPoolExecutor() as executor:
447+
futures = []
448+
449+
# commit-based checks
450+
for commit in commits:
451+
for file in self.git.files_in_commit(commit):
452+
futures.append(executor.submit(self._check_commit, commit, file))
453+
454+
# file-based checks
455+
for file in files:
456+
futures.append(executor.submit(self._check_commit, None, file))
457+
458+
for future in as_completed(futures):
459+
result = future.result()
460+
if result is not None:
461+
results.append(result)
462+
463+
return results
450464

451465
def _check_commit(self, ref: Optional[str], file: str) -> Optional[Result]:
452466
match os.path.basename(file):

0 commit comments

Comments
 (0)