summaryrefslogtreecommitdiffstats
path: root/subcmds
diff options
context:
space:
mode:
authorGavin Mak <gavinmak@google.com>2025-04-09 13:59:27 -0700
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2025-04-09 14:52:22 -0700
commitdaebd6cbc2ae642021bcc209484e7249edc656ea (patch)
tree7c7ae74465d8a7d3e691112806e39551e580232b /subcmds
parent3667de1d0fccc942e912dbc440da71c7de0d2398 (diff)
downloadgit-repo-daebd6cbc2ae642021bcc209484e7249edc656ea.tar.gz
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 <vapier@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Tested-by: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'subcmds')
-rw-r--r--subcmds/sync.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 49874c44..3dc74f1f 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -350,6 +350,8 @@ later is required to fix a server side protocol bug.
350 # value later on. 350 # value later on.
351 PARALLEL_JOBS = 0 351 PARALLEL_JOBS = 0
352 352
353 _JOBS_WARN_THRESHOLD = 100
354
353 def _Options(self, p, show_smart=True): 355 def _Options(self, p, show_smart=True):
354 p.add_option( 356 p.add_option(
355 "--jobs-network", 357 "--jobs-network",
@@ -1728,6 +1730,24 @@ later is required to fix a server side protocol bug.
1728 opt.jobs_network = min(opt.jobs_network, jobs_soft_limit) 1730 opt.jobs_network = min(opt.jobs_network, jobs_soft_limit)
1729 opt.jobs_checkout = min(opt.jobs_checkout, jobs_soft_limit) 1731 opt.jobs_checkout = min(opt.jobs_checkout, jobs_soft_limit)
1730 1732
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
1731 def Execute(self, opt, args): 1751 def Execute(self, opt, args):
1732 errors = [] 1752 errors = []
1733 try: 1753 try: