From 8b9846d9a9d29b427860891c9b699eb4305e348b Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 20 Nov 2024 08:58:10 +0100 Subject: mtest: move determine_worker_count to utils, generalize It is useful to apply a limit to the number of processes even outside "meson test", and specifically for clang tools. In preparation for this, generalize determine_worker_count() to accept a variable MESON_NUM_PROCESSES instead of MESON_TESTTHREADS, and use it throughout instead of multiprocessing.cpu_count(). Signed-off-by: Paolo Bonzini --- docs/markdown/Unit-tests.md | 8 +++++--- docs/markdown/snippets/num-processes.md | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 docs/markdown/snippets/num-processes.md (limited to 'docs') diff --git a/docs/markdown/Unit-tests.md b/docs/markdown/Unit-tests.md index 898366095..13f6093f2 100644 --- a/docs/markdown/Unit-tests.md +++ b/docs/markdown/Unit-tests.md @@ -83,16 +83,18 @@ possible. By default Meson uses as many concurrent processes as there are cores on the test machine. You can override this with the environment -variable `MESON_TESTTHREADS` like this. +variable `MESON_TESTTHREADS` or, *since 1.7.0*, `MESON_NUM_PROCESSES`: ```console -$ MESON_TESTTHREADS=5 meson test +$ MESON_NUM_PROCESSES=5 meson test ``` -Setting `MESON_TESTTHREADS` to 0 enables the default behavior (core +Setting `MESON_NUM_PROCESSES` to 0 enables the default behavior (core count), whereas setting an invalid value results in setting the job count to 1. +If both environment variables are present, `MESON_NUM_PROCESSES` prevails. + ## Priorities *(added in version 0.52.0)* diff --git a/docs/markdown/snippets/num-processes.md b/docs/markdown/snippets/num-processes.md new file mode 100644 index 000000000..e4ffdd1dc --- /dev/null +++ b/docs/markdown/snippets/num-processes.md @@ -0,0 +1,7 @@ +## Control the number of child processes with an environment variable + +Previously, `meson test` checked the `MESON_TESTTHREADS` variable to control +the amount of parallel jobs to run; this was useful when `meson test` is +invoked through `ninja test` for example. With this version, a new variable +`MESON_NUM_PROCESSES` is supported with a broader scope: in addition to +`meson test`, it is also used by the `external_project` module. -- cgit v1.2.3