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

Alphare (Raphaël Gomès) phabricator at mercurial-scm.org
Fri Nov 8 13:33:28 EST 2019


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

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,



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


More information about the Mercurial-devel mailing list