Closed
Description
Describe the bug
The script _common.sh
fails to detect correct CPU count in WSL distributions.
How can we reproduce it?
Export the following two functions from the mentioned script:
common::get_cpu_num
common::colorify
Run common::get_cpu_num
You will see this output:
Unable to derive number of available CPU cores.
Running inside K8s pod without limits or inside DinD without limits propagation.
To avoid possible harm, parallelism is disabled.
To re-enable it, set corresponding limits, or set the following for the current hook:
args:
- --hook-config=--parallelism-ci-cpu-cores=N
where N is the number of CPU cores to allocate to pre-commit.
1
This is wrong. This snippet from get_cpu_num shows the correct CPU count:
> nproc 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null || echo 1
20
But the script never reaches this point, because
/sys/fs/cgroup/cpu/cpu.cfs_quota_us
exists (and it contains -1).
So the problem is that the hook is not running inside K8s pod or inside DinD but inside WSL. It is possible to set CPU limits for WSL. But by default WSL is allowed to use all available CPUs with no limit.
Environment information
WSL-Version: 2.3.24.0
Kernelversion: 5.15.153.1-2
WSLg-Version: 1.0.65
MSRDC-Version: 1.2.5620
Direct3D-Version: 1.611.1-81528511
DXCore-Version: 10.0.26100.1-240331-1435.ge-release
Windows-Version: 10.0.22621.4317
Hook version is v4.6.0
Thanks for the hooks.
Activity