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

login
register
mail settings
Submitter phabricator
Date Nov. 8, 2019, 6:33 p.m.
Message ID <4a21e31d1949bee69abe84e55f11b53b@localhost.localdomain>
Download mbox | patch
Permalink /patch/42978/
State Not Applicable
Headers show

Comments

phabricator - Nov. 8, 2019, 6:33 p.m.
Closed by commit rHG57384e8e1fb6: rust-threads: force Rayon to respect the worker count in config (authored by Alphare).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

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

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
@@ -1109,6 +1109,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,