docker run --cpuset is not having any effect
Asked Answered
I

1

8

I started one docker container by specifying the cpuset to 1 cores:

docker run --cpuset-cpus="0"...

A second one by specifying the cpuset to 4 cores:

docker run --cpuset-cpus="0-3"...

I launched a load process within each container and I monitored the cpu consumption for both containers.

The load process is like:

ffmpeg input > output

I have observed that there is no improvement in term of execution time between both containers (no speed up).

Do you have any idea why there is no improvements? container with 4 cores should run faster than 1 core container right ?

NB: using top for 1core container

CPU0%=100%
CPU1%=0
CPU2%=0
CPU3%=0

using top for 4core container, docker chooses randomly one of 4 cores to launch the process. Sometimes it affects 30% for each core

CPU0%=0                  CPU0%=30%                   CPU0%=0
CPU1%=100%       or      CPU0%=30%            or     CPU0%=0
CPU2%=0                  CPU0%=30%                   CPU0%=0
CPU3%=0                  CPU0%=30%                   CPU0%=100%
Indiscrimination answered 29/7, 2015 at 13:59 Comment(0)
M
10

gzip does not use multiple cores even if they are available. As a result this program is not well suited to do performance tests regarding the use of CPU cores.

Use pzip instead. see Utilizing multi core for tar+gzip/bzip compression/decompression

Also see How can I produce high CPU load on a Linux server?


conveniently the stress tool is already available on the Docker Hub, so you can verify that the docker --cpuset-cpus option is working correctly by running:

docker run --rm -it --cpuset-cpus="0-3" jess/stress --cpu 4

→ you will witness that all 4 cores go to 100% usage.

then by running:

docker run --rm -it --cpuset-cpus="0-1" jess/stress --cpu 4

→ you will witness that just 2 cores go to 100% usage.

Molybdenous answered 29/7, 2015 at 14:3 Comment(4)
for ffmpeg library it is the same thing... how can I optimize the cpu consumption to use 100% of each core in multicore system? ffmpeg input.avi ouput.mp3Indiscrimination
this is another question.Molybdenous
the problem is that I don't want to use the stress tool provided by Docker Hub. I want to stress C libraries like ffmpeg with 100% for each core.Indiscrimination
and that is a very specific case which merits it own question. A quick search in google will show you that the ffmpeg process can or cannot use multiple threads depending on the codec you specify for the encoding. So you should ask a question regarding the specific use of ffmpeg and the codec you plan to useMolybdenous

© 2022 - 2024 — McMap. All rights reserved.