Patchwork D8927: posixworker: avoid creating workers that end up getting no work

login
register
mail settings
Submitter phabricator
Date Aug. 13, 2020, 5:45 p.m.
Message ID <differential-rev-PHID-DREV-5gmjig3qeingukla5d6e-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47027/
State Superseded
Headers show

Comments

phabricator - Aug. 13, 2020, 5:45 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  If `workers` (the detected or configured number of CPUs) is greater
  than the number of work items, then some of the workers end up getting
  0 work items. Let's not create such workers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8927

AFFECTED FILES
  mercurial/worker.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -211,7 +211,7 @@ 
     parentpid = os.getpid()
     pipes = []
     retval = {}
-    for pargs in partition(args, workers):
+    for pargs in partition(args, min(workers, len(args))):
         # Every worker gets its own pipe to send results on, so we don't have to
         # implement atomic writes larger than PIPE_BUF. Each forked process has
         # its own pipe's descriptors in the local variables, and the parent