Skip to content
Snippets Groups Projects
Commit 14e0d37c authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

multi-cpu: introduce a way to control the number of CPU

The feature seem common enough that making it accessible globally make sense.
We'll introduce a way to easily set it up in the next changesets.
parent db32d012
No related branches found
No related tags found
No related merge requests found
......@@ -308,6 +308,8 @@
params = BASE_PARAMS
param_names = BASE_PARAMS_NAMES
max_worker_count = 1
@params_as_kwargs
def setup(self, repo, **kwargs):
venv = os.path.abspath(os.path.join(os.path.dirname(sys.executable), ".."))
......@@ -579,8 +581,18 @@
'hg --cwd /path/to/repo'
"""
args = list(args)
# disabled multi worker because out current test setup is bad with multi CPU
args = ["--config", "worker.enabled=no"] + args
if self.max_worker_count <= 1:
# disabled multi worker because out current test setup is bad with multi CPU
args = ["--config", "worker.enabled=no"] + args
else:
args = [
"--config",
"worker.enabled=yes",
'--config',
'--worker.numcpus=%d' % self.max_worker_count,
]
args += args
# Force Rayon (Rust parallelism library) to respect the number of
# workers. This is a temporary workaround until Rust code knows
......@@ -588,7 +600,7 @@
env_kwarg = kwargs.get("env")
if env_kwarg is None:
kwargs['env'] = env_kwarg = self.environ.copy()
env_kwarg["RAYON_NUM_THREADS"] = "1"
env_kwarg["RAYON_NUM_THREADS"] = "%d" % self.max_worker_count
if '--cwd' not in args:
# use self.repo_path as repo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment