Presentation is loading. Please wait.

Presentation is loading. Please wait.

Virtual-Time Round-Robin: An O(1) Proportional Share Scheduler

Similar presentations


Presentation on theme: "Virtual-Time Round-Robin: An O(1) Proportional Share Scheduler"— Presentation transcript:

1 Virtual-Time Round-Robin: An O(1) Proportional Share Scheduler

2 Outline Introduction Categories of Proportional Share Schedulers
Background Definitions Scheduler goals Problems with existing proportional share schedulers Examples Virtual-Time Round-Robin description Example Experimental Setup and Results Conclusions

3 Introduction Proportional Share Scheduling
Based on the idea of assigning each task a weight Allocate resources in proportion to the assigned weight

4 Introduction (continued)
Modeled as a queue of tasks Select first task to run for a period of time (time quantum) Decide which task to run next Select that task to run for a period of time Can achieve proportional sharing by Adjust length of time quantum Adjust the frequency a task is selected to run (by adjusting its position in the queue)

5 Introduction (continued)
A proportional scheduler should Have low overhead for task selection Allows scheduler to handle a large number of tasks without a significant decline in performance Guarantee proportional fairness A given task should ideally receive its share (relative to its weight) of CPU time over a given time interval

6 Terms and Definitions Perfect Fairness
State where task has received service exactly proportional to its weight Proportional share for task A: Amount of service received in time interval (t1,t2) for task A: Perfect fairness:

7 Terms and Definitions Continued
Service Time Error: Difference between amount of service allocated for a given time interval and the ideal amount of time that should be allocated for that interval Positive value indicates a task received more than its ideal share of resources over that interval Negative value indicates task received less than its ideal share of resources over that interval

8 Problems with Existing Proportional Share Schedulers
Weighted Round-robin Tasks placed in queue and executed in turn Time quantum allocated to task is proportional to task weight Has low overhead but weak proportional fairness guarantee O(1) complexity for task selection Some tasks get all their service time at once, while others don’t get any at all Larger share values result in higher service error ratio value

9 WRR Example Three tasks
A with share 3 B with share 2 C with share 1 Weighted round robin would schedule them as follows

10 WRR Example Service time error for weighted round robin

11 WRR Example Increasing the share values proportionally increases the service time error

12 Terms and Definitions Continued
Virtual Time: Measure of amount of service allocation task receives relative to other tasks Advances at a rate inversely proportional to share value Virtual Finishing Time (VFT) Virtual time for a task after running for one time quantum

13 Problems with Existing Proportional Share Schedulers (continued)
Weighted fair queuing Tasks sorted from smallest to largest virtual time value After task execution, virtual time recalculated and task is reinserted in correct queue position Has strong proportional fairness guarantee, but higher overhead Adjusts frequency of execution, rather than size of time quanta based on share size Keeping queue sorted by virtual time values adds undesirable overhead to the scheduler O(N) complexity for task selection

14 WFQ Example VFT Time Task A Task B Task C Queue 1/3 1/2 1 ABC 2/3 BAC
1/3 1/2 1 ABC 2/3 BAC 2 3 BCA 4 1 1/2 CAB 5 6 1 1/3

15 WFQ Example

16 Virtual-Time Round-Robin
Combines low overhead of weighted round-robin scheduling with high proportional fairness guarantee of weighted fair queuing

17 Virtual-Time Round-robin
Basic Algorithm outline Order tasks on queue from largest to smallest share value Start from beginning of queue and run each task for one time quantum If a task receives more than its proportional share allocation, skip the remaining tasks and start executing tasks from the beginning of the queue again Task remains in same queue position unless its share value changes

18 Virtual-Time Round-Robin description
Associates five values with each task’s execution state Share Virtual Finishing Time Time Counter ID Number Run State

19 Virtual-Time Round-Robin description
Associates five values with each task’s execution state Share Task receives resources in proportion to its share value Virtual Finishing Time Advances at a rate proportional to the task’s resource consumption divided by its share value Determines when algorithm skips remaining tasks and starts from head of queue again

20 Virtual-Time Round-Robin description
Associates five values with each task’s execution state Time Counter Tracks number of time quanta a task requires before the end of the scheduling period to achieve perfect fairness Initially set to the share value of the task ID Number Unique identifier Runnable Whether task can be executed

21 Virtual-Time Round-Robin description
Four values used to maintain scheduler state Time Quantum Run Queue Total Shares Queue Virtual Time

22 Virtual-Time Round-Robin description
Four values used to maintain scheduler state Time Quantum Amount of time a task is allowed to execute before the next scheduling decision Same length regardless of share value, unlike weighted round-robin

23 Virtual-Time Round-Robin description
Four values used to maintain scheduler state Run Queue Sorted list of tasks from largest to smallest share value Total Shares Sum of all runnable task share values

24 Virtual-Time Round-Robin description
Queue Virtual Time Measure of what a task’s Virtual Time should be if it receives its proportional share allocation Advances at a rate inversely proportional to total shares

25 Virtual-Time Round-Robin description
Definitions Scheduling Cycle “Sequence of Allocations whose length is equal to the sum of all client shares” Time counter values correspond to task share values at beginning of cycle Time counter values for all tasks should be zero at end of cycle Time Counter Invariant Given two consecutive tasks in the run queue, the time counter of the subsequent task must always be no greater than the time counter of the former task

26 Virtual-Time Round-Robin description
Definitions Virtual Time Inequality If the task’s virtual time is less than the queue virtual time, it has used less than its proportional share of resources for a given time quantum

27 Virtual-Time Round-Robin description
Detailed Algorithm Description Run first task in run queue for one time quantum Increment that task’s VFT by the time quantum divided by the task’s share value Decrement that task’s time counter value

28 Virtual-Time Round-Robin description
Detailed Algorithm Description Prepare to run next task in run queue Check time counter invariant If counter for this task greater than that of the previous task, execute this task and decrement its time counter value to preserve invariant Compare VFT of this task to QVT’s next time quantum value If difference is less than the difference between current and next VFT for task, execute task (VFT inequality) Otherwise restart from beginning of run queue VFT – Virtual Finishing Time QVT – Queue Virtual Time

29 Virtual-Time Round-Robin description
Detailed Algorithm Description When all task time counters reach zero (at end of scheduling cycle), reset their values to the share value of the corresponding task Start from beginning of run queue

30 Virtual-Time Round-Robin description

31 Virtual-Time Round-Robin Example
Three tasks (A, B, C) A’s share value is 3 B’s share value is 2 C’s share value is 1 Recall for VTRR that queue is sorted from largest to smallest share A B C

32 Virtual-Time Round-Robin Example
Each task’s time counter value is initialized to its share value A’s time value is 3 B’s time value is 2 C’s time value is 1

33 Virtual-Time Round-Robin Example
Recall that task’s Virtual Finishing Time (VFT) advances at a rate inversely proportional to its share Therefore, each task’s virtual time will advance as follows: A’s advances by 1/3 per time quantum B’s advances by 1/2 per time quantum C’s advances by 1/1 per time quantum

34 Virtual-Time Round-Robin Example
Recall that Queue Virtual Time advances at a rate inversely proportional to the total share value Since the share values sum to 6 ( ), QVT advances by 1/6 for every time quanta

35 Virtual-Time Round-Robin Example

36 Virtual-Time Round-Robin Example

37 Virtual-Time Round-Robin Example

38 Virtual-Time Round-Robin Example

39 Virtual-Time Round-Robin Example

40 Virtual-Time Round-Robin Example

41 Virtual-Time Round-Robin Example

42 Virtual-Time Round-Robin Example
Now we’re at the end of the scheduling cycle At this point, the time counters are reset to the share values, VFTs are reset to their initial values, and execution starts at the head of the run queue (task A)

43 Virtual-Time Round-Robin Example
The service error ranges from 1/2 to -1/2

44 Virtual-Time Round-Robin description
New tasks can be added queue Set initial virtual time equal to QVT VFT becomes: Time counter becomes: Tasks can be removed from queue Store pointers to adjacent tasks to facilitate reinsertion when task becomes runnable again

45 Virtual-Time Round-Robin description
Existing tasks can be reinserted into run queue If adjacent task pointers are valid, O(1) insertion complexity Otherwise iterate over the list and determine insert position based on share value O(N) complexity

46 Virtual-Time Round-Robin description
Existing tasks can be reinserted into run queue Update VFT Take the maximum of the initial VFT calculation and original VFT value (where is the task’s original VFT value)

47 Virtual-Time Round-Robin description
Existing tasks can be reinserted into run queue Update time counter Cannot have larger value compared to before Set to minimum of initial counter calculation and previous counter value Must be bounded by values of adjacent task time counter values

48 Complexity O(1) Selecting next task for execution Updating VFT value
Updating run queue position Though run queue needs to be sorted by share value, it doesn’t change the selection process Unlike fair queuing where executed task needs to be reinserted in correct queue position Task creation and termination

49 Complexity O(N) Time counter reset at end of scheduling cycle
Only once per N scheduler selections at most Change task share assignment Inserting recently runnable task into run queue If previous and next task pointers are not valid

50 Experimental Setup and Results
Simulator User program used to measure service time error Could set the number of tasks, the total number of shares, the number of task to share combinations, and the scheduling algorithm Compared Virtual-Time Round-Robin, Weighted Fair Queuing, and Weighted Round-Robin

51 Experimental Setup and Results
Simulator Runs scheduler until schedule repeats Records minimum and maximum service time error values Assumes that tasks remain runnable at all times

52 Experimental Setup and Results
Simulator results As the share total becomes larger, the service error range is quite large especially when there are relatively few tasks

53 Experimental Setup and Results
Simulator Results Service error scale has been reduced. Even though the service error range for VTRR is greater compared to WFQ, it’s not that much more and given the lower scheduling overhead, it’s an acceptable tradeoff

54 Experimental Setup and Results
Scheduling overhead Compared Linux scheduling framework (kernel version 2.2) with VTRR, and WFQ and measured overhead as the number of tasks increased Each task performed a few operations in a while loop Measured execution time for scheduling events using a counter and timestamp event identifiers added to the Linux scheduling framework

55 Experimental Setup and Results
Scheduling overhead results

56 Experimental Setup and Results
Scheduling overhead results VTRR had the least overhead in part due to the O(1) complexity for choosing the next task for execution compared to O(N) for the Linux scheduler and WFQ or O(log(N)) complexity for the heap based WFQ

57 Experimental Setup and Results
Fine time resolution of scheduling Five micro-benchmark (tasks) Assigned shares of 1, 2, 3, 4, and 5 in VTRR and WFQ Assigned priorities of 19, 17, 15, 13, and 11 in the Linux scheduler Smallest time quantum is the same for all three schedulers Measurement made by taking high resolution timestamps from within each task

58 Experimental Setup and Results
Fine time resolution of scheduling

59 Experimental Setup and Results
Fine time resolution and scheduling

60 Experimental Setup and Results
Fine time resolution and scheduling Linux scheduler doesn’t schedule tasks as evenly or predictably compared to VTRR and WFQ Not predictable since order of execution depends on time scheduler is called Not as even because it continues to execute a task even if its “goodness” (priority – time remaining in quantum) drops below other task “goodness” values

61 Experimental Setup and Results
Application Workloads Five instances of MPEG audio recording application with shares 1, 2, 3, 4, and 5 for VTRR and WFQ and corresponding priority levels in Linux All reading from same file, but writing to individual files

62 Experimental Setup and Results
Application Workload results

63 Experimental Setup and Results
Application Workload results CPU resources are provided in “bursts” in the Linux scheduler while they’re provided more evenly in VTRR (due to a lesser degree of proportional fairness) For time-critical tasks like audio or video streaming, this can result in delays and frame drops

64 Conclusions Virtual-Time Round-robin scheduling is a better alternative compared to weighted fair queues, weighted round robin, and even the standard Linux scheduler (version 2.2) It provides better proportional fairness compared to the Linux scheduler or weighted round robin It has lower scheduling overhead compared to the Linux scheduler and weighted fair queues

65 Thoughts Why isn’t this type of scheduler used in Linux? Task latency
Linux doesn’t require explicit share value assignment for a process Task latency Interactive (I/O bound) processes don’t require much CPU time, but require low latency What would be the best share value to assign? Is a proportional share scheduler even appropriate?

66 Thoughts What about process groups? Two groups of two tasks each
All have the same share value One process blocks Group with blocked process only gets 25% of service, instead of 50% Group Ratio Round Robin

67 Questions ?


Download ppt "Virtual-Time Round-Robin: An O(1) Proportional Share Scheduler"

Similar presentations


Ads by Google