From e87ee4371c9f09daac814845df196a65cac28a7a Mon Sep 17 00:00:00 2001 From: "George L. Yermulnik" Date: Thu, 31 Oct 2024 21:31:18 +0200 Subject: [PATCH] fix(WSL): Make parallelism work appropriately (#728) * fix(`common::get_cpu_num`): Do not identify WSL as K8S --------- Co-authored-by: MaxymVlasov --- hooks/_common.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hooks/_common.sh b/hooks/_common.sh index 3c71f2b0f..25022e329 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -199,7 +199,8 @@ function common::get_cpu_num { local millicpu - if [[ -f /sys/fs/cgroup/cpu/cpu.cfs_quota_us ]]; then + if [[ -f /sys/fs/cgroup/cpu/cpu.cfs_quota_us && + ! -f /proc/sys/fs/binfmt_misc/WSLInterop ]]; then # WSL have cfs_quota_us, but WSL should be checked as usual Linux host # Inside K8s pod or DinD in K8s millicpu=$(< /sys/fs/cgroup/cpu/cpu.cfs_quota_us) @@ -251,7 +252,7 @@ function common::get_cpu_num { fi # On host machine or any other case - # `nproc` - Linux/FreeBSD, `sysctl -n hw.ncpu` - macOS/BSD, `echo 1` - fallback + # `nproc` - Linux/FreeBSD/WSL, `sysctl -n hw.ncpu` - macOS/BSD, `echo 1` - fallback nproc 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null || echo 1 }