Fair and Timely Scheduling via Cooperative Polling Charles Buck - - PowerPoint PPT Presentation

fair and timely scheduling via cooperative polling
SMART_READER_LITE
LIVE PREVIEW

Fair and Timely Scheduling via Cooperative Polling Charles Buck - - PowerPoint PPT Presentation

Introduction Our Approach Results Summary Fair and Timely Scheduling via Cooperative Polling Charles Buck Krasic 1 Mayukh Saubhasik 1 Anirban Sinha 1 Ashvin Goel 2 1 Department of Computer Science University of British Columbia 2


slide-1
SLIDE 1

Introduction Our Approach Results Summary

Fair and Timely Scheduling via Cooperative Polling

Charles ’Buck’ Krasic1 Mayukh Saubhasik1 Anirban Sinha1 Ashvin Goel2

1Department of Computer Science

University of British Columbia

2Department of Electrical and Computer Engineering

University of Toronto

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-2
SLIDE 2

Introduction Our Approach Results Summary

Outline

1

Introduction Problem Description Previous Approaches

2

Our Approach Design Implementation

3

Results Timeliness Fairness

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-3
SLIDE 3

Introduction Our Approach Results Summary Problem Description Previous Approaches

Outline

1

Introduction Problem Description Previous Approaches

2

Our Approach Design Implementation

3

Results Timeliness Fairness

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-4
SLIDE 4

Introduction Our Approach Results Summary Problem Description Previous Approaches

Introduction

Scheduling in commodity operating systems traditionally favors throughput over timeliness

Time sensitive applications are poorly served unless they have low requirements.

Our approach improves timeliness while preserving benefits of the best effort model

Application model for time sensitive applications Kernel scheduler the provides fairness and timeliness New system call called coop_poll that supports cooperation between application and kernel level schedulers

Timing improvements of up to two orders of magnitude

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-5
SLIDE 5

Introduction Our Approach Results Summary Problem Description Previous Approaches

Time Sensitive Applications

Hard real-time

aircraft controllers, airbag controllers

Soft real-time

games, graphical animation (visualizations, desktops, etc.) continuous media (audio and video) distributed computing services (e.g. SLAs) user level drivers

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-6
SLIDE 6

Introduction Our Approach Results Summary Problem Description Previous Approaches

Elements of good scheduling

Throughout

work conserving low overhead

Fairness

Max-min fairness is common in best effort systems. Can be resource centric (QoS: CPU time, bandwidth, etc.)

  • r application centric (QoE: PSNR, MOS, etc.)

Timeliness

Release-Time, Deadline, Jitter Tardiness: difference between release time and corresponding activation.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-7
SLIDE 7

Introduction Our Approach Results Summary Problem Description Previous Approaches

Critical Path of Tardiness

Timer Latency

High resolution clock, timers.

Preemption Latency

Fully preemptable kernel.

Scheduling Latency

Our approach.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-8
SLIDE 8

Introduction Our Approach Results Summary Problem Description Previous Approaches

Outline

1

Introduction Problem Description Previous Approaches

2

Our Approach Design Implementation

3

Results Timeliness Fairness

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-9
SLIDE 9

Introduction Our Approach Results Summary Problem Description Previous Approaches

Classic Real-time

Priority Based.

Starvation, inversions.

Reservation based.

Very hard to estimate resource requirements.

Tune the reservation parameter via Feedback.

Can lead to instability for adaptive applications. Composing feedback controllers is hard.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-10
SLIDE 10

Introduction Our Approach Results Summary Design Implementation

Outline

1

Introduction Problem Description Previous Approaches

2

Our Approach Design Implementation

3

Results Timeliness Fairness

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-11
SLIDE 11

Introduction Our Approach Results Summary Design Implementation

Key Ideas

Time-sensitive applications can cooperate with kernel and each other

Applications include a user level scheduler

Inform kernel of timing needs

new system call: coop_poll()

Kernel facilitates and coordinates this information exchange Kernel offers protection against mis-behaving applications

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-12
SLIDE 12

Introduction Our Approach Results Summary Design Implementation

Architecture

Timers Best-effort Application Event Scheduler Cooperative Threads Best-effort Threads

User Space Kernel Space

Thread Scheduler Thread 5, Group D Thread 4, Group D Thread 3, Group C Thread 2, Group B Thread 1, Group A Fair-share Virtual times (per-group)

G A G C G D G B U 5 R 5

Cooperative Group D Group C Release times (per-thread across groups)

R 5 R 4 R 3

User Virtual times (per-thread within group)

U 4 U 5

coop_poll

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-13
SLIDE 13

Introduction Our Approach Results Summary Design Implementation

User Level Programming Model

Reactive event loop

Two types of events - Best Effort, Timer Short running events

stack-rip loops or use coroutines

Use non-blocking I/O as much as possible.

Adaptive applications

reduce events (best-effort) during overload

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-14
SLIDE 14

Introduction Our Approach Results Summary Design Implementation

Application Example

recv_video_frame(player, frame) { frame.decode_event = { type = BEST_EFFORT, user_virtual_time = decoder_get_virtual_time(frame), callback.fn = decode_video_frame }; submit(frame.decode_event) frame.expire_event= { type = TIMER, release = decoder_get_release_time(frame), callback.fn = expire_video_frame }; submit(frame.expire_event); }

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-15
SLIDE 15

Introduction Our Approach Results Summary Design Implementation

Application Example (cont’d)

decode_video_frame(player, frame) { cancel(player.loop, frame.expire_event); if (decompress(frame) != DONE) { submit(frame.decode_event); return; } frame.display_event = { type = TIMER; release = player.start + frame.pts; callback.fn = display_video_frame }; submit(frame.display_event); } expire_video_frame(player, frame) { cancel(frame.decode_event); } display_video_frame(player, frame) { put_image(player.display, frame.image); }

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-16
SLIDE 16

Introduction Our Approach Results Summary Design Implementation

Kernel Fairshare Scheduler

Weighted fairshare scheduler. Virtual time:

Use high-resolution accounting to measure execution time. Vitual time = weight × measured. Not allowed to accumulate virtual time by sleeping.

Task with lowest virtual time picked for execution. Timeslice = Period / Number of runnable tasks.

lower bound enforced to prevent excessive context switches

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-17
SLIDE 17

Introduction Our Approach Results Summary Design Implementation

Coop_Poll Call

Coop_Poll connects user level scheduler to kernel scheduler.

Input ← Earliest local release-time & user virtual time. Output → CPU-wide earliest release-time & group-wide earliest virtual time.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-18
SLIDE 18

Introduction Our Approach Results Summary Design Implementation

Coop_Poll in the kernel scheduler

Timeslice calculation (amended)

Timeslice = min(Period/N, Time till next release-time) Sets output param of coop_poll.

fairness vs timeliness?

If release-time is due override fairness choice, but force task to yield quickly: set output release-time = now. Allows temporary unfairness, subject to following limit.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-19
SLIDE 19

Introduction Our Approach Results Summary Design Implementation

Mis-behaving Applications

Un-cooperative behavior:

Does not yield on time (now − release time > coop slack). Non-cooperative yield (page fault, IO, sleep, i.e. not coop_poll). Exceeds unfairness threshold (Task VT − Min VT > Unfairness Threshold).

Kernel demotes task to best-effort status

Temporary effect, status regained next time coop_poll is called.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-20
SLIDE 20

Introduction Our Approach Results Summary Design Implementation

Coop_Poll in the user level event scheduler

The event loop yields the CPU only via coop_poll. The output parameters of coop_poll are translated into proxy events:

Two proxies: timer and best-effort. Proxy events yield the CPU via coop_poll.

Application defined fairness via thread groups.

Whole group shares the same virtual time. User defined fairness within group.

Best-effort events contain application specified virtual time. e.g. cumulative fps, cumulative utility

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-21
SLIDE 21

Introduction Our Approach Results Summary Design Implementation

Outline

1

Introduction Problem Description Previous Approaches

2

Our Approach Design Implementation

3

Results Timeliness Fairness

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-22
SLIDE 22

Introduction Our Approach Results Summary Design Implementation

Scheduler Implementation

Implemented scheduler and coop poll in Linux kernel

Two versions: pre and post CFS (2.6.22 and 2.6.25). Simple tickless design:

  • ne shot high resolution timers.

High resolution accounting.

Previously prototyped approach at user level.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-23
SLIDE 23

Introduction Our Approach Results Summary Design Implementation

Cooperative Applications

QStream Adaptive Video Streaming

ideal candidate - event based, adaptive, short running events.

X11 display server.

Event based, but non-adaptive. Extend Xsync to support high res timers Incorporate integrated Coop_Poll 0.3% LOC changed (Excluding extensions).

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-24
SLIDE 24

Introduction Our Approach Results Summary Timeliness Fairness

Outline

1

Introduction Problem Description Previous Approaches

2

Our Approach Design Implementation

3

Results Timeliness Fairness

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-25
SLIDE 25

Introduction Our Approach Results Summary Timeliness Fairness

Experimental Setup

Pentium 4 3.0 Ghz, Nvidia NV43 GPU Kernel based on Linux 2.6.25, Preemption, High-Resolution Timers, SMP enabled 20 ms global period, 20 ms unfairness threshold, 100 us min timeslice, 2 ms coop_slack Compare with CFS and Linux real-time.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-26
SLIDE 26

Introduction Our Approach Results Summary Timeliness Fairness

Baseline Timeliness

0.2 0.4 0.6 0.8 1 0.01 0.1 1 10 100 1000 Tardiness CDF Time (milliseconds) Coop Realtime Cfs

Single time-sensitive thread + 4 Background loads. Gives reference point for application granularity and best-case timeliness.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-27
SLIDE 27

Introduction Our Approach Results Summary Timeliness Fairness

Timeliness with Multiple Adaptive Applications

8 time-sensitive threads + 4 Background loads. Linux real-time priority doesn’t help here.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-28
SLIDE 28

Introduction Our Approach Results Summary Timeliness Fairness

Non-Adaptive Application(X11 Display Server)

8 Video Players(X11 enabled) + 4 Background loads. Player performance (not shown) similar to previous case.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-29
SLIDE 29

Introduction Our Approach Results Summary Timeliness Fairness

Mis-behaving Application

0.2 0.4 0.6 0.8 1 0.001 0.01 0.1 1 10 100 1000 Tardiness CDF Time (milliseconds) Mis-behaving thread Rest of the threads Xserver

Same workload as before, 1 player delaying yields with probability of 1%

Random delay ranging from 0 . . . 10 milliseconds.

Misbehaving task is the only one to suffer!

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-30
SLIDE 30

Introduction Our Approach Results Summary Timeliness Fairness

Limits of frequent context switching

Q: Why don’t we just use a high granularity periodic scheduler? e.g. Global period = 1 millisecond. Coop tardiness is 5x better with 4x fewer context switches.

Tardiness is still 5ms due to context switch plateau. 9348 Context Switches/Second vs 2211 Context Switches/Second.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-31
SLIDE 31

Introduction Our Approach Results Summary Timeliness Fairness

Outline

1

Introduction Problem Description Previous Approaches

2

Our Approach Design Implementation

3

Results Timeliness Fairness

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-32
SLIDE 32

Introduction Our Approach Results Summary Timeliness Fairness

Fairness for Adaptive Applications

8 Video players + 4 Background loads. Coop fairshare scheduler shown, results with Linux CFS (not shown) are similar. Coop achieves timeliness and fairness.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-33
SLIDE 33

Introduction Our Approach Results Summary Timeliness Fairness

CPU fairness != Quality Fairness

FPS per video (left graph) is chaotic. Video Bitrates (right graph) are indicative of videos’ busty requirements.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-34
SLIDE 34

Introduction Our Approach Results Summary Timeliness Fairness

Application-centric fairness

Equal user defined quality (fps) via user scheduling All players run in same Coop group

CPU within group allocated according to user specified virtual time.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-35
SLIDE 35

Introduction Our Approach Results Summary

Summary

Cooperative Polling is:

Split level user-kernel scheduling Kernel combines fair sharing base with timeliness through cooperative-polling Kernel facilitates cooperation and protects against misbehaviour. Supports resource and application centric fairness

Results indicate sub-millisecond timing requirements are attainable. Reconciles the conflict between best-effort and time-sensitive applications.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-36
SLIDE 36

Introduction Our Approach Results Summary

Future Work

Multiprocessor evaluation Integrate with thread library such as GNU Pth Other resource types—storage, network, memory. Implementing the concept in a hypervisor. Move of fast-path coop_poll to Linux vsyscall. Support for Linux scheduler groups/cgroups.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling

slide-37
SLIDE 37

Introduction Our Approach Results Summary

Questions?

All of our code is open source: http://qstream.org/ Please visit our poster/demo at the poster session.

Krasic, Saubhasik, Sinha, Goel Fair and Timely Scheduling via Cooperative Polling