Behavior of powersave freq governor when cpu quota is set

From: Ashutosh Mehra1
Date: Thu Feb 15 2018 - 05:46:37 EST


I am trying to understand the effect of setting cpu.cpu_quota_us in cpu
cgroup subsytem on application performance.
Essentially by reducing the CPU quota, but increasing the number of CPUs
such that "effective" CPUs are still the same, would it impact the
application?
For example, is 4 CPU 100% quota configuration same as 8 CPU 50% quota
configuration?

I have written a simple CPU-intensive program at
https://github.com/ashu-mehra/cpu-quota-test and ran it under following
cgroup configuration:
1) In cgroup which has 4 cpus and no limit on quota
2) In cgroup which has 8 cpus and 50% quota

When running this program for 32 threads I noticed following difference in
the throughput reported by the program for the two configurations:

4CPU@100 8CPU@50
176236 87252.5

Performance of 8CPU@50 is less than half of what I get with 4CPU@100.
On debugging further, I noticed my system is configured to use "powersave"
CPU freq governor. In this mode the CPU frequency of the cores when
program is running on 4CPU@100 shot to maximum but for 8CPU@50 CPU
frequence of the cores was much lower.
When I changed the CPU freq governor to "performance" (which is the only
other freq governor available), performance with 8CPU@50 increases
considerably as the cores started running at max frequency:

4CPU@100 8CPU@50
175804 163831

My system details are:
Ubuntu 16.04.2 LTS
Kernel 4.4.0-103-generic

Can someone please explain why is CPU frequency not increasing to max when
"powersave" CPU freq governor is in use and CPU quota is set. Is this
working as designed?

Regards,
Ashutosh Mehra