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

login
register
mail settings
Submitter phabricator
Date Dec. 13, 2019, 6:17 p.m.
Message ID <38d5e7e3ce6d8f83214daf65d7c7be41@localhost.localdomain>
Download mbox | patch
Permalink /patch/43798/
State Not Applicable
Headers show

Comments

phabricator - Dec. 13, 2019, 6:17 p.m.
Closed by commit rHG37cbf45bb858: 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/D7610?vs=18640&id=18688

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

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: 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:
+                encoding.environ.setdefault(b'RAYON_NUM_THREADS', b'%d' % numcpus)
+
+            workers_enabled = self._ui.configbool("worker", "enabled", True)
+            if not workers_enabled:
+                encoding.environ[b"RAYON_NUM_THREADS"] = b"1"
+
             (
                 lookup,
                 modified,