Skip to content

Commit

Permalink
fix(WSL): Make parallelism work appropriately (#728)
Browse files Browse the repository at this point in the history
* fix(`common::get_cpu_num`): Do not identify WSL as K8S

---------

Co-authored-by: MaxymVlasov <[email protected]>
  • Loading branch information
yermulnik and MaxymVlasov authored Oct 31, 2024
1 parent 068ebb5 commit e87ee43
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hooks/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit e87ee43

Please sign in to comment.