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
I have following questions regarding the CPUFreq governors:
1) This link https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt tells, "The CPUfreq governor "powersave" sets the CPU statically to the lowest frequency within the borders of scaling_min_freq and scaling_max_freq." However, I noticed the frequency changes as the load increases. How does "powersave" actually work?
2) Wy is the CPU frequency not increasing to max when "powersave" CPU freq governor is in use and CPU quota is set. Is setting CPU quota causing "powersave" to misbehave?