From c2a11e18c8579a1352d35ffb5e1712810983c194 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Mon, 28 Sep 2020 17:18:55 +0100 Subject: utils: respect scheduler affinity in cpu_count() cpu_count() returns multiprocessing.cpu_count() but that is simply returns os.cpu_count() so we could use that directly. However this returns the number of CPUs on the host, not the number of usable CPUs on the host. If the user is using scheduler affinity then the number of usable CPUs may be less, so when determining how many cores we can use check the affinity instead. (From OE-Core rev: e2e8ccbe410b2f38bcd9525982b2261cf71aab60) Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- meta/lib/oe/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'meta/lib') diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py index 13f4271da0..468c76f30f 100644 --- a/meta/lib/oe/utils.py +++ b/meta/lib/oe/utils.py @@ -249,8 +249,7 @@ def trim_version(version, num_parts=2): return trimmed def cpu_count(at_least=1): - import multiprocessing - cpus = multiprocessing.cpu_count() + cpus = len(os.sched_getaffinity(0)) return max(cpus, at_least) def execute_pre_post_process(d, cmds): -- cgit v1.2.3-54-g00ecf