Skip to content

Commit daebd6c

Browse files
Gavin MakLUCI
Gavin Mak
authored and
LUCI
committed
sync: Warn about excessive job counts
Warn users if the effective job count specified via `-j`, `--jobs-network`, or `--jobs-checkout` exceeds a threshold (currently 100). This encourages users to use more reasonable values. Bug: 406868778 Bug: 254914814 Change-Id: I116e2bbaf3dc824c04d1b2fbe52cf9ca5be77b9a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/466801 Reviewed-by: Mike Frysinger <[email protected]> Commit-Queue: Gavin Mak <[email protected]> Tested-by: Gavin Mak <[email protected]>
1 parent 3667de1 commit daebd6c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

subcmds/sync.py

+20
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ class Sync(Command, MirrorSafeCommand):
350350
# value later on.
351351
PARALLEL_JOBS = 0
352352

353+
_JOBS_WARN_THRESHOLD = 100
354+
353355
def _Options(self, p, show_smart=True):
354356
p.add_option(
355357
"--jobs-network",
@@ -1728,6 +1730,24 @@ def _ValidateOptionsWithManifest(self, opt, mp):
17281730
opt.jobs_network = min(opt.jobs_network, jobs_soft_limit)
17291731
opt.jobs_checkout = min(opt.jobs_checkout, jobs_soft_limit)
17301732

1733+
# Warn once if effective job counts seem excessively high.
1734+
# Prioritize --jobs, then --jobs-network, then --jobs-checkout.
1735+
job_options_to_check = (
1736+
("--jobs", opt.jobs),
1737+
("--jobs-network", opt.jobs_network),
1738+
("--jobs-checkout", opt.jobs_checkout),
1739+
)
1740+
for name, value in job_options_to_check:
1741+
if value > self._JOBS_WARN_THRESHOLD:
1742+
logger.warning(
1743+
"High job count (%d > %d) specified for %s; this may "
1744+
"lead to excessive resource usage or diminishing returns.",
1745+
value,
1746+
self._JOBS_WARN_THRESHOLD,
1747+
name,
1748+
)
1749+
break
1750+
17311751
def Execute(self, opt, args):
17321752
errors = []
17331753
try:

0 commit comments

Comments
 (0)