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

login
register
mail settings
Submitter phabricator
Date Nov. 8, 2019, 9:09 a.m.
Message ID <differential-rev-PHID-DREV-qty26k2sanjdpwetvawk-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42908/
State Superseded
Headers show

Comments

phabricator - Nov. 8, 2019, 9:09 a.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
  default

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 8, 2019, 1:40 p.m.
This revision now requires changes to proceed.
martinvonz added inline comments.
martinvonz requested changes to this revision.

INLINE COMMENTS

> dirstate.py:1125
> +                os.environ.setdefault('RAYON_NUM_THREADS',
> +                                      pycompat.sysstr(str(numcpus)))
> +

Is is the pycompat call needed? Same below.

REPOSITORY
  rHG Mercurial

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

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

To: Alphare, #hg-reviewers, martinvonz
Cc: martinvonz, mercurial-devel
phabricator - Nov. 8, 2019, 2:13 p.m.
Alphare added a comment.


  You're right, it shouldn't

REPOSITORY
  rHG Mercurial

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

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

To: Alphare, #hg-reviewers, martinvonz
Cc: martinvonz, mercurial-devel
phabricator - Dec. 13, 2019, 4:54 p.m.
mharbison72 added inline comments.

INLINE COMMENTS

> dirstate.py:1119
> +
> +            workers_enabled = self._ui.configbool("worker", "enabled", True)
> +            if not workers_enabled:

Isn't the default parameter usually omitted, and picked up from the registrar?

REPOSITORY
  rHG Mercurial

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

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

To: Alphare, #hg-reviewers, martinvonz
Cc: mharbison72, 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,18 @@ 
             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',
+                                      pycompat.sysstr(str(numcpus)))
+
+            workers_enabled = self._ui.configbool("worker", "enabled", True)
+            if not workers_enabled:
+                os.environ["RAYON_NUM_THREADS"] = pycompat.sysstr("1")
+
             (
                 lookup,
                 modified,