2 ms·
That's good, but i'd prefer not to assume perl is there. Perhaps something like this untested POSIX shell might be better? if [ -e /sys/fs/cgroup/cpu/cpu.cf
by Daviey 2y ago
That's good, but i'd prefer not to assume perl is there. Perhaps something like this untested POSIX shell might be better?
if [ -e /sys/fs/cgroup/cpu/cpu.cfs_quota_us ] && [ -e /sys/fs/cgroup/cpu/cpu.cfs_period_us ]; then
read -r quota < /sys/fs/cgroup/cpu/cpu.cfs_quota_us
read -r period < /sys/fs/cgroup/cpu/cpu.cfs_period_us
# Perform division and rounding
GOMAXPROCS=$(( (quota + period - 1) / period ))
else
GOMAXPROCS=$(nproc)
fi
export GOMAXPROCS