30
7/23/2019 Lottery Scheduling http://slidepdf.com/reader/full/lottery-scheduling 1/30 LOTTERY SCHEDULING: FLEXIBLE PROPORTIONAL- SHARE RESOURCE MANAGEMENT Carl A. Waldspurger William E. Weihl MIT LCS

Lottery Scheduling

  • Upload
    -

  • View
    221

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 1/30

LOTTERY SCHEDULING:FLEXIBLE PROPORTIONAL-

SHARE RESOURCEMANAGEMENT

Carl A. WaldspurgerWilliam E. Weihl

MIT LCS

Page 2: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 2/30

Overview

• Lottery scheduling

–Gives variable numbers of lottery

tickets to processes–olds lotteries to decide !hich

thread !ill get the C"#

• "aper introduces currencies–$or allocating C"# among multiple

threads of a single user

Page 3: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 3/30

Traditi!a" #$%ed&"er#

• "riority schemes%

–"riority assignments often ad hoc

–&chemes using decay'usagescheduling are poorly understood

• ($air share) schemes ad*ust priorities

!ith a feedback loop to achievefairness

–+nly achieve long'term fairness

Page 4: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 4/30

Ltter' #$%ed&"i!(

• "riority determined by the number oftickets each thread has%

–"riority is the relative percentageof all of the tickets !hose o!nerscompete for the resource

• &cheduler picks !inning ticketrandomly, gives o!ner the resource

Page 5: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 5/30

E)a*+"e

• -hree threads

–A has tickets

–/ has 0 tickets–C has 1 tickets

• 2f all compete for the resource

–/ has 034 chance of being selected• 2f only / and C compete

–/ has 534 chance of being selected

Page 6: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 6/30

Ti$,et +r+ertie#

– Abstract:operate independently of machine

details–Relative:

chances of !inning the lotterydepends on contention level

–Uniform:can be used for many differentresources

Page 7: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 7/30

A!t%er adva!ta(e

• Lottery scheduling is starvation-free

–Every ticket holder will finally get

the resource

Page 8: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 8/30

Fair!e## a!a"'#i# I.

• Lottery scheduling is probabilisticallyfair 

• 2f a thread has a t  tickets out of T–2ts probability of !inning a lottery is  p

= t/T 

–2ts e6pected number of !ins over n 

dra!ings is np•/inomial distribution

•7ariance σ 2 = np/ 0 p.

Page 9: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 9/30

Fair!e## a!a"'#i# II.

• Coefficient of variation of number of !ins

σ/np = 1/-p.2np.

–8ecreases !ith 1 n

• 9umber of tries before !inning thelottery follo!s a geometric distribution

• As time passes, each thread endsreceiving its share of the resource

Page 10: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 10/30

Ti$,et tra!#3er#

• E6plicit transfers of tickets from oneclient to another

• -hey an be used !henever a clientblocks due to some dependency

–When a client !aits for a reply

from a server, it can temporarilytransfer its tickets to the server

• -hey eliminate priority inversions

Page 11: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 11/30

Ti$,et i!3"ati!

• Lets users create ne! tickets

–Like printing their o!n money

–Counterpart is ticket deflation

• ormally disallo!ed  e6cept amongmutually trusting clients

–Lets them to ad*ust their prioritiesdynamically !ithout e6plicitcommunication

Page 12: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 12/30

Ti$,et $&rre!$ie# I.

•  Consider the case of a usermanaging multiple threads

–Want to let her favor some threadsover others

–Without impacting the threads of

other users

Page 13: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 13/30

Ti$,et $&rre!$ie# II.

• Will let her create ne! tickets but !illdebase the individual values of all

the tickets she o!ns–er tickets !ill be e6pressed in a

ne! currency  that !ill have a

variable e"c#ange rate !ith thebase currency  

Page 14: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 14/30

E)a*+"e I.

• Ann manages three threads

–A has tickets

–/ has 0 tickets

–C has 1 tickets

• Ann creates e6tra tickets and assignsthem to process C

–Ann no! has : tickets

Page 15: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 15/30

E)a*+"e II.

• -hese : tickets represent : unitsof a ne! currency !hose e6change

rate !ith the base currency is :3;:

• -he total value of Ann tickets

e6pressed in the base currency is stille<ual to :3

Page 16: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 16/30

A!a"('

• When coins represented specificamounts of gold and silver

–A king could create ne! money=inflation> by minting coins !ith alesser amount of precious metal

–Worked !ell inside the kingdom

–E6change rate of ne! coins !ith coinsfrom other countries !ent do!n.

Page 17: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 17/30

C*+e!#ati! ti$,et# I.

• 2;+'bound threads are likely get lessthan their fair share of the C"#

because they often block before theirC"# <uantum e6pires

• Compensation tickets address thisimbalance

Page 18: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 18/30

C*+e!#ati! ti$,et# II.

•  A client that consumes only afraction f  of its C"# <uantum can be

granted a compensation ticket –-icket inflates the value of all

client tickets by :;f until the client

starts gets the C"#•(Wording in the paper is muchmore astract!

Page 19: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 19/30

E)a*+"e

• C"# <uantum is :33 ms

• Client A releases the C"# after 13ms

– f  4 567 r /28• 7alue of all tickets o!ned by A !ill

be multiplied by until A gets the

C"#

Page 20: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 20/30

C*+e!#ati! ti$,et# III.

• Compensation tickets

–$avor 2;+'bound?and interactive?

threads–elps them getting their fair share

of the C"#

Page 21: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 21/30

IMPLEMENTATION

• +n a @2"&'based 8ECstation running@ach 0 microkernel

–-ime slice is :33ms•"airly large as scheme does notallow preemption

• e<uires–A fast 9G

–A fast !ay to pick lottery !inner

Page 22: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 22/30

Pi$,i!( t%e wi!!er I.

• $irst idea%

–Assign to each client a range of

consecutive lottery ticket numbers–Create a list of clients

–#se 9G to generate a !inning

ticket number–&earch client list until !e find the

!inner

Page 23: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 23/30

E)a*+"e

• -hree threads

–A has tickets

–/ has 0 tickets–C has 1 tickets

• List contains

–A =3'B>–/ ='>

–C =D'>

&earch time is +=n>!here n is list length

Page 24: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 24/30

Pi$,i!( t%e wi!!er II.

• /etter idea%

–$or larger n

–FA tree of partial ticket sums, !ithclients at the leavesF

Page 25: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 25/30

E)a*+"e

9

A

B C

;

;

<

<

Page 26: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 26/30

L!(-ter* 3air!e## I.

Page 27: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 27/30

L!(-ter* 3air!e## II.

• Allocation ratio is ratio of numbers oftickets allocated to the t!o tasks

• @easurements made over a 53 sinterval

• Actual allocation fairly close toallocation ratio e6cept for :3%: ratio

–esulted in an average ratio of :0.B1

– Gets better over longer intervals

Page 28: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 28/30

S%rt ter* 3"&$t&ati!#

$or1%:ticket

alloc.ratio

Page 29: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 29/30

=%at t%e +a+er de# !t #a'

• #$% straightforward implementation oflottery scheduling does not provide theresponsiveness for a mi&ed interactive andC')ound workload offered y the decayusage priority scheduler of the "ree*S+operating system,

• Moreover- standard lottery schedulingignores kernel priorities used in the"ree*S+ scheduler to reduce kernel lockcontention,

Page 30: Lottery Scheduling

7/23/2019 Lottery Scheduling

http://slidepdf.com/reader/full/lottery-scheduling 30/30

=%at t%e +a+er de# !t #a'

• uotes are from%

– 8. "etrou, H. W. @ilford, and G. A.

Gibson, 2mplementing Lottery&cheduling% @atching the &pecialiIationsin -raditional &chedulers, 'roc, SE.I/

011- Monterey C$- 2une 1)33- 3111,