Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hashed and Hierarchical Timing Wheels

Similar presentations


Presentation on theme: "Hashed and Hierarchical Timing Wheels"— Presentation transcript:

1 Hashed and Hierarchical Timing Wheels
A paper by George Varghese and Tony Lauck

2 Motivation Timers are important for Timer maintenance high if
Failure recovery, rate based flow control, scheduling algorithms, controlling packet lifetime in networks Timer maintenance high if Processor interrupted every clock tick Fine granularity timers are used # outstanding timers is high Efficient timer algorithms are required to reduce the overall interrupt overhead

3 Model & Performance Measure
Routines in the model Client Invoked : START_TIMER(Interval, Request_ID, Expiry_Action) STOP_TIMER(Request_ID) Timer tick invoked : PER_TICK_BOOKKEEPING EXPIRY_PROCESSING Performance Measure Space : Memory used by the data structures Latency : Time required to begin and end any of the routines mentioned above

4 Simple Timer Schemes (1 & 2)
a b a b c c d d e e f Scheme 1: Can maintain absolute expiry time or the timer interval START_TIMER = O(1) STOP_TIMER = O(1) PER_TICK_BOOKKEEPING = O(n) Scheme 2: maintain absolute expiry time START_TIMER = O(n) STOP_TIMER = O(1) PER_TICK_BOOKKEEPING = O(1)

5 Tree based timers (3) a a b b c c d d Can degenerate to a
linear list in case of equal Interval timers START_TIMER = O(n) STOP_TIMER = O(1) PER_TICK_BOOKKEEPING = O(1) Scheme 3: maintain absolute expiry time START_TIMER = O(log(n)) STOP_TIMER = O(1) PER_TICK_BOOKKEEPING = O(1)

6 Simple Timing Wheel (4) Scheme 4 Keep a large timing wheel
A cursor in the timing wheel moves one location every time unit (just like a seconds hand in the clock) If the timer interval is within a rotation from the current curser position then put the timer in the corresponding location 1 7 2 6 3 5 4 START_TIMER = O(1) STOP_TIMER = O(1) PER_TICK_BOOKKEEPING = O(1)

7 Hashed Timing Wheel (5+6)
# of rounds remaining Say wheel has 8 ticks Timer value = 17 Make 2 rounds of wheel + 1 more tick Schedule the timer in the bucket “1” Keep the # rounds with the timer At the expiry processing if the # rounds > 0 then reinsert the timer 2 4 1 7 2 6 3 1 2 5 4 2 1 1 2

8 Hashed Timing Wheel Scheme 5: Sorted Lists in each bucket
The list in each bucket can be insertion sorted Hence START_TIMER takes O(n) time in the worst case If n < WheelSize then average O(1) Scheme 6: Unsorted list in each bucket List can be kept unsorted to avoid worst case O(n) latency for START_TIMER However worst case PER_TICK_BOOKKEEPING = O(n) Again, if n < WheelSize then average O(1)

9 Hierarchical Timing Wheel
1 3 3 5 1 7 2 6 3 3 7 4 5 3 5 1 5 1 Hours wheel 7 2 6 3 4 7 5 5 1 7 2 1 1 2 6 3 Minutes wheel 4 5 Seconds wheel

10 Hierarchical Timing Wheels
Scheme 6, extension 2 START_TIMER = O(m) where m is the number of wheels The bucket value on each wheel needs to be calculated STOP_TIMER = O(1) PER_TICK_BOOKKEEPING = O(1) on avg.

11 Comparison Scheme Name Start Stop Per-Tick 1 Straightforward O(1) O(N)
2 Ordered List 3 Tree O(log(N)) 4 Simple Wheel* 5 Hashed Wheel (sorted) O(N) WC, O(1) Avg 6 Hashed Wheel (unsorted) O(N) WC, O(1) Avg 6-ext2 Hierarchical* O(m) *Overflow list


Download ppt "Hashed and Hierarchical Timing Wheels"

Similar presentations


Ads by Google