You are not logged in.

#1 2015-01-15 00:05:47

Next7
Member
Registered: 2011-12-07
Posts: 44

[SOLVED] How to limit cpu usage by makepkg?

I tried

cpulimit -l 30 makepkg

but the cpu usage still reaches 100% + 100% due to conky (i have 2 core cpu). OK, I've found out that cpulimit does not restrict child processes but cgroup is promised to do that. So I installed it from AUR and did the following:

sudo systemctl enable cgconfig
sudo systemctl start cgconfig

sudo cgcreate -t my_name:my_name -a my_name:my_name -g memory,cpu:my_build

sudo echo 100000000 > /sys/fs/cgroup/memory/my_build/memory.limit_in_bytes
sudo echo 300 > /sys/fs/cgroup/cpu/my_build/cpu.shares

cgexec -g 'memory,cpu:my_build' makepkg

But cpu usage is nevertheless 100% + 100%.

Am I doing something wrong? And how to fix it?

Last edited by Next7 (2015-01-16 00:40:18)

Offline

#2 2015-01-15 00:59:09

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How to limit cpu usage by makepkg?

Is it enough to make makepkg use 100% of one core and 0% of the other? If so, set MAKEFLAGS to use just one core.

Offline

#3 2015-01-15 02:30:21

Next7
Member
Registered: 2011-12-07
Posts: 44

Re: [SOLVED] How to limit cpu usage by makepkg?

Thanks for the reply and the tip, it will be a good compromise solution. But it would be nice to make cgroup to work and to decrease cpu usage below 50%.

Offline

#4 2015-01-16 00:39:07

Next7
Member
Registered: 2011-12-07
Posts: 44

Re: [SOLVED] How to limit cpu usage by makepkg?

I've found the solution for my problem. First of all "cpu.shares" parameter is useless for one task and one cgroup which is my case since it specifies a relative share of CPU among different cgroups.

So for my purpose the following parameters are needed: "cpu.cfs_period_us" and "cpu.cfs_quota_us". The execution of the following commands resulted in 10% + 10% CPU load.

echo 1000000 > /sys/fs/cgroup/cpu/my_build/cpu.cfs_period_us
echo 200000 > /sys/fs/cgroup/cpu/my_build/cpu.cfs_quota_us

And there's another important point: "cgexec" command should be executed with option "--sticky" to restrict child processes.

cgexec -g memory,cpu:my_build --sticky makepkg

Offline

Board footer

Powered by FluxBB