# HG changeset patch # User Raphaël Gomès # Date 2019-11-10 15:30:14 # Node ID 37cbf45bb8585679af55e1dfdd7406d6f2cf0426 # Parent 612b4b63fb2267320f18655c0fa8a675f8fe3939 rust-threads: force Rayon to respect the worker count in config As per the inline comment, this is a workaround because Rust code does not yet know how to read config files. Differential Revision: https://phab.mercurial-scm.org/D7610 diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -1116,6 +1116,17 @@ class dirstate(object): 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,