Lecture 4: scheduling: buffer managment

Download Report

Transcript Lecture 4: scheduling: buffer managment

‫‪Lecture 4: Nov 8, 2009‬‬
‫תזכורת‬
‫‪ ‬שבוע הבא אין הרצאה‬
‫‪ ‬יום א‪ ,‬נובמבר ‪2009 ,15‬‬
‫‪ ‬שיעור השלמה‬
‫‪ ‬יום שישי‪ ,‬דצמבר ‪2009 ,11‬‬
‫‪# 1‬‬
Lecture 4: Nov 8, 2009
Scheduling:
Buffer
Management
# 2
Lecture 4: Nov 8, 2009
The setting
# 3
Lecture 4: Nov 8, 2009
Buffer Scheduling
 Who
to send next?
 What happens when buffer is full?
 Who to discard?
# 4
Lecture 4: Nov 8, 2009
Requirements of scheduling
 An ideal scheduling discipline
 is easy to implement
 is fair and protective
 provides performance bounds

Each scheduling discipline makes a
different trade-off among these
requirements
# 5
Lecture 4: Nov 8, 2009
Ease of implementation
 Scheduling discipline has to make a decision
once every few microseconds!
 Should be implementable in a few instructions
or hardware


for hardware: critical constraint is VLSI space
Complexity of enqueue + dequeue processes
 Work per packet should scale less than
linearly with number of active connections
# 6
Lecture 4: Nov 8, 2009
Fairness
 Intuitively
 each
connection should get no more than
its demand
 the excess, if any, is equally shared
 But it also provides protection
 traffic hogs cannot overrun others
 automatically isolates heavy users
# 7
Max-min Fairness:
Single Buffer






Lecture 4: Nov 8, 2009
Allocate bandwidth equally among all users
If anyone doesn’t need its share, redistribute
maximize the minimum bandwidth provided to any flow not
receiving its request
To increase the smallest need to take from larger.
Consider fluid example.
Ex: Compute the max-min fair allocation for a set of four
sources with demands 2, 2.6, 4, 5 when the resource has a
capacity of 10.
• s1= 2;
• s2= 2.6;
• s3 = s4= 2.7

More complicated in a network.
# 8
Lecture 4: Nov 8, 2009
FCFS / FIFO Queuing
 Simplest Algorithm, widely used.
 Scheduling is done using first-in first-out
(FIFO) discipline
 All flows are fed into the same queue
# 9
Lecture 4: Nov 8, 2009
FIFO Queuing (cont’d)
 First-In First-Out (FIFO) queuing
First Arrival, First Transmission
 Completely dependent on arrival time
 No notion of priority or allocated buffers
 No space in queue, packet discarded

 Flows
can interfere with each other; No
isolation; malicious monopolization;

Various hacks for priority, random drops,...
# 10
Lecture 4: Nov 8, 2009
Priority Queuing
 A priority index is assigned to each packet upon arrival
 Packets transmitted in ascending order of priority index.


Priority 0 through n-1
Priority 0 is always serviced first
 Priority
i is serviced only if 0 through i-1 are empty
 Highest priority has the



lowest delay,
highest throughput,
lowest loss
 Lower priority classes may be starved by higher priority
 Preemptive and non-preemptive versions.
# 11
Lecture 4: Nov 8, 2009
Priority Queuing
Packet discard
when full
High-priority
packets
Transmission link
Low-priority
packets
Packet discard
when full
When
high-priority
queue empty
# 12
Lecture 4: Nov 8, 2009
Round Robin: Architecture
 Round Robin: scan class queues serving one from
each class that has a non-empty queue
Flow 1
Transmission link
Flow 2
Round robin
Flow 3
Hardware requirement:
Jump to next non-empty queue
# 13
Lecture 4: Nov 8, 2009
Round Robin Scheduling
 Round Robin: scan class queues serving one from
each class that has a non-empty queue
# 14
Lecture 4: Nov 8, 2009
Round Robin (cont’d)
 Characteristics:
Classify incoming traffic into flows (sourcedestination pairs)
 Round-robin among flows

 Problems:
 Ignores packet length (GPS, Fair queuing)
 Inflexible allocation of weights (WRR,WFQ)
 Benefits:
 protection against heavy users (why?)
# 15
Lecture 4: Nov 8, 2009
Weighted Round-Robin
 Weighted round-robin
 Different weight wi (per flow)
 Flow j can sends wj packets in a period.
 Period of length  wj
 Disadvantage
 Variable packet size.
 Fair only over time scales longer than a period time.
• If a connection has a small weight, or the number of
connections is large, this may lead to long periods of
unfairness.
# 16
Lecture 4: Nov 8, 2009
DRR (Deficit RR) algorithm
 Choose a quantum of bits to serve from each
connection in order.
 For each HoL (Head of Line) packet,





credit := credit + quantum
if the packet size is ≤ credit; send and save excess,
otherwise save entire credit.
If no packet to send, reset counter (to remain fair)
If some packet sent: counter = min{ excess, quantum }
 Each connection has a deficit counter (to store
credits) with initial value zero.
 Easier implementation than other fair policies

WFQ
# 17
Lecture 4: Nov 8, 2009
Deficit Round-Robin
 DRR can handle variable packet size
Quantum size : 1000 byte
2000
1000
1500
500 300
1200
Second
Round
First
Round
 1st Round
 A’s count : 1000
0
 B’s count : 200 (served twice)
A
 C’s count : 1000
 2nd Round
B
 A’s count : 500 (served)
 B’s count : 0
C
 C’s count : 800 (served)
Head of
Queue
# 18
Lecture 4: Nov 8, 2009
DRR: performance
 Handles variable length packets fairly
 Backlogged sources share bandwidth equally
 Preferably, packet size < Quantum
 Simple to implement

Similar to round robin
# 19
Lecture 4: Nov 8, 2009
Generalized
Processor
Sharing
# 20
Lecture 4: Nov 8, 2009
Generalized Process Sharing (GPS)
 The methodology:

Assume we can send infinitesimal packets
• single bit

Perform round robin.
• At the bit level
 Idealized policy to split bandwidth
 GPS is not implementable
 Used mainly to evaluate and compare real
approaches.
 Has weights that give relative frequencies.
# 21
Lecture 4: Nov 8, 2009
GPS: Example 1
40
30
A
20
B
C
10
0
30
Packets of size 10, 20 & 30
arrive at time 0
50
60
# 22
Lecture 4: Nov 8, 2009
GPS: Example 2
GPS example 2
25
queue size
20
A
15
B
10
C
5
0
5
15
30
40
45
time
Packets: time 0 size 15
time 5 size 20
time 15 size 10
# 23
Lecture 4: Nov 8, 2009
GPS: Example 3
GPS examlpe 3
25
queue size
20
15
A
10
B
C
5
0
5
15
Packets: time 0
time 5
time 15
time 18
30
time
size
size
size
size
45
15
20
10
15
60
# 24
Lecture 4: Nov 8, 2009
GPS : Adding weights
 Flow j has weight wj
 The output rate of flow j, Rj(t) obeys:
d
R (t )  R j (t ) 
dt
'
j

wj
k ACTIVE ( t )
wk
 For the un-weighted case (wj=1):
d
1
R (t )  R j (t ) 
dt
| ACTIVE(t ) |
'
j
# 25
Lecture 4: Nov 8, 2009
Fairness using GPS
 Non-backlogged connections, receive what
they ask for.
 Backlogged connections share the remaining
bandwidth in proportion to the assigned
weights.
 Every backlogged connection i, receives a
service rate of :
R (t ) 
'
i
Active(t): the set of
backlogged flows at time t
wi
 jACTIVE
(t )
wj
# 26
Lecture 4: Nov 8, 2009
GPS: Measuring unfairness
 No packet discipline can be as fair as GPS
while a packet is being served, we are unfair to others
Degree of unfairness can be bounded
Define: workA (i,a,b) = # bits transmitted for flow i in time
[a,b] by policy A.
Absolute fairness bound for policy S
 Max (workGPS(i,a,b) - workS(i, a,b))
Relative fairness bound for policy S
 Max (workS(i,a,b) - workS(j,a,b))
assuming both i and j are backlogged in [a,b]





# 27
Lecture 4: Nov 8, 2009
GPS: Measuring unfairness
fixed packet size and round robin
 Relative bound: 1
 Absolute bound: 1-1/n
 Assume

n is the number of flows
 Challenge: handle variable size packets.
# 28
Lecture 4: Nov 8, 2009
Weighted Fair
Queueing
# 29
Lecture 4: Nov 8, 2009
GPS to WFQ
 We can’t implement GPS
 So, lets see how to emulate it
 We want to be as fair as possible
 But also have an efficient implementation
# 30
Lecture 4: Nov 8, 2009
# 31
Lecture 4: Nov 8, 2009
GPS vs WFQ (equal length)
Queue 1
@ t=0
GPS:both packets
served at rate 1/2
1
Queue 2
@ t=0
Both packets complete
service at t=2
t
0
1
Packet from
queue 2 waiting
2
Packet-by-packet system (WFQ):
queue 1 served first at rate 1;
then queue 2 served at rate 1.
1
Packet from
queue 1 being
served
Packet from queue 2
being served
t
0
1
2
# 32
Lecture 4: Nov 8, 2009
GPS vs WFQ (different length)
2
Queue 1
@ t=0
GPS: both packets served
at rate 1/2
1
Queue 2
@ t=0
Packet from queue
2 served at rate 1
0
2
t
3
Packet from
queue 2 waiting
queue 2 served at rate 1
1
Packet from
queue 1 being
served at rate 1
0
1
2
t
3
# 33
Lecture 4: Nov 8, 2009
GPS vs WFQ
Queue 1
@ t=0
GPS: packet from queue 1
served at rate 1/4;
Queue 2
@ t=0
1
Packet from queue 1
served at rate 1
Weight:
Packet from queue 2
Queue 1=1
served at rate 3/4
Queue 2 =3
t
0
1
Packet from
queue 1 waiting
2
WFQ: queue 2 served first at rate 1;
then queue 1 served at rate 1.
1
Packet from queue 1
being served
Packet from
queue 2 being
served
t
0
1
2
# 34
Lecture 4: Nov 8, 2009
Completion times
 Emulating a policy:
Assign each packet p a value time(p).
 Send packets in order of time(p).

 FIFO:
 Arrival of a packet p from flow j:
last = last + size(p);
time(p)=last;
 perfect emulation...
# 35
Lecture 4: Nov 8, 2009
Round Robin Emulation
 Round Robin (equal size packets)
Arrival of packet p from flow j:
 last(j) = last(j)+ 1;
 time(p)=last(j);
 Idle queue not handle properly!!!

 Sending packet q: round = time(q)
 Arrival: last(j) = max{round,last(j)}+ 1
 time(p)=last(j);
 What kind of low level scheduling?
# 36
Lecture 4: Nov 8, 2009
Round Robin Emulation
 Round Robin (equal size packets)
Sending packet q:
 round = time(q); flow_num = flow(q);
 Arrival:
 last(j) = max{round,last(j) }+1
 IF (j >= flow_num) & (last(j)=round)
THEN last(j)=last(j)-1
 time(p)=last(j);

 What kind of low level scheduling?
# 37
Lecture 4: Nov 8, 2009
GPS emulation (WFQ)
 Arrival of p from flow j:
 last(j)= max{last(j), round} + size(p);
 using weights:
last(j)= max{last(j), round} + size(p)/wj;
 How should we compute the round?
 We like to simulate GPS:
 x is the period of time in which #active did not change
 round(t+x) = round(t) + x/B(t)
 B(t) = # active flows
(unweighted case)
• B(t) = sum of weights of active flows
(weighted case)
 A flow j is active while round(t) < last(j)
# 38
Lecture 4: Nov 8, 2009
WFQ: Example (GPS view)
1
½
0
1
0
1/2
2
3
5/6
7/6
4
11/6
t
round
Note that if in a time interval round progresses by amount x
Then every non-empty buffer is emptied by amount x during the interval
# 39
Lecture 4: Nov 8, 2009
WFQ: Example (equal size)
Time 0: packets arrive to flow 1 & 2.
last(1)= 1; last(2)= 1; Active = 2
round (0) =0; send 1
Time 1: A packet arrives to flow 3
round(1) = 1/2; Active = 3
last(3) = 3/2; send 2
Time 2: A packet arrives to flow 4.
round(2) = 5/6; Active = 4
last(4) = 11/6; send 3
Time
Time
Time
Time
2+2/3:
3 :
3+2/3:
4 :
round
round
round
round
=
=
=
=
1; Active = 2
7/6 ; send 4;
3/2; Active = 1
11/6 ; Active=0
# 40
Lecture 4: Nov 8, 2009
WFQ: Example (GPS view)
1
½
0
1
0
1/2
2
3
5/6
7/6
4
11/6
t
round
Note that if in a time interval round progresses by amount x
Then every non-empty buffer is emptied by amount x during the interval
# 41
Lecture 4: Nov 8, 2009
Worst Case Fair
Weighted Fair
2
Queuing (WF Q)
# 42
Worst Case Fair Weighted Fair Queuing
(WF2Q)
Lecture 4: Nov 8, 2009
 WF2Q fixes an unfairness problem in WFQ.
 WFQ: among packets waiting in the system, pick
one that will finish service first under GPS
 WF2Q: among packets waiting in the system,
that have started service under GPS, select one
that will finish service first GPS
 WF2Q provides service closer to GPS
 difference in packet service time bounded by
max. packet size.
# 43
Lecture 4: Nov 8, 2009
# 44
Lecture 4: Nov 8, 2009
# 45
Lecture 4: Nov 8, 2009
# 46
Lecture 4: Nov 8, 2009
# 47
Lecture 4: Nov 8, 2009
Multiple Buffers
# 48
Lecture 4: Nov 8, 2009
Buffers
Fabric
Buffer locations
 Input ports
 Output ports
 Inside fabric
 Shared Memory
 Combination of all
# 49
Lecture 4: Nov 8, 2009
fabric
Outputs
Inputs
Input Queuing
# 50
Lecture 4: Nov 8, 2009
Input Buffer : properties
•
•
•
•
•
Input speed of queue – no more than input line
Need arbiter (running N times faster than input)
FIFO queue
Head of Line (HoL) blocking .
Utilization:
• Random destination
• 1- 1/e = 59% utilization
• due to HoL blocking
# 51
Head of Line Blocking
Lecture 4: Nov 8, 2009
# 52
Lecture 4: Nov 8, 2009
# 53
Lecture 4: Nov 8, 2009
# 54
Lecture 4: Nov 8, 2009
Overcoming HoL blocking:
look-ahead
 The fabric looks ahead into the input
buffer for packets that may be
transferred if they were not blocked by
the head of line.
 Improvement depends on the depth of the
look ahead.
 This corresponds to virtual output queues
where each input port has buffer for each
output port.
# 55
Input Queuing
Lecture 4: Nov 8, 2009
Virtual output queues
# 56
Lecture 4: Nov 8, 2009
Overcoming HoL blocking:
output expansion
 Each output port is expanded to L output
ports
 The fabric can transfer up to L packets to
the same output instead of one cell.
Karol and Morgan,
IEEE transaction on communication, 1987: 1347-1356
# 57
Input Queuing
Lecture 4: Nov 8, 2009
Output Expansion
L
fabric
# 58
Lecture 4: Nov 8, 2009
Output Queuing
The “ideal”
2
1
1
2
1
2 1
2
11
2
2
1
# 59
Lecture 4: Nov 8, 2009
Output Buffer : properties
 No HoL problem
 Output queue needs to run faster than input lines
 Need to provide for N packets arriving to same
queue
 solution: limit the number of input lines that can be
destined to the output.
# 60
Lecture 4: Nov 8, 2009
MEMORY
FABRIC
FABRIC
Shared Memory
a common pool of buffers divided into
linked lists indexed by output port number
# 61
Lecture 4: Nov 8, 2009
Shared Memory: properties
•
•
•
•
Packets stored in memory as they arrive
Resource sharing
Easy to implement priorities
Memory is accessed at speed equal to sum of
the input or output speeds
• How to divide the space between the sessions
# 62