CFS: Scheduler: How does each change in 'nice' value result in 10% change in CPU time?
Can anyone explain how the weights that the 'nice' values are mapped to actually result in an ~10% change in CPU time as you go from one nice level to the next? I can't make out how the comment here actually computes: (https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/ke...) /* * Nice levels are multiplicative, with a gentle 10% change for every * nice level changed. I.e. when a CPU-bound task goes from nice 0 to * nice 1, it will get ~10% less CPU time than another CPU-bound task * that remained on nice 0. * * The "10% effect" is relative and cumulative: from _any_ nice level, * if you go up 1 level, it's -10% CPU usage, if you go down 1 level * it's +10% CPU usage. (to achieve that we use a multiplier of 1.25. * If a task goes up by ~10% and another task goes down by ~10% then * the relative distance between them is ~25%.) */ static const int prio_to_weight[40] = { If I take an example of 2 tasks both with weight=1024 (NICE_0) they should each get 50% of the CPU time. If 1 of the tasks is reniced to NICE_1 then the NICE_0 task will get 1024/(1024+820)=56% of the CPU time and the NICE_1 task will get 44% of the CPU time. I'm obviously not understanding something since I can't come at those 10% figures in the comments. Thanks.
On Thu, 21 Jan 2016 08:51:08 -0800, John Locke said:
* Nice levels are multiplicative, with a gentle 10% change for every * nice level changed. I.e. when a CPU-bound task goes from nice 0 to * nice 1, it will get ~10% less CPU time than another CPU-bound task
Note the ~ indicating approximately.
If I take an example of 2 tasks both with weight=1024 (NICE_0) they should each get 50% of the CPU time. If 1 of the tasks is reniced to NICE_1 then the NICE_0 task will get 1024/(1024+820)=56% of the CPU time and the NICE_1 task will get 44% of the CPU time.
12% difference - that's around 10%.
On Thu, Jan 21, 2016 at 9:37 AM, <Valdis.Kletnieks@vt.edu> wrote:
On Thu, 21 Jan 2016 08:51:08 -0800, John Locke said:
* Nice levels are multiplicative, with a gentle 10% change for every * nice level changed. I.e. when a CPU-bound task goes from nice 0 to * nice 1, it will get ~10% less CPU time than another CPU-bound task
Note the ~ indicating approximately.
If I take an example of 2 tasks both with weight=1024 (NICE_0) they should each get 50% of the CPU time. If 1 of the tasks is reniced to NICE_1 then the NICE_0 task will get 1024/(1024+820)=56% of the CPU time and the NICE_1 task will get 44% of the CPU time.
12% difference - that's around 10%.
That's true but depending on what nice levels I choose it can be off by more. If I increase the distance between 'nice' levels, e.g. using -20 and -9 then I get (88761+7620)/96381 or 92% CPU time vs 8%. I guess the real question is if I were given a set of tasks running on the system and their 'nice' levels could I quantify roughly how much CPU time CFS would give them? The ~10% guideline is nice but doesn't hold if the spread between 'nice' levels is larger it seems.
participants (2)
-
John Locke -
Valdis.Kletnieks@vt.edu