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

login
register
mail settings
Submitter phabricator
Date Dec. 12, 2019, 5:37 p.m.
Message ID <differential-rev-PHID-DREV-3d3aqarl4yow5nf7dvmq-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43751/
State Superseded
Headers show

Comments

phabricator - Dec. 12, 2019, 5:37 p.m.
Alphare created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  As per the inline comment, this is a workaround because Rust code does not yet
  know how to read config files.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 12, 2019, 5:38 p.m.
Alphare added a comment.


  This entire series is a graft of existing changesets onto stable, to fix the current CI for the Rust module policy.

REPOSITORY
  rHG Mercurial

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

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

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,