changeset 45396:26eb62bd0550

posixworker: avoid creating workers that end up getting no work 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. Differential Revision: https://phab.mercurial-scm.org/D8927
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 13 Aug 2020 10:37:25 -0700
parents 8c466bcb0879
children da3b7c80aa34
files mercurial/worker.py
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/worker.py	Mon Aug 10 21:46:47 2020 -0700
+++ b/mercurial/worker.py	Thu Aug 13 10:37:25 2020 -0700
@@ -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