Patchwork D7310: rust-threads: force Rayon to respect the worker count in config

login
register
mail settings
Submitter phabricator
Date Nov. 8, 2019, 2:15 p.m.
Message ID <53c2c3050c89726dde3114ae7b68ec36@localhost.localdomain>
Download mbox | patch
Permalink /patch/42931/
State Not Applicable
Headers show

Comments

phabricator - Nov. 8, 2019, 2:15 p.m.
Alphare updated this revision to Diff 17749.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7310?vs=17726&id=17749

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7310/new/

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -1116,6 +1116,17 @@ 
             use_rust = False
 
         if use_rust:
+            # Force Rayon (Rust parallelism library) to respect the number of
+            # workers. This is a temporary workaround until Rust code knows
+            # how to read the config file.
+            numcpus = self._ui.configint("worker", "numcpus")
+            if numcpus is not None:
+                os.environ.setdefault('RAYON_NUM_THREADS', str(numcpus))
+
+            workers_enabled = self._ui.configbool("worker", "enabled", True)
+            if not workers_enabled:
+                os.environ["RAYON_NUM_THREADS"] = "1"
+
             (
                 lookup,
                 modified,