opsengine/cpulimit

performance versus setting CPU affinity

milahu opened this issue · 0 comments

why not use taskset to set CPU affinity?

The control of the used CPU amount is done sending SIGSTOP and SIGCONT POSIX signals to processes.

this sounds like a bad idea on a busy machine

lets say our machine has 100 cores
we use cpulimit to launch 2 processes, each process starts 100 workers

ideally each process would use 50 workers on 50 cores, so both can run perfectly parallel
but with cpulimit, the 2 processes block each other, because the cpu caches are constantly invalidated ...

n=$(nproc)
n2=$((n / 2))
echo nproc is $n

stress-ng --cpu $n --metrics --timeout 2s &
cpulimit -p$! -l$n2 -m &
stress-ng --cpu $n --metrics --timeout 2s &
cpulimit -p$! -l$n2 -m &

warning:
i just crashed a machine with these commands.
this seems to start a fork bomb

-bash: fork: retry: Resource temporarily unavailable