Skip to content

performance versus setting CPU affinity #111

@milahu

Description

@milahu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions