203

Algorithmic Techniques to overcome the I/O Bottleneck

  • Upload
    rbarve

  • View
    220

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 1/203

C o p y r i g h t  

  1 9 9 9 b y R a k e s h D i l i p B a r v e  

A l l r i g h t s r e s e r v e d  

Page 2: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 2/203

A L G O R I T H M I C T E C H N I Q U E S T O O V E R C O M E T H E I / O      

B O T T L E N E C K        

b y 

R a k e s h D i l i p B a r v e  

D e p a r t m e n t o f D e p a r t m e n t o f C o m p u t e r S c i e n c e  

D u k e U n i v e r s i t y  

D a t e :  

A p p r o v e d :  

J e r e y S . V i t t e r , S u p e r v i s o r  

P a n k a j A g a r w a l  

L a r s A r g e  

J e r e y C h a s e  

G r e g o r y L a w l e r  

D i s s e r t a t i o n s u b m i t t e d i n p a r t i a l f u l l l m e n t o f t h e  

r e q u i r e m e n t s f o r t h e d e g r e e o f D o c t o r o f P h i l o s o p h y  

i n t h e D e p a r t m e n t o f D e p a r t m e n t o f C o m p u t e r S c i e n c e  

i n t h e G r a d u a t e S c h o o l o f  

D u k e U n i v e r s i t y  

1 9 9 8  

Page 3: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 3/203

A B S T R A C T      

( C o m p u t e r S c i e n c e { A l g o r i t h m s )  

A L G O R I T H M I C T E C H N I Q U E S T O O V E R C O M E T H E I / O      

B O T T L E N E C K        

b y 

R a k e s h D i l i p B a r v e  

D e p a r t m e n t o f D e p a r t m e n t o f C o m p u t e r S c i e n c e  

D u k e U n i v e r s i t y  

D a t e :  

A p p r o v e d :  

J e r e y S . V i t t e r , S u p e r v i s o r  

P a n k a j A g a r w a l  

L a r s A r g e  

J e r e y C h a s e  

G r e g o r y L a w l e r  

A n a b s t r a c t o f a d i s s e r t a t i o n s u b m i t t e d i n p a r t i a l  

f u l l l m e n t o f t h e r e q u i r e m e n t s f o r t h e d e g r e e  

o f D o c t o r o f P h i l o s o p h y i n t h e D e p a r t m e n t o f  

D e p a r t m e n t o f C o m p u t e r S c i e n c e i n t h e G r a d u a t e S c h o o l o f  

D u k e U n i v e r s i t y  

1 9 9 8  

Page 4: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 4/203

A b s t r a c t    

T h e I / O b o t t l e n e c k i s t h e b o t t l e n e c k i n t h e p e r f o r m a n c e o f l a r g e s c a l e c o m p u t i n g a p p l i c a t i o n s c a u s e d b y t h e ( w i d e n i n g )  

g a p i n t h e p e r f o r m a n c e o f f a s t C P U a n d i n t e r n a l m e m o r y o n t h e o n e h a n d , a n d s l o w e r e x t e r n a l m e m o r y d e v i c e s o n  

t h e o t h e r . T h i s d i s p a r i t y i n p e r f o r m a n c e i s a w e l l - k n o w n p r o b l e m , s o r e s e a r c h e r s h a v e d e v e l o p e d s e v e r a l a p p r o a c h e s  

t o a l l e v i a t e t h e e e c t s o f t h e I / O b o t t l e n e c k . I n t h i s t h e s i s , w e p r e s e n t a l g o r i t h m i c t e c h n i q u e s r e l e v a n t t o s o m e o f  

t h e s e a p p r o a c h e s t o o v e r c o m e t h e I / O p r o b l e m .  

O n e u s e f u l a p p r o a c h i s f o r t h e o p e r a t i n g s y s t e m t o i m p l e m e n t c l e v e r c a c h i n g o r p r e f e t c h i n g s t r a t e g i e s , s o t h a t  

a c c e s s e d d a t a i s a l w a y s i n i n t e r n a l m e m o r y a s f a r a s p o s s i b l e . W e p r e s e n t a n a p p l i c a t i o n - c o n t r o l l e d p a g i n g a l g o r i t h m  

t o m a n a g e a c a c h e s h a r e d b y s e v e r a l c o m p e t i n g a p p l i c a t i o n s ; u s i n g t h e f r a m e w o r k o f c o m p e t i t i v e a n a l y s i s , w e p r o v e  

t h a t t h a t u s i n g h i n t s f r o m a p p l i c a t i o n s c a n r e s u l t i n s i g n i c a n t i m p r o v e m e n t s i n p a g i n g p e r f o r m a n c e c o m p a r e d t o  

p r e v i o u s a p p r o a c h e s . U s i n g h i n t s f r o m a p p l i c a t i o n s t o i n c o r p o r a t e l o c a l i t y o f r e f e r e n c e o f i n d i v i d u a l a p p l i c a t i o n s i n t o  

t h e p a g i n g m o d e l r e p r e s e n t s a s i g n i f c a n t l y d i e r e n t a p p r o a c h f r o m p r e v i o u s t h e o r e t i c a l a p p r o a c h e s t o i n c o r p o r a t e  

l o c a l i t y o f r e f e r e n c e .  

A n o t h e r a p p r o a c h t o i m p r o v e I / O p e r f o r m a n c e i s t o d e v e l o p a p p l i c a t i o n s u s i n g c u s t o m - m a d e I / O a l g o r i t h m s .  

W e p r e s e n t a n I / O a l g o r i t h m c a l l e d s i m p l e r a n d o m i z e d m e r g e s o r t ( S R M ) , t o p e r f o r m e x t e r n a l s o r t i n g u s i n g p a r a l l e l  

d i s k s . M e r g e s o r t i s w i d e l y u s e d f o r e x t e r n a l m e m o r y s o r t i n g , b u t s o m e d i c u l t i e s i n h e r e n t t o e x t e r n a l m e r g i n g h a v e  

t o b e o v e r c o m e i n o r d e r t o a d a p t i t t o u s e p a r a l l e l d i s k s . S R M i s s i m p l e , h a s p r o v a b l y e c i e n t I / O p e r f o r m a n c e ,  

a n d i s a t t r a c t i v e f o r p r a c t i c a l i m p l e m e n t a t i o n . T h e a n a l y s i s u s e d t o b o u n d S R M ' s p e r f o r m a n c e i n c l u d e s i n t e r e s t i n g  

r e d u c t i o n s t o c e r t a i n m a x i m u m o c c u p a n c y p r o b l e m s .  

R e c e n t d e v e l o p m e n t s i n d a t a b a s e s y s t e m s n e c e s s i t a t e t h e d e v e l o p m e n t o f e x t e r n a l m e m o r y a p p l i c a t i o n s c a p a b l e  

o f e c i e n t I / O p e r f o r m a n c e w h i l e a d a p t i n g t o d y n a m i c , u n p r e d i c t a b l e , u c t u a t i o n s i n t h e i r m e m o r y a l l o c a t i o n s . D e -  

s i g n i n g s u c h a p p l i c a t i o n s r e q u i r e s i n c o r p o r a t i n g n o t i o n s o f o n l i n e a l g o r i t h m s w i t h t e c h n i q u e s u s e d i n I / O a l g o r i t h m s .  

W e p r e s e n t a t h e o r e t i c a l f r a m e w o r k f o r s u c h \ m e m o r y - a d a p t i v e " a l g o r i t h m s : W e p r e s e n t a c o m p u t a t i o n a l m o d e l t o  

d e s i g n a n d a n a l y z e m e m o r y - a d a p t i v e a l g o r i t h m s , n o t i o n s o f o p t i m a l i t y , a n d l o w e r b o u n d s a n d o p t i m a l ( t o w i t h i n  

c o n s t a n t f a c t o r s ) a l g o r i t h m s f o r s o r t i n g , m a t r i x m u l t i p l i c a t i o n a n d r e l a t e d p r o b l e m s .  

A c o m m o n a p p r o a c h t o i m p r o v e I / O p e r f o r m a n c e i s t o e m p l o y m a n y d i s k s i n p a r a l l e l , o r g a n i z i n g t h e m u s i n g  

o n e o r m o r e I / O b u s e s w i t h s e v e r a l d i s k s o n e a c h b u s . M o t i v a t e d b y t h e c o m p l e x i t y o f s u c h s y s t e m s , w e p r e s e n t a n  

a c c u r a t e a n a l y t i c a l m o d e l o f t h e i r I / O p e r f o r m a n c e o n i n t e r e s t i n g w o r k l o a d s r e l e v a n t t o I / O a l g o r i t h m s a n d o t h e r  

l a r g e - s c a l e a p p l i c a t i o n s . W e p r e s e n t a s i m p l e t e c h n i q u e , b a s e d o n i n s i g h t s g a i n e d f r o m o u r e x p e r i m e n t s , t h a t r e s u l t s  

i n s i g n i c a n t I / O p e r f o r m a n c e i m p r o v e m e n t i n c e r t a i n s i t u a t i o n s .  

F i n a l l y , w e p r e s e n t a n i m p l e m e n t a t i o n o f S R M , u s i n g s i m p l e a n d p r a c t i c a l d a t a s t r u c t u r e s a n d t e c h n i q u e s . W e  

p r e s e n t a c o m p a r i s o n o f o u r S R M i m p l e m e n t a t i o n w i t h a n i m p l e m e n t a t i o n o f t h e p o p u l a r d i s k s t r i p e d m e r g e s o r t  

( D S M ) a l g o r i t h m , s h o w i n g t h a t S R M o u t p e r f o r m s D S M a n d i s e c i e n t i n p r a c t i c e .  

i v 

Page 5: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 5/203

A c k n o w l e d g e m e n t s    

M a n y p e o p l e { p e e r s , c o l l e a g u e s , t e a c h e r s , f r i e n d s , a n d f a m i l y { h a v e ( d i r e c t l y o r i n d i r e c t l y ) p l a y e d a p o s i t i v e r o l e  

w i t h r e s p e c t t o t h i s t h e s i s , a n d I a m g r a t e f u l t o a l l o f t h e m .  

I w o u l d l i k e t o t h a n k m y t h e s i s s u p e r v i s o r , J e V i t t e r , f o r g u i d i n g m e t h r o u g h m y t h e s i s . I h a v e l e a r n t a t r e m e n d o u s  

a m o u n t a b o u t v a r i o u s t e c h n i c a l a n d n o n - t e c h n i c a l a s p e c t s o f c o m p u t e r s c i e n c e r e s e a r c h f r o m m y i n t e r a c t i o n s w i t h  

h i m o v e r t h e p a s t v e y e a r s .  

I w o u l d a l s o l i k e t o t h a n k L a r s A r g e f o r m a n y u s e f u l d i s c u s s i o n s a b o u t I / O a l g o r i t h m s a n d T P I E , J e C h a s e  

f o r u s e f u l d i s c u s s i o n s a n d h e l p r e l e v a n t t o i m p l e m e n t a t i o n s o f e x t e r n a l m e m o r y a l g o r i t h m s , a n d P a n k a j A g a r w a l f o r  

i n t e r e s t i n g d i s c u s s i o n s a n d t h e c o u r s e s h e t a u g h t .  

M y s t a y a t D u k e U n i v e r s i t y w a s m a d e p l e a s a n t a n d e n j o y a b l e b e c a u s e o f m a n y f r i e n d s : T h o m a s A l e x a n d e r , A m i t  

B a g g a , K a u s a r B a n o o , S u b h r a j i t B h a t t a c h a r y a , P a v a n D e s i k a n , S a c h i n G a r g , R a n j i t G u p t a , P . K r i s h n a n , J a g d i s h  

K r i s h n a s w a m y , V i s h a l L u l l a , T . M . M u r a l i , G h a z a l a S h a h b u d d i n , R a j e s h R a o a n d K a s t u r i V a r a d a r a j a n .  

I a m i m m e n s e l y g r a t e f u l t o m y w i f e S h a l i n i P i l l a y - B a r v e , f o r b e i n g w i t h m e d u r i n g t h e l a s t y e a r o f m y d i s s e r t a t i o n  

w o r k , f o r h e r l o v e , c a l m i n g p r e s e n c e , c o n s t a n t s u p p o r t , a n d t h e w o n d e r f u l t i m e s . I a m i n d e b t e d t o R e k h a a n d D i l i p  

B a r v e f o r b e i n g s u c h w o n d e r f u l p a r e n t s : F o r t h e p a s t t w e n t y - s i x y e a r s , I c o u l d a l w a y s c o u n t o n t h e i r l o v e , g u i d a n c e ,  

a n d b e l i e f i n m y a b i l i t i e s . I t h a n k m y b r o t h e r N e i l f o r h i s l o v e a n d f r i e n d s h i p .  

C r e d i t s    

I w o u l d l i k e t o a c k n o w l e d g e c o - a u t h o r s w i t h w h o m I h a v e h a d t h e o p p o r t u n i t y t o i n t e r a c t f r u i t f u l l y , w h i l e w o r k i n g  

o n t h e m a t e r i a l p r e s e n t e d i n t h i s t h e s i s . I c o l l a b o r a t e d w i t h E d d i e G r o v e a n d J e V i t t e r w h i l e w o r k i n g o n m a t e r i a l  

p r e s e n t e d i n C h a p t e r 2 a n d C h a p t e r 3 , w i t h J e V i t t e r w h i l e w o r k i n g o n m a t e r i a l i n C h a p t e r 4 a n d C h a p t e r 5 , a n d  

w i t h L i d d y S h r i v e r , P h i l G i b b o n s , B r u c e H i l l y e r , Y o s s i M a t i a s a n d J e V i t t e r w h i l e w o r k i n g o n m a t e r i a l i n C h a p t e r 6 .  

T h e w o r k p r e s e n t e d i n C h a p t e r 6 w a s p a r t l y c a r r i e d o u t w h e n I w a s v i s i t i n g B e l l L a b o r a t o r i e s .  

I a m g r a t e f u l f o r a d i s c u s s i o n w i t h G r e g L a w l e r i n w h i c h h e s u g g e s t e d a s i m p l i f c a t i o n t o t h e o r i g i n a l v e r s i o n o f  

o u r p r o o f o f T h e o r e m 7 p e r t a i n i n g t o t h e \ D e p e n d e n t M a x i m u m O c c u p a n c y " p r o b l e m d i s c u s s e d i n o f C h a p t e r 3 . A  

s i m i l a r s i m p l i c a t i o n w a s i n d e p e n d e n t l y c o m m u n i c a t e d b y D o n K n u t h a n d i n c o r p o r a t e d i n K n u 9 8 , S e c t i o n 5 . 4 . 9 ] i n  

h i s t r e a t m e n t o f t h e m a t e r i a l i n C h a p t e r 3 .  

I h a v e a v a i l e d o f c o m p u t i n g f a c i l i t i e s a t t h e c o m p u t e r s c i e n c e d e p a r t m e n t o f D u k e U n i v e r s i t y a n d i n t h e I n f o r m a t i o n  

S c i e n c e s C e n t e r o f B e l l L a b o r a t o r i e s i n c o u r s e o f m y t h e s i s w o r k .  

I g r a t e f u l l y a c k n o w l e d g e t h e n a n c i a l s u p p o r t p r o v i d e d t o m e b y a n I B M F e l l o w s h i p ( f r o m A u g u s t 1 9 9 5 t h r o u g h  

M a y 1 9 9 8 ) , a n d b y r e s e a r c h g r a n t s f r o m t h e N a t i o n a l S c i e n c e F o u n d a t i o n , a n d t h e A r m y R e s e a r c h O c e .  

Page 6: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 6/203

Page 7: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 7/203

3 . 1 I n t r o d u c t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2  

3 . 2 M a i n R e s u l t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 5  

3 . 2 . 1 B a c k g r o u n d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 5  

3 . 2 . 2 O v e r v i e w o f S R M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 6  

3 . 3 S R M D a t a L a y o u t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 9  

3 . 4 F o r e c a s t i n g F o r m a t a n d D a t a S t r u c t u r e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 0  

3 . 5 T h e S R M M e r g i n g P r o c e d u r e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2  

3 . 5 . 1 I n t e r n a l M e m o r y M a n a g e m e n t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2  

3 . 5 . 2 M a i n t a i n i n g t h e d y n a m i c p a r t i t i o n o f i n t e r n a l m e m o r y . . . . . . . . . . . . . . . . . . . . . . . 4 3  

3 . 5 . 3 M a i n t a i n i n g t h e F o r e c a s t i n g D a t a S t r u c t u r e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 4  

3 . 5 . 4 T e r m i n o l o g y a n d N o t a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 4  

3 . 5 . 5 I / O S c h e d u l i n g A l g o r i t h m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 5  

3 . 6 U s i n g P h a s e s t o C o u n t   P a r R e a d   O p e r a t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 7  

3 . 7 P r o b a b i l i s t i c A n a l y s i s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 0  

3 . 7 . 1 T h e D e p e n d e n t O c c u p a n c y P r o b l e m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1  

3 . 7 . 2 A s y m p t o t i c E x p a n s i o n s o f t h e M a x i m u m O c c u p a n c y . . . . . . . . . . . . . . . . . . . . . . . . 5 2  

3 . 7 . 3 P r o o f o f T h e o r e m 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1  

3 . 8 A D e t e r m i n i s t i c V a r i a n t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2  

3 . 9 C o m p a r i s o n s b e t w e e n S R M a n d D S M i n P r a c t i c e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3  

3 . 9 . 1 E x p r e s s i o n s f o r t h e n u m b e r o f I / O o p e r a t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3  

3 . 9 . 2 C o m p a r i s o n b a s e d u p o n e x p e c t e d w o r s t - c a s e p e r f o r m a n c e o f S R M . . . . . . . . . . . . . . . . 6 4  

3 . 9 . 3 U s i n g s i m u l a t i o n s t o c o u n t S R M ' s I / O o p e r a t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . 6 6  

3 . 1 0 R e a l i s t i c V a l u e s f o r P a r a m e t e r s   k  ,  D  , a n d   B  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 7  

3 . 1 1 C o n c l u s i o n s a n d R e l a t e d N o t e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 8  

4 D e s i g n a n d I m p l e m e n t a t i o n o f S R M i n T P I E 7 0  

4 . 1 I n t r o d u c t i o n a n d M o t i v a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1  

4 . 1 . 1 O u r C o n t r i b u t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3  

4 . 2 E x t e r n a l M e r g e s o r t P r e l i m i n a r i e s a n d P r e v i o u s W o r k . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4  

4 . 2 . 1 R u n F o r m a t i o n + M e r g i n g P a s s e s = M e r g e s o r t . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 5  

4 . 2 . 2 P a r t i c i p a t i o n O r d e r o f B l o c k s i n a M e r g e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 5  

4 . 2 . 3 P r e v i o u s W o r k o n E x t e r n a l M e r g i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 6  

v i i 

Page 8: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 8/203

4 . 2 . 4 P a r a l l e l D i s k M e r g i n g i n D S M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 7  

4 . 2 . 5 D i c u l t y o f M e r g i n g O p t i m a l l y w i t h P a r a l l e l I n d e p e n d e n t D i s k s . . . . . . . . . . . . . . . . . 7 7  

4 . 3 S R M A l g o r i t h m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 8  

4 . 3 . 1 T h e F o r e c a s t a n d F l u s h S c h e m e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 9  

4 . 3 . 2 P r o v a b l e P e r f o r m a n c e G u a r a n t e e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 0  

4 . 3 . 3 D a t a S t r u c t u r e s R e q u i r e d i n t h e S t r a i g h t f o r w a r d I m p l e m e n t a t i o n . . . . . . . . . . . . . . . . . 8 0  

4 . 4 I m p l e m e n t a t i o n T e c h n i q u e s a n d D a t a S t r u c t u r e s f o r S R M . . . . . . . . . . . . . . . . . . . . . . . . . 8 1  

4 . 4 . 1 M a n a g i n g F o r e c a s t i n g D a t a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1  

4 . 4 . 2 O t h e r D a t a S t r u c t u r e s a n d P r i m i t i v e O p e r a t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4  

4 . 4 . 3 B a s i c I d e a s o f O u r I m p l e m e n t a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 6  

4 . 4 . 4 A l g o r i t h m i c D e s c r i p t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 7  

4 . 5 P e r f o r m a n c e R e s u l t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 0  

4 . 5 . 1 C o m p u t e r S y s t e m a n d E n v i r o n m e n t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 0  

4 . 5 . 2 I n p u t C h a r a c t e r i s t i c s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1  

4 . 5 . 3 D S M a n d S R M C o n g u r a t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1  

4 . 5 . 4 P e r f o r m a n c e N u m b e r s a n d G r a p h s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3  

4 . 5 . 5 R e l a t i v e P e r f o r m a n c e C o m p a r i s o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 5  

4 . 5 . 6 I m p r o v i n g I / O P e r f o r m a n c e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 6  

4 . 6 O t h e r A p p l i c a t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 6  

4 . 6 . 1 D i s t r i b u t i o n S o r t a n d M u l t i - w a y P a r t i t i o n i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 6  

4 . 6 . 2 S t r e a m i n g T h r o u g h M u l t i m e d i a F i l e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 7  

4 . 7 C o n c l u s i o n s a n d F u t u r e W o r k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 7  

5 M e m o r y - A d a p t i v e E x t e r n a l M e m o r y A l g o r i t h m s 9 9  

5 . 1 I n t r o d u c t i o n a n d M o t i v a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0 0  

5 . 2 D y n a m i c M e m o r y M o d e l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0 2  

5 . 2 . 1 D y n a m i c a l l y O p t i m a l M e m o r y - A d a p t i v e A l g o r i t h m s . . . . . . . . . . . . . . . . . . . . . . . . 1 0 4  

5 . 3 M e m o r y - A d a p t i v e L o w e r B o u n d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0 4  

5 . 3 . 1 M e m o r y - A d a p t i v e L o w e r B o u n d s f o r P e r m u t i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0 7  

5 . 3 . 2 M e m o r y - A d a p t i v e L o w e r B o u n d s f o r S o r t i n g , F F T a n d P e r m u t a t i o n N e t w o r k s . . . . . . . . . 1 1 0  

5 . 3 . 3 M e m o r y - A d a p t i v e L o w e r B o u n d s f o r M a t r i x M u l t i p l i c a t i o n . . . . . . . . . . . . . . . . . . . . 1 1 1  

v i i i  

Page 9: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 9/203

5 . 4 D e s i g n i n g M e m o r y - A d a p t i v e A l g o r i t h m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 2  

5 . 4 . 1 O p t i m a l n o n - a d a p t i v e e x t e r n a l m e m o r y a l g o r i t h m s . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 3  

5 . 4 . 2 M i m i c k i n g O p t i m a l S t a t i c M e m o r y A l g o r i t h m s . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 3  

5 . 4 . 3 A d a p t i v e O r g a n i z a t i o n o f C o m p u t a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 3  

5 . 4 . 4 A l l o c a t i o n L e v e l s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 4  

5 . 5 A F r a m e w o r k f o r M e m o r y - A d a p t i v e M e r g e s o r t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 5  

5 . 5 . 1 M e m o r y - A d a p t i v e R u n F o r m a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 5  

5 . 5 . 2 M e m o r y - a d a p t i v e m e r g i n g s t a g e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 6  

5 . 5 . 3 R e s o u r c e c o n s u m p t i o n o f m e m o r y - a d a p t i v e e x t e r n a l m e r g e s o r t . . . . . . . . . . . . . . . . . . 1 1 7  

5 . 6 P o t e n t i a l o f a M e r g e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 9  

5 . 7 N o n o p t i m a l i t y o f a s i m p l e m e m o r y - a d a p t i v e m e r g e s o r t a l g o r i t h m . . . . . . . . . . . . . . . . . . . . . 1 2 0  

5 . 7 . 1 S k e t c h o f t h e m e m o r y - a d a p t i v e e x t e r n a l m e m o r y m e r g e s o r t . . . . . . . . . . . . . . . . . . . . 1 2 1  

5 . 7 . 2 L o w e r B o u n d o n R e s o u r c e C o n s u m p t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 3  

5 . 8 D y n a m i c a l l y O p t i m a l M e m o r y - A d a p t i v e S o r t i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 6  

5 . 8 . 1 O v e r v i e w . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 8  

5 . 8 . 2 R u n - R e c o r d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 0  

5 . 8 . 3 P r e p r o c e s s i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 4  

5 . 8 . 4 L e v e l - r e c o r d D a t a S t r u c t u r e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 6  

5 . 8 . 5 I n v a r i a n t s f o r r u n - r e c o r d s a n d l e v e l - r e c o r d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 7  

5 . 8 . 6 L o w - l e v e l M e r g e C o m p u t a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 9  

5 . 8 . 7 D o w n l o a d i n g W o r k f o r A d a p t i v i t y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 4 7  

5 . 8 . 8 P u t t i n g   d o w n l o a d   ( ) a n d   l l m e r g e   ( ) T o g e t h e r . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 3  

5 . 9 A n a l y s i s o f r e s o u r c e c o n s u m p t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 7  

5 . 9 . 1 R e s o u r c e C o n s u m p t i o n o f   d o w n l o a d   ( ) c a l l s , b a d   l l m e r g e   ( ) c a l l s a n d   l l m e r g e   (  r r 

g l o b a l  

) c a l l s . . 1 5 7  

5 . 9 . 2 P o t e n t i a l F u n c t i o n A r g u m e n t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 6 3  

5 . 9 . 3 O p t i m a l i t y o f R e s o u r c e C o n s u m p t i o n f o r S o r t i n g . . . . . . . . . . . . . . . . . . . . . . . . . . 1 6 6  

5 . 1 0 S o m e n o t e s o n t h e p o t e n t i a l f u n c t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 6 6  

5 . 1 1 D y n a m i c a l l y O p t i m a l P e r m u t i n g , F F T , a n d P e r m u t a t i o n N e t w o r k s . . . . . . . . . . . . . . . . . . . . 1 6 8  

5 . 1 1 . 1 P e r m u t i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 6 8  

5 . 1 1 . 2 D y n a m i c a l l y O p t i m a l F F T a n d P e r m u t a t i o n N e t w o r k s . . . . . . . . . . . . . . . . . . . . . . . 1 6 9  

5 . 1 2 M e m o r y - A d a p t i v e B u e r T r e e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 7 1  

i x 

Page 10: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 10/203

5 . 1 2 . 1 M e m o r y - a d a p t i v e b u e r e m p t y i n g o f i n t e r n a l n o d e s . . . . . . . . . . . . . . . . . . . . . . . . 1 7 2  

5 . 1 2 . 2 M e m o r y - a d a p t i v e b u e r e m p t y i n g o f o t h e r n o d e s . . . . . . . . . . . . . . . . . . . . . . . . . . 1 7 3  

5 . 1 3 D y n a m i c a l l y O p t i m a l M e m o r y - a d a p t i v e M a t r i x A r i t h m e t i c . . . . . . . . . . . . . . . . . . . . . . . . 1 7 5  

5 . 1 3 . 1 T r a n s f o r m a t i o n b e t w e e n d i e r e n t b l o c k i n g o r d e r s . . . . . . . . . . . . . . . . . . . . . . . . . . 1 7 5  

5 . 1 3 . 2 M e m o r y - a d a p t i v e M a t r i x M u l t i p l i c a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 7 7  

5 . 1 3 . 3 M o p R e c o r d s a n d L e v e l - R e c o r d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 7 8  

5 . 1 3 . 4 T h e   l o a d l e v e l  ( ) ,  d o w n l o a d   ( ) , a n d   l l m u l t  ( ) S u b r o u t i n e s . . . . . . . . . . . . . . . . . . . . . . 1 8 0  

5 . 1 3 . 5 A l g o r i t h m   M A M u l t i p l y   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 8 4  

5 . 1 3 . 6 R e s o u r c e C o n s u m p t i o n A n a l y s i s o f   M A M u l t i p l y   . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 8 5  

5 . 1 3 . 7 P r o v i n g O p t i m a l i t y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 8 9  

5 . 1 4 C o n c l u s i o n s a n d F u t u r e W o r k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 9 0  

6 M o d e l i n g a n d O p t i m i z i n g t h e I / O P e r f o r m a n c e o f M u l t i p l e D i s k s o n a S C S I B u s 1 9 2  

6 . 1 I n t r o d u c t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 9 2  

6 . 2 R e l a t e d W o r k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 9 5  

6 . 3 W o r k l o a d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 9 6  

6 . 4 H a r d w a r e C o n g u r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 9 7  

6 . 4 . 1 T h e F e n c e P a r a m e t e r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 9 7  

6 . 5 C o m p o n e n t s O f S e r v i c e T i m e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 9 9  

6 . 6 R o u n d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 0  

6 . 7 A n a l y t i c a l M o d e l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 1  

6 . 7 . 1 R e a d d u r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 2  

6 . 7 . 2 S i n g l e d i s k m o d e l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 2  

6 . 7 . 3 P a r a l l e l d i s k m o d e l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 4  

6 . 8 V a l i d a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 5  

6 . 8 . 1 E x p e r i m e n t s t o V a l i d a t e M o d e l s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 6  

6 . 8 . 2 C o n c l u s i o n s F r o m E x p e r i m e n t a l V a l i d a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1 2  

6 . 9 P i p e l i n i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1 2  

6 . 1 0 C o n c l u s i o n s a n d F u t u r e W o r k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1 5  

B i o g r a p h y 2 2 9  

Page 11: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 11/203

L i s t o f T a b l e s    

3 . 1 T h e o v e r h e a d   v  (  k ; D  ) , c o m p u t e d b y e s t i m a t i n g   C  (  k D ; D   )  = k  u s i n g c o m p u t e r s i m u l a t i o n s . . . . . . . . . 6 6  

3 . 2 T h e p e r f o r m a n c e r a t i o   C 

S R M 

= C 

D S M 

f o r m e m o r y s i z e   M  = ( 2  k  + 4 )  D B  +  k D 

, w i t h b l o c k s i z e   B  = 1 0 0 0 .  

( B o t h   M  a n d  B  a r e e x p r e s s e d i n u n i t s o f r e c o r d s . ) T h e o v e r h e a d f a c t o r   v  i n  C 

S R M 

i s b a s e d u p o n  

c o m p u t e r s i m u l a t i o n s o f   C  (  k d ; D   )  = k  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 6  

3 . 3 T h e o v e r h e a d f a c t o r   v  (  k ; D  ) f o r m e m o r y s i z e   M  = ( 2  k  + 4 )  D B  +  k D 

o b t a i n e d f r o m s i m u l a t i o n s . . . 6 7  

3 . 4 T h e p e r f o r m a n c e r a t i o   C 

S R M 

= C 

D S M 

f o r m e m o r y s i z e   M  = ( 2  k  + 4 )  D B  +  k D 

w h e r e   C 

S R M 

i s c o m p u t e d  

u s i n g t h e o v e r h e a d v a l u e   v  (  k ; D  ) o b t a i n e d f r o m s i m u l a t i o n s . . . . . . . . . . . . . . . . . . . . . . . . 6 7  

4 . 1 C o m p a r i n g S R M a n d D S M w h e n i n t e r n a l m e m o r y i s 1 5 M B a n d t h e r e a r e   D  = 6 d i s k s . T h e i n p u t s i z e  

N  i s i n u n i t s o f 1 m i l l i o n i t e m s , e a c h o f s i z e 1 0 4 b y t e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3  

4 . 2 C o m p a r i n g S R M a n d D S M w h e n m e m o r y i s 2 4 M B a n d t h e r e a r e   D  = 6 d i s k s . T h e i n p u t s i z e   N  i s i n  

u n i t s o f 1 m i l l i o n s i t e m s , e a c h o f s i z e 1 0 4 b y t e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4  

6 . 1 D i s k p a r a m e t e r s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 9 8  

6 . 2 T h e a v e r a g e m i n i m u m t i m e t o r e a d o n e s e c t o r o n a W r e n 7 . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 8  

6 . 3 V a l i d a t i n g e q u a t i o n ( 6 . 1 ) ( 1 W r e n , f e n c e 0 ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 8  

6 . 4 V a l i d a t i n g e q u a t i o n ( 6 . 2 ) ( 1 W r e n , f e n c e 2 5 5 ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 8  

6 . 5 V a l i d a t i n g e q u a t i o n ( 6 . 3 ) ( W r e n d i s k s , f e n c e 0 ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 9  

6 . 6 V a l i d a t i n g e q u a t i o n ( 6 . 4 ) ( W r e n d i s k s , f e n c e 2 5 5 ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 9  

6 . 7 T h e B a r r a c u d a d e v i c e p a r a m e t e r s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 9  

6 . 8 V a l i d a t i n g e q u a t i o n ( 6 . 1 ) ( 1 B a r r a c u d a , f e n c e 0 ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 9  

6 . 9 V a l i d a t i n g e q u a t i o n ( 6 . 3 ) ( B a r r a c u d a d i s k s , f e n c e 0 ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1 0  

6 . 1 0 T h e C h e e t a h d e v i c e p a r a m e t e r s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1 0  

6 . 1 1 V a l i d a t i n g e q u a t i o n ( 6 . 1 ) ( 1 C h e e t a h , f e n c e 0 , S p a r c - 2 0 ) . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1 0  

6 . 1 2 V a l i d a t i n g e q u a t i o n ( 6 . 2 ) ( 1 C h e e t a h , f e n c e 2 5 5 , S p a r c - 2 0 ) . . . . . . . . . . . . . . . . . . . . . . . . . 2 1 0  

6 . 1 3 V a l i d a t i n g e q u a t i o n ( 6 . 3 ) ( C h e e t a h d i s k s , f e n c e 0 , S p a r c - 2 0 ) . . . . . . . . . . . . . . . . . . . . . . . . . 2 1 1  

6 . 1 4 V a l i d a t i n g e q u a t i o n ( 6 . 4 ) ( C h e e t a h d i s k s , f e n c e 2 5 5 , S p a r c - 2 0 ) . . . . . . . . . . . . . . . . . . . . . . . 2 1 1  

6 . 1 5 V a l i d a t i n g e q u a t i o n ( 6 . 1 ) ( 1 C h e e t a h , f e n c e 0 , U l t r a ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1 1  

x i 

Page 12: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 12/203

6 . 1 6 V a l i d a t i n g e q u a t i o n ( 6 . 2 ) ( 1 C h e e t a h , f e n c e 2 5 5 , U l t r a ) . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1 1  

6 . 1 7 V a l i d a t i n g e q u a t i o n ( 6 . 3 ) ( C h e e t a h d i s k s , f e n c e 0 , U l t r a ) . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1 2  

6 . 1 8 V a l i d a t i n g e q u a t i o n ( 6 . 4 ) ( C h e e t a h d i s k s , f e n c e 2 5 5 , U l t r a ) . . . . . . . . . . . . . . . . . . . . . . . . . 2 1 2  

6 . 1 9 M B / s f o r n a i v e a n d p i p e l i n e d I / O , f e n c e 0 , W r e n / S u n S p a r c - 2 0 . . . . . . . . . . . . . . . . . . . . . . . 2 1 4  

6 . 2 0 M B / s f o r n a i v e a n d p i p e l i n e d I / O , f e n c e 0 , B a r r a c u d a / D E C A l p h a . . . . . . . . . . . . . . . . . . . . . 2 1 5  

6 . 2 1 M B / s f o r n a i v e a n d p i p e l i n e d I / O , f e n c e 0 , C h e e t a h / S u n U l t r a - 1 . . . . . . . . . . . . . . . . . . . . . . 2 1 5  

x i i 

Page 13: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 13/203

L i s t o f F i g u r e s    

1 . 1 A S i n g l e P l a t t e r o f a M a g n e t i c D i s k D r i v e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2  

3 . 1 T h e P a r a l l e l D i s k M o d e l V S 9 4 ] :   D  ,  B  ,  M  a n d  N  r e s p e c t i v e l y d e n o t e t h e n u m b e r o f i n d e p e n d e n t d i s k  

d r i v e s , t h e s i z e o f e a c h d i s k b l o c k , t h e s i z e o f i n t e r n a l m e m o r y , a n d t h e s i z e o f t h e i n p u t . . . . . . . . 3 3  

3 . 2 ( a ) D e p e n d e n t o c c u p a n c y i n s t a n c e w i t h   N 

= 1 2 ,  C  = 5 ,  D  = 4 . A r r o w s i n d i c a t e t h e c y c l i c a l o r d e r o f  

b l o c k s i n t h e s a m e c h a i n . T h e m a x i m u m o c c u p a n c y i s 4 , a s r e a l i z e d i n t h e s e c o n d b i n . ( b ) C l a s s i c a l  

o c c u p a n c y i n s t a n c e w i t h   N 

= 1 2 ,  D  = 4 . B l o c k s f a l l i n d e p e n d e n t l y o f e a c h o t h e r . T h e m a x i m u m  

o c c u p a n c y i s 5 , a s r e a l i z e d i n t h e s e c o n d b i n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1  

4 . 1 M e r g i n g P h a s e T i m i n g s o f S R M a n d D S M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4  

x i i i  

Page 14: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 14/203

0 00 01 11 10 0 00 0 01 1 11 1 1disk track 

read/write head

read/write arm

magnetic surface of disk 

disk 

F i g u r e 1 . 1  : A S i n g l e P l a t t e r o f a M a g n e t i c D i s k D r i v e .  

C h a p t e r 1      

I n t r o d u c t i o n      

I n t h i s t h e s i s , w e i n v e s t i g a t e a l g o r i t h m i c t e c h n i q u e s t o a l l e v i a t e t h e e e c t o f t h e s o - c a l l e d \ I / O b o t t l e n e c k " . T h r o u g h -  

o u t t h i s t h e s i s , I / O ( t h a t i s , I n p u t / O u t p u t ) r e f e r s t o t r a n s f e r o f d a t a b e t w e e n   i n t e r n a l   ( o r  p r i m a r y   o r  m a i n   ) m e m o r y  

c o n s i s t i n g o f R A M m e m o r y a n d   s e c o n d a r y   ( o r  e x t e r n a l  ) m e m o r y c o n s i s t i n g o f m a g n e t i c d i s k d r i v e s R W 9 4 ] . W e a r e  

p r i m a r i l y c o n c e r n e d a b o u t c o m p u t a t i o n i n v o l v i n g t h e t w o - l e v e l m e m o r y h i e r a r c h y c o n s i s t i n g o f R A M a n d d i s k d r i v e  

m e m o r i e s . A l t h o u g h s e v e r a l c o m p u t i n g s y s t e m s a l s o h a v e a   t e r t i a r y   m e m o r y c o n s i s t i n g o f m a g n e t i c t a p e ( s ) , w e d o  

n o t a d d r e s s i s s u e s r e l e v a n t t o t e r t i a r y m e m o r y a c c e s s e s i n t h i s t h e s i s .  

I n t h i s r s t c h a p t e r , w e g i v e a n o v e r v i e w o f t h e e n t i r e t h e s i s . I n S e c t i o n 1 . 1 , w e d e s c r i b e t h e n a t u r e o f m a g n e t i c  

d i s k d r i v e a c c e s s e s a n d t h e r e a s o n f o r t h e I / O b o t t l e n e c k . I n S e c t i o n 1 . 2 , w e d e s c r i b e e a c h o f t h e r e m a i n i n g c h a p t e r s  

i n t h e t h e s i s a n d s u r v e y s o m e t o p i c s a n d p r e v i o u s w o r k r e l e v a n t t o t h e a p p r o a c h o f e a c h c h a p t e r .  

1 . 1 T h e I / O B o t t l e n e c k      

I n t h e p a s t d e c a d e , t h e r e h a s b e e n a t w o - o r d e r - o f m a g n i t u d e i n c r e a s e i n p r o c e s s o r s p e e d b u t o n l y a t w o - f o l d i m p r o v e -  

m e n t i n d i s k a c c e s s t i m e . ( S e e D a h 9 6 ] f o r d e t a i l s o f d i s k , R A M , p r o c e s s o r s p e e d s a n d o t h e r i n t e r e s t i n g t e c h n o l o g y  

t r e n d s . ) A t y p i c a l d i s k d r i v e i s a f a c t o r o f 1 0  

{ 1 0 

t i m e s s l o w e r G V W 9 6 ] p e r f o r m i n g r a n d o m a c c e s s t h a n i s t h e  

i n t e r n a l m e m o r y o f t h e c o m p u t e r s y s t e m .  

I n g e n e r a l , t h e r e a s o n f o r t h e p o o r d a t a a c c e s s p e r f o r m a n c e o f d i s k d r i v e s i s t h e n e e d t o r e l y o n m e c h a n i c a l ( h e a d  

Page 15: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 15/203

m o v e m e n t ) o p e r a t i o n s t h a t a r e s l o w c o m p a r e d t o t h e s o l i d - s t a t e e l e c t r o n i c s w i t c h i n g b a s e d o p e r a t i o n s i n v o l v e d i n  

i n t e r n a l m e m o r y a c c e s s e s . M a g n e t i c d i s k s c o n s i s t o f o n e o r m o r e r o t a t i n g p l a t t e r s a n d o n e r e a d / w r i t e h e a d p e r p l a t t e r  

s u r f a c e . F i g u r e 1 . 1 s h o w s o n e s u c h p l a t t e r . T h e d a t a a r e s t o r e d i n c o n c e n t r i c c i r c l e s o n t h e p l a t t e r s c a l l e d   t r a c k s   T o 

r e a d o r w r i t e a d a t a i t e m a t a c e r t a i n a d d r e s s o n d i s k , t h e r e a d / w r i t e h e a d m u s t m e c h a n i c a l l y   s e e k   t o t h e c o r r e c t  

t r a c k a n d t h e n w a i t f o r t h e d e s i r e d a d d r e s s t o p a s s b y . T h e r a t e a t w h i c h d a t a p a s s e s u n d e r t h e h e a d d e t e r m i n e s t h e  

d i s k b a n d w i d t h . T h e s e e k t i m e t o m o v e f r o m o n e r a n d o m t r a c k t o a n o t h e r i s o f t e n o n t h e o r d e r o f 5 { 1 0 m i l l i s e c o n d s ,  

a n d t h e a v e r a g e r o t a t i o n a l l a t e n c y , w h i c h i s t h e t i m e f o r h a l f a r e v o l u t i o n , h a s t h e s a m e o r d e r o f m a g n i t u d e . T h e t e r m  

d i s k l a t e n c y r e f e r s t o t h e c o m b i n a t i o n o f s e e k a n d r o t a t i o n a l l a t e n c i e s . I n o r d e r t o a m o r t i z e t h e d e l a y c o r r e s p o n d i n g  

t o t h e d i s k l a t e n c y , i t p a y s t o t r a n s f e r a l a r g e c o l l e c t i o n o f c o n t i g u o u s d a t a i t e m s , s o m e t i m e s c a l l e d a   b l o c k   o r a  p a g e  

T h e b a n d w i d t h p e r f o r m a n c e o f d i s k s i s i m p r o v i n g a t o n l y h a l f t h e r a t e a t w h i c h t h e b a n d w i d t h p e r f o r m a n c e o f  

m a i n m e m o r y i s i m p r o v i n g D a h 9 6 ] ; d i s k l a t e n c y i s i m p r o v i n g a t a n e v e n s m a l l e r r a t e t h a n d i s k b a n d w i d t h D a h 9 6 ]  

a n d p r o c e s s o r p e r f o r m a n c e i s i n c r e a s i n g a t a s l i g h t l y f a s t e r r a t e t h a n i n t e r n a l m e m o r y p e r f o r m a n c e . T h e p e r f o r m a n c e  

d i s c r e p a n c y b e t w e e n d i s k a n d m a i n m e m o r y a c c e s s t i m e s , a l s o k n o w n a s t h e I / O b o t t l e n e c k , w i l l l i k e l y b e w i t h u s  

f o r q u i t e a l o n g t i m e G V W 9 6 ] .  

1 . 2 A p p r o a c h e s t o O v e r c o m e t h e I / O B o t t l e n e c k      

A t a h i g h l e v e l , t h e r e a r e o n l y a f e w f u n d a m e n t a l t e c h n i q u e s G V W 9 6 ] a v a i l a b l e t o a l l e v i a t e t h e e e c t o f t h e I / O  

b o t t l e n e c k :  

1 . u s i n g m u l t i p l e d i s k s i n p a r a l l e l , t h u s i n c r e a s i n g e e c t i v e b a n d w i d t h o f t h e I / O s y s t e m ;  

2 . m o r e e e c t i v e c a c h i n g , a n d , m o r e g e n e r a l l y , r e o r g a n i z i n g d a t a w i t h i n t h e s t o r a g e s y s t e m t o e x p l o i t l o c a l i t y ,  

t h e r e b y r e d u c i n g t h e c o s t o f a c c e s s i n g d a t a ;  

3 . o v e r l a p p i n g I / O w i t h c o m p u t a t i o n ( f o r e x a m p l e , b y p r e f e t c h i n g d a t a b e f o r e i t i s n e e d e d ) i n o r d e r t o r e d u c e t h e  

t i m e t h a t a n a p p l i c a t i o n s p e n d s w a i t i n g f o r d a t a t o b e t r a n s f e r r e d f r o m o r t o a d i s k d r i v e ;  

4 . r e d u c i n g o r r e a r r a n g i n g t h e a c c e s s e s m a d e t o d a t a b y r e d e s i g n i n g t h e a p p l i c a t i o n s t h e m s e l v e s ; a n d  

5 . s c h e d u l i n g a n d / o r c o - o r d i n a t i n g a c c e s s e s t o d i s k d r i v e s t o i n c r e a s e t h e e e c t i v e s p e e d o f d a t a t r a n s f e r t o o r f r o m  

d i s k d r i v e s , b y e x p l o i t i n g c h a r a c t e r i s t i c s a n d f e a t u r e s o f m o d e r n d i s k d r i v e s .  

T h e a l g o r i t h m i c t e c h n i q u e s w e p r o p o s e i n t h i s t h e s i s s p a n a l l t h e a b o v e m e n t i o n e d t e c h n i q u e s . H o w e v e r , i n s t e a d o f  

c l a s s i f y i n g o u r p r o p o s e d t e c h n i q u e s a c c o r d i n g t o t h e a b o v e c a t e g o r i e s , i t i s m o r e f r u i t f u l t o v i e w e a c h o f o u r a l g o r i t h m i c  

t e c h n i q u e s i n t e r m s o f i t s r e l a t i o n s h i p w i t h t h e p r i n c i p a l c o m p o n e n t s o f a c o m p u t i n g s y s t e m . F o r o u r p u r p o s e s , i t i s  

e n o u g h t o v i e w a c o m p u t i n g s y s t e m a s c o m p r i s e d o f a n   o p e r a t i n g s y s t e m   N u t 9 7 ] o r a   d a t a b a s e m a n a g e m e n t s y s t e m  

Page 16: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 16/203

( D B M S )   U W 9 7 ] , a n d o n e o r m o r e   a p p l i c a t i o n p r o g r a m s  , o r j u s t   a p p l i c a t i o n s  . A l t h o u g h t h e r e a r e d i e r e n c e s i n t h e  

d e s i g n o b j e c t i v e s o f d a t a b a s e m a n a g e m e n t s y s t e m s a n d o p e r a t i n g s y s t e m s , t h r o u g h o u t t h e r e s t o f t h i s c h a p t e r , w e  

u s e t h e t e r m \ o p e r a t i n g s y s t e m " t o r e f e r t o d a t a b a s e m a n a g e m e n t s y s t e m s a s w e l l . A n i m p o r t a n t s u b - c o m p o n e n t o f  

t h e o p e r a t i n g s y s t e m i s t h e   I / O s y s t e m  

t h a t i m p l e m e n t s t h e t r a n s f e r o f d a t a b e t w e e n i n t e r n a l a n d e x t e r n a l m e m o r y ,  

c a r r i e s o u t \ l o w l e v e l " f u n c t i o n s w i t h r e s p e c t t o o r g a n i z i n g d a t a o n d i s k s , e t c . T h e o p e r a t i n g s y s t e m , a m o n g s t o t h e r  

t h i n g s , i s g e n e r a l l y i n c h a r g e o f m a n a g i n g r e s o u r c e s t o a p p l i c a t i o n s b a s e d u p o n v a r i o u s c r i t e r i a N u t 9 7 , U W 9 7 ] . F r o m  

t h e p e r s p e c t i v e o f t h i s t h e s i s , o n e k e y r e s o u r c e t h a t g o v e r n s t h e p e r f o r m a n c e o f a n a p p l i c a t i o n , a n d a s a c o n s e q u e n c e ,  

o f t h e e n t i r e c o m p u t i n g s y s t e m , i s t h e a m o u n t o f i n t e r n a l m e m o r y a l l o c a t e d t o t h e a p p l i c a t i o n o v e r i t s r u n t i m e .  

W h e n e v e r a n a p p l i c a t i o n h a s l e s s i n t e r n a l m e m o r y t h a n i t i d e a l l y w o u l d l i k e t o h a v e , I / O o p e r a t i o n s a r e r e q u i r e d  

t o t r a n s f e r d a t a b e t w e e n i n t e r n a l m e m o r y a n d d i s k : T h e d i s k p l a y s t h e r o l e o f a s t o r e t h a t b a c k s u p a p p l i c a t i o n  

d a t a t h a t d o n o t t i n i n t e r n a l m e m o r y . S i n c e I / O o p e r a t i o n s a r e n e c e s s a r y t o m a k e \ p r o g r e s s " i n a n a p p l i c a t i o n ' s  

c o m p u t a t i o n , w e c a n v i e w e v e n I / O o p e r a t i o n s a s a r e s o u r c e t h a t g o v e r n s t h e p e r f o r m a n c e o f a n a p p l i c a t i o n .  

A l g o r i t h m i c t e c h n i q u e s c a n b e a p p l i e d t o o v e r c o m e t h e I / O b o t t l e n e c k o n s e v e r a l d i e r e n t f r o n t s G V W 9 6 ] . E a c h  

c h a p t e r o f t h e t h e s i s p r e s e n t s a n a l g o r i t h m i c t e c h n i q u e b a s e d u p o n a d i s t i n c t a p p r o a c h t o i m p r o v e I / O p e r f o r m a n c e .  

F o r e a c h o f t h e r e m a i n i n g c h a p t e r s o f t h e t h e s i s , w e n o w d e s c r i b e t h e a p p r o a c h c o r r e s p o n d i n g t o t h a t c h a p t e r , b r i e y  

s u r v e y o t h e r t e c h n i q u e s b a s e d u p o n t h a t a p p r o a c h , a n d t h e n d e s c r i b e k e y a s p e c t s o f o u r a l g o r i t h m i c t e c h n i q u e . E a c h  

a p p r o a c h d i e r s f r o m o t h e r a p p r o a c h e s w i t h r e s p e c t t o t h e n a t u r e o f i t s r e l a t i o n s h i p w i t h t h e p r i n c i p a l c o m p o n e n t s  

o f t h e c o m p u t i n g s y s t e m .  

1 . 2 . 1 O p e r a t i n g S y s t e m C a c h i n g a n d P r e f e t c h i n g  

O n e a p p r o a c h t o w a r d s o v e r c o m i n g t h e I / O b o t t l e n e c k i s   c a c h i n g   a n d / o r   p r e f e t c h i n g   i m p l e m e n t e d i n t h e o p e r a t i n g  

s y s t e m . P r o g r a m m e r s w r i t e a p p l i c a t i o n s a s t h o u g h a l l t h e d a t a r e q u i r e d b y t h e a p p l i c a t i o n w i l l b e m e m o r y - r e s i d e n t ;  

i t i s t h e n e n t i r e l y u p t o t h e o p e r a t i n g s y s t e m t o e n s u r e t h a t t h e a p p l i c a t i o n i s p r o c e s s e d c o r r e c t l y e v e n i f a l l o f t h e  

a p p l i c a t i o n ' s d a t a m a y n o t t i n t h e m e m o r y . T h e o p e r a t i n g s y s t e m t r i e s t o m a n a g e m e m o r y s u c h t h a t w h e n e v e r  

p o s s i b l e , t h e d a t a r e q u i r e d b y t h e a p p l i c a t i o n i s c a c h e d i n m e m o r y . I t i s e c i e n t t o m a n a g e m e m o r y a n d e x e c u t e I / O  

o p e r a t i o n s i n u n i t s o f p a g e s N u t 9 7 ] . S i n c e t h e t o t a l a m o u n t o f m e m o r y m a y b e s m a l l e r t h a n t h e t o t a l a m o u n t o f  

d a t a o f a l l t h e a p p l i c a t i o n s e x e c u t i n g c o n c u r r e n t l y o n a m a c h i n e , e c i e n t   p a g e r e p l a c e m e n t   p o l i c i e s a r e r e q u i r e d t o  

e n s u r e t h a t a t a n y t i m e o n l y u s e f u l p a g e s a r e c a c h e d i n m e m o r y w h i l e r e m a i n i n g p a g e s a r e s t o r e d o n d i s k . V e r y o f t e n ,  

o n d e t e c t i n g s p e c i c p a g e a c c e s s p a t t e r n s o f a n a p p l i c a t i o n , o r o n r e c e i v i n g \ h i n t s " r e g a r d i n g f u t u r e p a g e a c c e s s e s ,  

a n o p e r a t i n g s y s t e m m a y a l s o p r e f e t c h p a g e s f r o m d i s k i n t o m e m o r y b e f o r e t h e i r u s e s o t h a t b y t h e t i m e t h e p a g e  

i s a c c e s s e d , i t i s a l r e a d y i n m e m o r y . U n d e r t h i s a p p r o a c h , e a c h a p p l i c a t i o n c a n b e m o d e l e d a s a n a r b i t r a r y x e d  

s e q u e n c e o f p a g e a c c e s s e s a n d h a s n o c o n t r o l o v e r t h e s i z e o r c o n t e n t s o f t h e m e m o r y i t g e t s a l l o c a t e d . T h e o p e r a t i n g  

O u r u s a g e o f t h e t e r m I / O s y s t e m i s g e n e r i c ; w h e r e a p p l i c a b l e , l o w l e v e l c o m p o n e n t s o f a l e s y s t e m  

o r v i r t u a l m e m o r y p a g i n g s y s t e m r e l e v a n t t o a c t u a l d a t a t r a n s f e r a r e a l l c l u b b e d t o g e t h e r u n d e r  

t h e t e r m I / O s y s t e m .  

Page 17: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 17/203

s y s t e m i s s u p p o s e d t o u s e c l e v e r , g e n e r a l - p u r p o s e c a c h i n g , p r e f e t c h i n g a n d m e m o r y m a n a g e m e n t s t r a t e g i e s t h a t w i l l  

p r o v i d e g o o d I / O p e r f o r m a n c e f o r a l a r g e v a r i e t y o f a p p l i c a t i o n s a n d w o r k l o a d s . A n o p e r a t i n g s y s t e m ' s w o r k l o a d  

m a y c o n s i s t o f m u l t i p l e , c o n c u r r e n t l y e x e c u t i n g a p p l i c a t i o n s . T h e o p e r a t i n g s y s t e m i s s o l e l y i n c o n t r o l o f m e m o r y  

a n d I / O o p e r a t i o n s o f t h e a p p l i c a t i o n s u n d e r t h i s a p p r o a c h .  

T h e r e i s a l a r g e l i t e r a t u r e o n o p e r a t i n g s y s t e m c a c h i n g a n d p r e f e t c h i n g t e c h n i q u e s N u t 9 7 ] . W e b r i e y m e n t i o n t h e  

m a n y a v o r s i n w h i c h c a c h i n g a n d p r e f e t c h i n g t e c h n i q u e s a r e a v a i l a b l e , a n d t h e n m e n t i o n s o m e r e l e v a n t t h e o r e t i c a l  

w o r k i n t h e s e s c e n a r i o s . O n e w i d e l y s t u d i e d p r o b l e m i s t h e p r o b l e m o f   d e m a n d p a g i n g  : A s s u m i n g t h a t a b o u n d e d  

n u m b e r o f a p p l i c a t i o n p a g e s c a n b e c a c h e d i n m e m o r y a t a n y t i m e , w h a t p a g e s h o u l d b e e v i c t e d w h e n t h e n e x t  

a c c e s s e d p a g e i s n o t i n m e m o r y , t h a t i s , w h e n a   p a g e f a u l t   o c c u r s ? B e l a d y B e l 6 6 ] p r e s e n t e d a n   o i n e   a l g o r i t h m  

t h a t m i n i m i z e s p a g e f a u l t s a s s u m i n g t h a t t h e e n t i r e s e q u e n c e o f p a g e a c c e s s e s i s k n o w n a p r i o r i . S u b s e q u e n t l y , m a n y  

e m p i r i c a l s t u d i e s s h o w e d t h a t t h e   L e a s t R e c e n t l y U s e d ( L R U )   a l g o r i t h m i s a n e x t r e m e l y e c i e n t   o n l i n e   d e m a n d  

p a g i n g a l g o r i t h m i n g e n e r a l , f o r t h e p r a c t i c a l c a s e i n w h i c h t h e s e q u e n c e o f p a g e a c c e s s e s t o b e s e r v e d i s u n k n o w n .  

I n p i o n e e r i n g w o r k , S l e a t o r a n d T a r j a n S T 8 5 ] , a n d t h e n F i a t e t a l . F K L  

9 1 ] a p p l i e d t h e f r a m e w o r k o f   c o m p e t i t i v e  

a n a l y s i s   t o t h e o r e t i c a l l y e v a l u a t e t h e p e r f o r m a n c e o f o n l i n e d e m a n d p a g i n g a l g o r i t h m s . T h e w o r s t - c a s e n a t u r e o f  

t h e c o m p e t i t i v e a n a l y s i s f r a m e w o r k u s e d i n S T 8 5 , F K L  

9 1 ] h a s o f t e n b e e n c o n s i d e r e d u n r e a l i s t i c b e c a u s e i t d o e s  

n o t a d e q u a t e l y c a p t u r e t h e c h a r a c t e r i s t i c   l o c a l i t y o f r e f e r e n c e   N u t 9 7 ] t h a t m o s t a p p l i c a t i o n s e x h i b i t i n p r a c t i c e .  

S u b s e q u e n t w o r k B I R S 9 1 , K P R 9 2 , I K P 9 2 , F K 9 5 , A l b 9 3 ] t r i e d t o i n c o r p o r a t e v a r i o u s n o t i o n s o f l o c a l i t y o f r e f e r e n c e  

w i t h i n t h e c o m p e t i t i v e a n a l y s i s f r a m e w o r k , t h e r e b y p r o v i n g b o u n d s o n t h e p e r f o r m a n c e o f v a r i o u s o n l i n e d e m a n d  

p a g i n g a l g o r i t h m s u n d e r v a r i o u s a s s u m p t i o n s . R e c e n t l y , a n i n t e r e s t i n g v e r s i o n o f t h e d e m a n d p a g i n g p r o b l e m i n v o l v i n g  

m u l t i p l e a p p l i c a t i o n s s h a r i n g a x e d s i z e c a c h e , w i t h e a c h a p p l i c a t i o n c a p a b l e o f f u r n i s h i n g u s e f u l \ h i n t s " t o t h e  

p a g i n g a l g o r i t h m w a s p r o p o s e d i n C F L 9 4 a ] , w i t h a n a c c o m p a n y i n g p a g i n g a l g o r i t h m . G e n e r a l i z a t i o n s o f t h e d e m a n d  

p a g i n g p r o b l e m i n w h i c h p a g e s i z e s m a y d i e r Y o u 9 8 ] , o r t h e a c c e s s t i m e s o f p a g e s m a y b e n o n - u n i f o r m Y o u 9 1 ] ,  

a n d g e n e r a l i z e d v a r i a n t s A A K 9 9 ] , g e a r e d t o w a r d s s c e n a r i o s i n v o l v i n g w i d e a r e a n e t w o r k s a n d t h e w o r l d - w i d e w e b ,  

h a v e a l s o b e e n s t u d i e d . A n o t h e r g e n e r a l i z a t i o n o f t h e d e m a n d p a g i n g p r o b l e m a d d r e s s e s t h e i s s u e o f d i s t r i b u t i n g  

a s e t o f p a g e s a c r o s s a n e t w o r k o f m a c h i n e s e a c h w i t h l o c a l m e m o r y ; o n l i n e a l g o r i t h m s h a v e b e e n p r o p o s e d a n d  

a n a l y z e d A B F 9 6 , A B F 9 3 ] t o d e c i d e h o w t o k e e p d y n a m i c a l l y c h a n g i n g t h e c o n t e n t s o f t h e l o c a l m e m o r i e s u n d e r  

v a r i o u s c o n s t r a i n t s s o a s t o m i n i m i z e p a g e f a u l t s a t a n y m a c h i n e .  

A n o v e l a d a p t a t i o n o f t h e c o m p e t i t i v e a n a l y s i s f r a m e w o r k a n d a   s t a l l t i m e m o d e l   t o s t u d y t h e p e r f o r m a n c e o f  

p r e f e t c h i n g a l g o r i t h m s w h i l e s e r v i n g a n a p p l i c a t i o n m o d e l e d a s a s e q u e n c e o f p a g e a c c e s s e s w a s p r o p o s e d i n C F K L 9 5 ] .  

I n p r e f e t c h i n g a l g o r i t h m s , ( s o m e a m o u n t o f ) i n f o r m a t i o n r e g a r d i n g f u t u r e p a g e a c c e s s e s i s n e c e s s a r y . B e s i d e s m a k i n g  

p a g e r e p l a c e m e n t d e c i s i o n , a p r e f e t c h i n g a l g o r i t h m a l s o h a s t o d e c i d e w h e n t o i n i t i a t e a n I / O o p e r a t i o n ; s o t e c h n i q u e s  

u s e d t o p r e f e t c h a n d t h e i r t h e o r e t i c a l a n a l y s e s C F K L 9 5 , K k 9 6 , A G L 9 8 ] a p p e a r t o b e r e l a t i v e l y m o r e c o m p l e x t h a n  

t h o s e f o r d e m a n d p a g i n g .  

I n C h a p t e r 2 , w e p r e s e n t a n   a p p l i c a t i o n - c o n t r o l l e d p a g i n g a l g o r i t h m   t o m a n a g e a c a c h e s h a r e d b y   P  c o m p e t i n g ,  

Page 18: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 18/203

c o n c u r r e n t l y e x e c u t i n g a p p l i c a t i o n s . T h e a p p l i c a t i o n - c o n t r o l l e d a p p r o a c h o f u s i n g \ h i n t s " ( r e g a r d i n g f u t u r e p a g e  

a c c e s s e s ) p r o v i d e d b y a p p l i c a t i o n s t o a i d r e p l a c e m e n t d e c i s i o n s r e p r e s e n t s a m a r k e d l y d i e r e n t , a n d i n m a n y c a s e s  

i m p r o v e d , a p p r o a c h t o i n c o r p o r a t e e a c h a p p l i c a t i o n ' s l o c a l i t y o f r e f e r e n c e c o m p a r e d t o p r e v i o u s a p p r o a c h e s m e n t i o n e d  

a b o v e . I f   k  i s u s e d t o d e n o t e t h e n u m b e r o f p a g e s t h a t c a n b e s t o r e d i n t h e c a c h e s h a r e d b y t h e   P  a p p l i c a t i o n s , f o r o u r  

s c e n a r i o , w e s h o w h o w \ h i n t s " p r o v i d e d b y t h e a p p l i c a t i o n s c a n b e u s e d t o c i r c u m v e n t a l o w e r b o u n d o f     l n  k  p r o v e d  

f o r t h e   c o m p e t i t i v e r a t i o   F K L  

9 1 ] o f a n y o n l i n e a l g o r i t h m f o r t h e \ c l a s s i c a l " p a g i n g m o d e l F K L  

9 1 ] : O u r a l g o r i t h m  

h a s a c o m p e t i t i v e r a t i o o f     2 l n  P  , w h i c h c a n b e m u c h s m a l l e r t h a n l n   k  s i n c e   k    P  t y p i c a l l y . O u r a l g o r i t h m c a n  

a l s o b e m o d i e d t o i n c o r p o r a t e s o m e n o t i o n s o f f a i r n e s s i n s i t u a t i o n s w h e n a p p l i c a t i o n s p r o v i d e i n c o r r e c t i n f o r m a t i o n  

i n t h e i r \ h i n t s " . T h e t h e o r e t i c a l a p p l i c a t i o n - c o n t r o l l e d p a g i n g m o d e l w e u s e i s i n s p i r e d b y r e c e n t w o r k o n a p p l i c a t i o n -  

c o n t r o l l e d l e c a c h i n g b y C a o e t a l . C F L 9 4 a ] .  

1 . 2 . 2 E x t e r n a l M e m o r y A l g o r i t h m s ( w i t h s t a t i c a l l y a l l o -  

c a t e d m e m o r y )  

I n c o n t r a s t t o t h e p r e v i o u s a p p r o a c h i n w h i c h t h e o p e r a t i n g s y s t e m s o l e l y c o n t r o l s m e m o r y c o n t e n t s a n d I / O o p -  

e r a t i o n s , t h e a p p r o a c h o f   e x t e r n a l m e m o r y ( E M )   ( o r  I / O  o r  o u t - o f - c o r e   ) a l g o r i t h m s r e q u i r e s t h e a p p l i c a t i o n t o  

c o m p l e t e l y m a n a g e i t s o w n i n t e r n a l m e m o r y . E a c h E M a l g o r i t h m i s c u s t o m - m a d e f o r t h e p r o b l e m b e i n g s o l v e d .  

I n t h i s a p p r o a c h , t h e o p e r a t i n g s y s t e m s t a t i c a l l y a l l o c a t e s a x e d i n v a r i a n t a m o u n t o f m e m o r y t o t h e a p p l i c a t i o n ,  

a f t e r w h i c h t h e a p p l i c a t i o n s o l e l y d e t e r m i n e s t h e s e q u e n c e o f I / O o p e r a t i o n s i t c a r r i e s o u t i n c o n j u n c t i o n w i t h i t s  

c o m p u t a t i o n . E a c h I / O o p e r a t i o n t r a n s f e r s o n e b l o c k o f   B  c o n t i g u o u s i t e m s o r r e c o r d s t o o r f r o m d i s k i n t o m e m o r y .  

I f t h e r e a r e   D >  1 d i s k s , e a c h ( p a r a l l e l ) I / O o p e r a t i o n m a y t r a n s f e r a t m o s t o n e b l o c k t o o r f r o m e a c h d i s k d r i v e ;  

s o a t m o s t   D  b l o c k s c a n b e t r a n s f e r r e d w h e n t h e r e a r e   D  d i s k s , o n e t o o r f r o m e a c h d i s k . T h e g o a l i s t o d e s i g n t h e  

E M a l g o r i t h m s o t h a t t h e n u m b e r o f I / O o p e r a t i o n s i n c u r r e d i s t h e s m a l l e s t p o s s i b l e f o r t h a t a p p l i c a t i o n . O n c e i t i s  

a l l o c a t e d m e m o r y b y t h e o p e r a t i n g s y s t e m , t h e E M a p p l i c a t i o n e x e r c i s e s c o m p l e t e c o n t r o l o v e r i t s m e m o r y a n d I / O  

o p e r a t i o n s .  

T h e f a c t t h a t a l g o r i t h m s t h a t w o r k w e l l i n i n t e r n a l m e m o r y v e r y o f t e n r e s u l t i n a n o n - o p t i m a l n u m b e r o f I / O  

o p e r a t i o n s w h e n i n t e r m e d i a t e d a t a n e e d s t o b e s t o r e d o n d i s k h a s b e e n w e l l k n o w n f o r l o n g , a n d s o E M a l g o r i t h m s f o r  

f u n d a m e n t a l a n d f r e q u e n t l y o c c u r r i n g p r o b l e m s s u c h a s s o r t i n g K n u 9 8 ] f o r t h e s p e c i a l c a s e   D  = 1 h a v e b e e n i n u s e  

f o r m a n y y e a r s . D a t a b a s e r e s e a r c h e r s h a v e a l s o d e v e l o p e d I / O e c i e n t a l g o r i t h m s ( o f t e n a n a l y z e d e x p e r i m e n t a l l y )  

f o r v a r i o u s o t h e r E M q u e r y p r o c e s s i n g a p p l i c a t i o n s s u c h a s s o r t - j o i n a n d h a s h - j o i n U W 9 7 ] f o r t h e c a s e w h e n   D  = 1

H o w e v e r , r e c e n t r e s e a r c h h a s l e d t o t h e d e v e l o p m e n t o f p r o v a b l y e c i e n t p a r a l l e l d i s k (  D >  1 ) a l g o r i t h m s f o r s e v e r a l  

b a s i c p r o b l e m s , o p t i m a l E M a l g o r i t h m s f o r s e v e r a l g r a p h t h e o r e t i c a n d c o m p u t a t i o n a l g e o m e t r y p r o b l e m s , a n d n e w  

e x t e r n a l m e m o r y d a t a s t r u c t u r e s .  

I t i s c o n v e n i e n t t o u s e   N  t o d e n o t e t h e n u m b e r o f i t e m s i n p u t t o a n E M a l g o r i t h m a n d   M  t o d e n o t e t h e n u m b e r  

Page 19: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 19/203

o f i t e m s t h a t c a n b e s t o r e d i n t h e m e m o r y s t a t i c a l l y a l l o c a t e d t o a n E M a l g o r i t h m . A p i o n e e r i n g s t e p t o w a r d s t h e  

n o t i o n o f   I / O c o m p l e x i t y   o f a p r o b l e m , t h a t i s , t h e s m a l l e s t n u m b e r o f I / O o p e r a t i o n s r e q u i r e d t o s o l v e t h e p r o b l e m ,  

w a s m a d e b y F l o y d F l o 7 2 ] w h e n h e w a s a b l e t o p r o v e a l o w e r b o u n d o n t h e n u m b e r o f I / O o p e r a t i o n s r e q u i r e d t o  

t r a n s p o s e   a d i s k - r e s i d e n t m a t r i x f o r t h e s p e c i c c a s e   D  = 1 a n d   B  = (  M  ) = (  N 

) , w h e r e 0   < c <  1 i s a c o n s t a n t .  

T h e l o w e r b o u n d s a p p l y t o e x t e r n a l s o r t i n g a n d p e r m u t i n g a s w e l l . H o w e v e r , t h e l o w e r b o u n d s a r e n o t t i g h t i n g e n e r a l  

f o r o t h e r v a l u e s o f   B  ,  N  ,  M  , a n d   D  . H o n g a n d K u n g H K 8 1 a ] t h e n p r e s e n t e d \ p e b b l i n g " - b a s e d l o w e r b o u n d s o n t h e  

n u m b e r o f I / O o p e r a t i o n s r e q u i r e d i n e x t e r n a l F F T c o m p u t a t i o n a n d e x t e r n a l m a t r i x m u l t i p l i c a t i o n w h e n   B  =  O  ( 1 ) 

a n d  D  = 1 . I n p i o n e e r i n g w o r k , A g g a r w a l a n d V i t t e r A V 8 8 ] t h e n p r o v e d g e n e r a l I / O c o m p l e x i t y l o w e r b o u n d s f o r  

s o r t i n g , p e r m u t i n g , F F T , p e r m u t a t i o n n e t w o r k s , a n d m a t r i x t r a n s p o s i t i o n v a l i d f o r a l l v a l u e s o f   B  ,  D  ,  M  , a n d   N  ; 

p a v i n g t h e w a y f o r i n c r e a s e d r e s e a r c h a c t i v i t y i n I / O a l g o r i t h m s . V i t t e r a n d S h r i v e r V S 9 4 ] t h e n p r o p o s e d t h e s o -  

c a l l e d   p a r a l l e l d i s k m o d e l ( P D M )   m e a n t t o f a c i l i t a t e t h e d e s i g n a n d a n a l y s i s o f p a r a l l e l d i s k a l g o r i t h m s ; a n d p r o p o s e d  

o p t i m a l p a r a l l e l d i s k a l g o r i t h m s f o r s o r t i n g a n d r e l a t e d p r o b l e m s A V 8 8 ] , a n d m a t r i x m u l t i p l i c a t i o n . T h e r e h a s s i n c e  

b e e n a l a r g e a m o u n t o f w o r k o n e x t e r n a l m e m o r y a l g o r i t h m s . S e v e r a l o p t i m a l p a r a l l e l d i s k s o r t i n g a l g o r i t h m s h a v e  

b e e n p r o p o s e d i n N V 9 0 , N V 9 5 , A P 9 4 , N V 9 3 ] . E c i e n t a l g o r i t h m s f o r v a r i o u s E M g r a p h p r o b l e m s w e r e p r o p o s e d  

i n C G G  

9 5 , K S 9 6 , A B W 9 8 ] a n d o p t i m a l a l g o r i t h m s f o r v a r i o u s E M c o m p u t a t i o n a l g e o m e t r y p r o b l e m s w e r e p r o p o s e d  

i n G T V V 9 3 , C F M  

9 8 ] . A f t e r t h e B - t r e e i n d e x i n g d a t a s t r u c t u r e s U W 9 7 ] p r o p o s e d i n t h e s e v e n t i e s , r e c e n t l y , m a n y  

n e w e x t e r n a l m e m o r y d a t a s t r u c t u r e s h a v e b e e n p r o p o s e d . A n o t a b l e d a t a s t r u c t u r e i s t h e v e r s a t i l e b u e r t r e e  

d e v e l o p e d b y A r g e A r g 9 6 ] , w i t h m a n y a p p l i c a t i o n s . O t h e r e x t e r n a l m e m o r y d a t a s t r u c t u r e s r e l e v a n t t o e c i e n t  

g e o m e t r i c p r o c e s s i n g h a v e b e e n p r o p o s e d i n R S 9 4 , V V 9 6 a , A V 9 6 ] . E c i e n t E M a l g o r i t h m s h a v e a l s o b e e n p r o p o s e d  

f o r v a r i o u s l a r g e - s c a l e p r o b l e m s o c c u r r i n g i n g e o g r a p h i c a l i n f o r m a t i o n s y s t e m s A V V a r , A r g 9 7 , A A M  

9 8 , A P R  

9 8 ] 

a n d s t r i n g p r o c e s s i n g a p p l i c a t i o n s F G 9 5 , A F G V 9 8 ] . A c o m p r e h e n s i v e s u r v e y o f t h e s t a t e - o f - t h e - a r t i n t h e e l d o f  

I / O a l g o r i t h m s c a n b e f o u n d i n V i t 9 8 ] .  

I n C h a p t e r 3 , w e p r e s e n t a   s i m p l e r a n d o m i z e d m e r g e s o r t ( S R M )   f o r p a r a l l e l d i s k s o r t i n g o n t h e P D M V S 9 4 ] .  

P r e v i o u s l y p r o p o s e d t h e o r e t i c a l l y e c i e n t p a r a l l e l d i s k s o r t i n g a l g o r i t h m s h a v e t h e d r a w b a c k t h a t t h e y a r e s o m e w h a t  

c o m p l i c a t e d a n d h a v e l a r g e r t h a n d e s i r e d c o n s t a n t f a c t o r s , a n d s o a r e n o t s u i t a b l e f o r i m p l e m e n t a t i o n . I n c o n t r a s t ,  

S R M i s s i m p l e , c o n s i s t s o f a s i m p l e p r e f e t c h i n g a n d b u e r - m a n a g e m e n t s c h e m e t h a t e c i e n t l y u t i l i z e s a v a i l a b l e  

m e m o r y a n d   D  - d i s k p a r a l l e l i s m , a n d i s e a s i l y i m p l e m e n t a b l e . W i t h r e s p e c t t o t h e e n t i r e r a n g e o f v a l u e s o f   M  , 

D  a n d  B  , S R M i s e i t h e r p r o v a b l y o p t i m a l o r p r o v a b l y e c i e n t . E x p e r i m e n t a l e v i d e n c e s u g g e s t s t h a t o u r a n a l y s i s  

i s s o m e w h a t c o n s e r v a t i v e w i t h r e s p e c t t o p r a c t i c a l s i t u a t i o n s . F o r a l l p r a c t i c a l p u r p o s e s , S R M m a y b e c o n s i d e r e d  

b e t t e r t h a n m o s t o t h e r a l g o r i t h m s , e v e n f o r r a n g e s o f   M  ,  D  a n d  B  v a l u e s o v e r w h i c h S R M i s , s t r i c t l y s p e a k i n g , n o t  

t h e o r e t i c a l l y o p t i m a l . R e c e n t l y , K n u t h K n u 9 8 , S e c t i o n 5 . 4 . 9 ] i d e n t i e d S R M ( w h i c h h e c a l l s \ r a n d o m i z e d s t r i p i n g " )  

a s t h e m e t h o d o f c h o i c e f o r s o r t i n g o n p a r a l l e l d i s k s . T h e p r o b a b i l i s t i c a n a l y s i s i n v o l v e d i n p r o v i n g b o u n d s o n S R M ' s  

p e r f o r m a n c e i n c l u d e s r e d u c t i o n s t o c e r t a i n m a x i m u m o c c u p a n c y p r o b l e m s , w h i c h m a y b e o f i n d e p e n d e n t i n t e r e s t .  

T h e p r e f e t c h i n g a n d b u e r m a n a g e m e n t u s e d i n S R M a l s o h a s a p p l i c a t i o n s i n p a r a l l e l p r e f e t c h i n g i n c e r t a i n s i t u a t i o n s ,  

Page 20: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 20/203

a s o b s e r v e d i n B K V V 9 7 ] .  

I n C h a p t e r 4 , w e p r e s e n t t e c h n i q u e s a n d i s s u e s r e l e v a n t t o t h e i m p l e m e n t a t i o n o f I / O a l g o r i t h m s u s i n g  

T P I E V e n 9 5 ] : T P I E ( T r a n s p a r e n t P a r a l l e l I / O E n v i r o n m e n t ) i s a p r o g r a m m i n g e n v i r o n m e n t , o r i g i n a l l y d e v e l o p e d  

b y D a r r e n V e n g r o V e n 9 6 ] f o r h i s P h D t h e s i s t o f a c i l i t a t e t h e i m p l e m e n t a t i o n o f e c i e n t I / O a l g o r i t h m s . C h a p t e r 4  

d e s c r i b e s t h e i m p l e m e n t a t i o n o f t h e S R M a l g o r i t h m i n T P I E . W e u s e e l e g a n t d a t a s t r u c t u r e s a n d t e c h n i q u e s t o i m p l e -  

m e n t t h e   f o r e c a s t i n g   K n u 9 8 ] a n d p r e f e t c h i n g a p p r o a c h o f S R M . W e d e m o n s t r a t e t h a t S R M i s s i g n i c a n t l y f a s t e r t h a n  

d i s k - s t r i p e d m e r g e s o r t ( D S M ) , a p o p u l a r l y u s e d p a r a l l e l d i s k s o r t i n g a l g o r i t h m . G e n e r a l i z a t i o n s o f o u r f o r e c a s t i n g  

d a t a s t r u c t u r e s a n d t e c h n i q u e s a l s o h a v e a p p l i c a t i o n s i n m u l t i - w a y e x t e r n a l d i s t r i b u t i o n a n d i n o t h e r s i t u a t i o n s s u c h  

a s i n v i d e o s e r v e r s e t c .  

1 . 2 . 3 E M A l g o r i t h m s w i t h D y n a m i c M e m o r y A l l o c a t i o n s  

T h e a p p r o a c h i n S e c t i o n 1 . 2 . 1 h a s t h e o p e r a t i n g s y s t e m i n c o m p l e t e c o n t r o l o v e r t h e m e m o r y a l l o c a t i o n a n d t h e m e m -  

o r y c o n t e n t s o f t h e a p p l i c a t i o n s , a n d t h e o p e r a t i n g s y s t e m e x e c u t e s I / O o p e r a t i o n s o n b e h a l f o f t h e a p p l i c a t i o n s . T h e  

a p p r o a c h i n S e c t i o n 1 . 2 . 2 h a s t h e o p e r a t i n g s y s t e m o n l y a l l o c a t i n g a x e d a m o u n t o f m e m o r y t o t h e E M a p p l i c a t i o n ,  

a f t e r w h i c h t h e E M a p p l i c a t i o n i s s o l e l y r e s p o n s i b l e f o r m a n a g i n g i t s m e m o r y a n d I / O o p e r a t i o n s a p p r o p r i a t e l y . W e  

n o w c o n s i d e r a   d y n a m i c   a p p r o a c h a p p l i c a b l e f r e q u e n t l y i n s p e c i c s i t u a t i o n s n o w a d a y s , i n w h i c h t h e o p e r a t i n g s y s t e m  

c h a n g e s t h e m e m o r y a l l o c a t i o n o f a n E M a p p l i c a t i o n f r o m t i m e t o t i m e , b u t t h e E M a p p l i c a t i o n i s i n c o m p l e t e c h a r g e  

o f t h e m e m o r y a l l o c a t e d t o i t a t a n y t i m e . C o m p a r e d t o t h e a p p r o a c h i n S e c t i o n 1 . 2 . 1 , t h e a p p l i c a t i o n h a s g r e a t e r  

c o n t r o l o v e r i t s r e s o u r c e s , a n d i n c o n t r a s t t o t h e a p p r o a c h o f S e c t i o n 1 . 2 . 2 , t h e o p e r a t i n g s y s t e m c a n p o t e n t i a l l y  

i n u e n c e t h e a p p l i c a t i o n ' s m e m o r y a l l o c a t i o n ( a n d h e n c e i t s p e r f o r m a n c e ) t h r o u g h o u t i t s e x e c u t i o n .  

R e c e n t d e v e l o p m e n t s r e l a t e d t o r e a l - t i m e d a t a b a s e s y s t e m s S y s 9 2 , R e c 8 8 ] a n d d a t a b a s e s y s t e m s b a s e d u p o n  

a d m i n i s t r a t i v e l y d e n e d g o a l s F N G 8 9 , B C L 9 3 ] h a v e m o t i v a t e d t h e s t u d y o f E M a p p l i c a t i o n s t h a t c a n a d a p t t o  

m e m o r y u c t u a t i o n s , b u t s u c h a s t u d y c a n a l s o b e v i e w e d a s a n a t u r a l e x t e n s i o n t o t h e s t a t i c a l l y a l l o c a t e d , x e d  

m e m o r y a p p r o a c h ( S e c t i o n 1 . 2 . 2 ) t o d e v e l o p E M a l g o r i t h m s . D r a s t i c p e r f o r m a n c e d e g r a d a t i o n c a n o c c u r w h e n  

t h e i n t e r n a l m e m o r y a l l o c a t i o n o f a n E M a p p l i c a t i o n t h a t a s s u m e s a s t a t i c m e m o r y a l l o c a t i o n , i s u n p r e d i c t a b l y  

r e d u c e d . E M t e c h n i q u e s t h a t i n c o r p o r a t e n o t i o n s o f o n l i n e a l g o r i t h m s a r e n e e d e d i n o r d e r t o d e s i g n   m e m o r y - a d a p t i v e  

a l g o r i t h m s t h a t c a n c o p e w i t h m e m o r y u c t u a t i o n s . W o r k o n m e m o r y - a d a p t i v e h a s h - j o i n a l g o r i t h m s i s r e p o r t e d  

i n Z G 9 0 , P C L 9 3 b ] ; a m e m o r y - a d a p t i v e m e r g e s o r t i s p r o p o s e d i n P C L 9 3 a , Z L 9 7 ] . P r i o r w o r k o n m e m o r y - a d a p t i v e  

E M a l g o r i t h m s h a s b e e n i n c o m p l e t e a n d e x c l u s i v e l y e m p i r i c a l i n n a t u r e .  

I n C h a p t e r 5 , w e p r e s e n t a t h e o r e t i c a l f r a m e w o r k f o r m e m o r y - a d a p t i v e a l g o r i t h m s . W e p r e s e n t a t h e o r e t i c a l  

m o d e l f o r d y n a m i c m e m o r y a l l o c a t i o n a n d p r e s e n t a n o t i o n o f o p t i m a l i t y f o r m e m o r y - a d a p t i v e a l g o r i t h m s . S i n c e  

t h e p e r f o r m a n c e o f a m e m o r y - a d a p t i v e a l g o r i t h m c a n n o t b e c a p t u r e d b y c o n s i d e r i n g i n i s o l a t i o n e i t h e r o n l y i t s  

m e m o r y u s a g e o r o n l y i t s n u m b e r o f I / O o p e r a t i o n s , w e i n t r o d u c e t h e p r o b l e m - s p e c i c n o t i o n o f   r e s o u r c e c o n s u m p t i o n  

o f a m e m o r y - a d a p t i v e a l g o r i t h m . W e p r o v e r e s o u r c e c o n s u m p t i o n b o u n d s a n d p r e s e n t o p t i m a l m e m o r y - a d a p t i v e  

Page 21: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 21/203

a l g o r i t h m s f o r s o r t i n g ( a n d r e l a t e d p r o b l e m s ) a n d m a t r i x m u l t i p l i c a t i o n ( a n d r e l a t e d p r o b l e m s . ) O u r u p p e r b o u n d  

a n a l y s i s i n c l u d e s a n o v e l p o t e n t i a l f u n c t i o n a p p r o a c h t h a t p r o v i d e s i n s i g h t s o n t h e n o t i o n o f o p t i m a l m e m o r y u t i l i z a t i o n  

d u r i n g E M c o m p u t a t i o n . W e p r o v e t h a t a m e m o r y - a d a p t i v e s o r t i n g a l g o r i t h m b a s e d u p o n a p r e v i o u s l y p r o p o s e d  

a p p r o a c h i s n o n - o p t i m a l . O u r l o w e r b o u n d t e c h n i q u e s a r e r e l a t e d t o t e c h n i q u e s i n A V 8 8 ] a n d H K 8 1 a ] .  

1 . 2 . 4 T e c h n i q u e s t o I m p r o v e D a t a T r a n s f e r S p e e d  

I n t h e a b o v e t h r e e a p p r o a c h e s , t h e e m p h a s i s i s o n d e v e l o p i n g a l g o r i t h m i c t e c h n i q u e s ( f o r t h e o p e r a t i n g s y s t e m o r  

a p p l i c a t i o n ) t h a t a t t a i n e c i e n t I / O p e r f o r m a n c e b y a p p r o p r i a t e l y d e t e r m i n i n g   w h a t   b l o c k s o r p a g e s a r e t o b e  

t r a n s f e r r e d i n e a c h I / O o p e r a t i o n . A c o m p l e t e l y c o m p l e m e n t a r y a p p r o a c h i s t o d e v e l o p t e c h n i q u e s t h a t w i l l r e s u l t i n  

e c i e n t d a t a t r a n s f e r b e t w e e n m e m o r y a n d d i s k , a s s u m i n g s o m e o t h e r c o m p o n e n t o f t h e c o m p u t i n g s y s t e m s p e c i e s  

t h e b l o c k s t h a t n e e d t o b e t r a n s f e r r e d i n I / O o p e r a t i o n s . A n i n s t a n c e o f t h i s a p p r o a c h i s M K 9 1 ] a n d r e l a t e d w o r k ,  

w h i c h p r o p o s e d d i s k b l o c k a l l o c a t i o n a l g o r i t h m s a i m e d t o o p t i m i z e t h e p e r f o r m a n c e o f l e a c c e s s e s . R e s e a r c h e r s  

h a v e a l s o p r o p o s e d a n d e x p e r i m e n t a l l y a n a l y z e d t e c h n i q u e s t o d y n a m i c a l l y r e o r g a n i z e d a t a o n d i s k s b a s e d u p o n  

a c c e s s s t a t i s t i c s , t h e g o a l b e i n g t o a c c e l e r a t e d a t a t r a n s f e r r a t e s d J K H 9 3 , E S 9 2 , R W 9 1 , V C 9 0 ] : T h e g e n e r a l i d e a  

i s t o u s e a c c e s s s t a t i s t i c s a n d f e a t u r e s o f m o d e r n d i s k d r i v e s R W 9 4 ] t o e n s u r e t h a t f r e q u e n t l y u s e d ( \ h o t " ) d a t a  

r e s i d e s i n t h e m i d d l e o f t h e d i s k s u r f a c e , t o e n s u r e t h a t d a t a b l o c k s a c c e s s e d t o g e t h e r a r e a l s o s t o r e d t o g e t h e r o n  

d i s k , a n d s o o n , t h e r e b y i n c r e a s i n g l o c a l i t y o f d i s k a c c e s s e s . A t e c h n i q u e u s e d a t \ r u n - t i m e " t o a c c e l e r a t e d a t a  

t r a n s f e r r a t e s v i a o p t i m i z e d r e q u e s t s e q u e n c i n g i s f o r d i s k d r i v e s c h e d u l i n g a l g o r i t h m s t o p e r f o r m d y n a m i c r e q u e s t  

r e o r d e r i n g J W 9 1 , S C O 9 0 , W G P 9 4 ] o f t e n t a k i n g a d v a n t a g e o f l o w - l e v e l i n f o r m a t i o n a v a i l a b l e o n l y t o t h e d i s k d r i v e  

c o n t r o l l e r . A t h e o r e t i c a l r e s u l t p e r t a i n i n g t o a n e c i e n t d i s k d r i v e s c h e d u l i n g a l g o r i t h m i n c o r p o r a t i n g s o m e r e c e n t  

d e v e l o p m e n t s i n d i s k d r i v e t e c h n o l o g y a p p e a r s i n A B Z 9 6 ] . S c h e d u l i n g t e c h n i q u e s c a n i m p r o v e d e v i c e t h r o u g h p u t b y  

r e o r d e r i n g a c c e s s e s f o r l o w e r e d p o s i t i o n i n g t i m e s , b a l a n c e t h e u s e o f r e s o u r c e s o v e r m u l t i p l e r e q u e s t i n g a p p l i c a t i o n s ,  

a n d r e d u c e p r o c e s s i n g o v e r h e a d s b y c o a l e s c i n g d i s t i n c t a c c e s s e s i n t o a s i n g l e l a r g e r a c c e s s K o t 9 4 , P E K 9 6 ] . I n D B M S ,  

w h i c h o f t e n t e n d t o a v o i d t h e l e s y s t e m i n t e r f a c e S t o 8 1 ] , r e s e a r c h e r s h a v e p r o p o s e d a p p l i c a t i o n s p e c i c d i s k d r i v e  

s c h e d u l i n g a n d d i s k b l o c k l a y o u t t e c h n i q u e s Z L 9 6 , Z L 9 8 ] d e s i g n e d t o t a k e a d v a n t a g e o f d i s k c o n t r o l l e r f e a t u r e s s u c h  

a s s e q u e n t i a l r e a d a h e a d t o o p t i m i z e d a t a t r a n s f e r d u r i n g I / O . T h e t e c h n i q u e i n C T 9 6 ] p r o p o s e s a s p e c i a l i z e d d i s k  

s c h e d u l i n g a l g o r i t h m t o b e u s e d i n c o n j u n c t i o n w i t h s o m e a d v a n c e d f e a t u r e s o f d i s k d r i v e c o n t r o l l e r s t o i m p r o v e I / O  

p e r f o r m a n c e o f c e r t a i n m u l t i m e d i a a p p l i c a t i o n s . S e v e r a l r e s e a r c h e r s h a v e a l s o c a r r i e d o u t d e t a i l e d m o d e l i n g R W 9 4 ,  

W G P W 9 5 , C h e 8 9 , S h r 9 7 ] o f s t o r a g e d e v i c e s , w h i c h a r e g e t t i n g m o r e a n d m o r e c o m p l i c a t e d G V W 9 6 ] : D e t a i l e d m o d e l s  

o f u n d e r l y i n g I / O d e v i c e s a r e n e c e s s a r y t o d e v e l o p a n d i m p l e m e n t a l g o r i t h m s t o a c c e l e r a t e d a t a t r a n s f e r t o o r f r o m  

d e v i c e s .  

I n C h a p t e r 6 , w e m o d e l t h e p e r f o r m a n c e o f a p a r a l l e l I / O s y s t e m c o n s i s t i n g o f m u l t i p l e d i s k d r i v e s s h a r i n g a  

S C S I b u s a n d p r e s e n t a t e c h n i q u e t o i m p r o v e t h e I / O p e r f o r m a n c e o f t h e s y s t e m . O u r w o r k l o a d c o n s i s t s o f a n  

a p p r o x i m a t i o n o f t h e I / O w o r k l o a d g e n e r a t e d b y a P D M a l g o r i t h m . O u r a n a l y t i c a l m o d e l f o r t h e I / O p e r f o r m a n c e o f  

Page 22: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 22/203

a s y s t e m c o m p r i s i n g o f m u l t i p l e d i s k s s h a r i n g a b u s i s d i e r e n t f r o m p r e v i o u s a p p r o a c h e s t o m o d e l i n g m u l t i p l e d i s k s o n  

a b u s . W e t a k e i n t o a c c o u n t s o m e i n t e r e s t i n g p h e n o m e n a ( n o t r e p o r t e d i n p r e v i o u s l i t e r a t u r e o n t h i s s u b j e c t ) t h a t w e  

d i s c o v e r e d w h i l e m o n i t o r i n g t h e b e h a v i o r o f t h e s y s t e m a n d s o m e a d v a n c e d f e a t u r e s o f m o d e r n d i s k d r i v e c o n t r o l l e r s .  

O u r m o d e l h a s b e e n v a l i d a t e d o n s e v e r a l d i s k s a n d s y s t e m s . W e a l s o p r e s e n t a s i m p l e \ p i p e l i n i n g " t e c h n i q u e b a s e d  

u p o n t h e S C S I P r e f e t c h c o m m a n d C T 9 6 ] t o h i d e d i s k l a t e n c y ; w e p r e s e n t a n i m p l e m e n t a t i o n f o r s i t u a t i o n s i n w h i c h  

t h e S C S I P r e f e t c h c o m m a n d i s n o t s u p p o r t e d b y t h e d i s k d r i v e c o n t r o l l e r s . O u r p i p e l i n i n g i m p l e m e n t a t i o n ( e v e n  

t h o u g h w e c o u l d n o t u s e S C S I P r e f e t c h c o m m a n d s ) y i e l d s s i g n i c a n t p e r f o r m a n c e i m p r o v e m e n t s i n c e r t a i n s i t u a t i o n s .  

Page 23: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 23/203

C h a p t e r 2      

A p p l i c a t i o n - C o n t r o l l e d P a g i n g f o r a      

S h a r e d C a c h e      

S u m m a r y      

W e p r o p o s e a p r o v a b l y e c i e n t a p p l i c a t i o n - c o n t r o l l e d g l o b a l s t r a t e g y f o r o r g a n i z i n g a c a c h e o f s i z e   k  s h a r e d a m o n g  

P  a p p l i c a t i o n p r o c e s s e s . E a c h a p p l i c a t i o n h a s a c c e s s t o i n f o r m a t i o n a b o u t i t s o w n f u t u r e p a g e r e q u e s t s , a n d b y  

u s i n g t h a t l o c a l i n f o r m a t i o n a l o n g w i t h r a n d o m i z a t i o n i n t h e c o n t e x t o f a g l o b a l c a c h i n g a l g o r i t h m , w e a r e a b l e t o  

b r e a k t h r o u g h t h e c o n v e n t i o n a l   H 

  l n  k  l o w e r b o u n d o n t h e c o m p e t i t i v e r a t i o f o r t h e c a c h i n g p r o b l e m . I f t h e  

P  a p p l i c a t i o n p r o c e s s e s a l w a y s m a k e g o o d c a c h e r e p l a c e m e n t d e c i s i o n s , o u r o n l i n e a p p l i c a t i o n - c o n t r o l l e d c a c h i n g  

a l g o r i t h m a t t a i n s a c o m p e t i t i v e r a t i o o f 2  H 

P    1 

+ 2    2 l n  P  . T y p i c a l l y ,   P  i s m u c h s m a l l e r t h a n   k  , p e r h a p s b y s e v e r a l  

o r d e r s o f m a g n i t u d e . O u r c o m p e t i t i v e r a t i o i m p r o v e s u p o n t h e 2  P  + 2 c o m p e t i t i v e r a t i o a c h i e v e d b y t h e d e t e r m i n i s t i c  

a p p l i c a t i o n - c o n t r o l l e d s t r a t e g y o f C a o , F e l t e n , a n d L i . W e s h o w t h a t n o o n l i n e a p p l i c a t i o n - c o n t r o l l e d a l g o r i t h m c a n  

h a v e a c o m p e t i t i v e r a t i o b e t t e r t h a n m i n  f  H 

P    1 

; H 

g  , e v e n i f e a c h a p p l i c a t i o n p r o c e s s h a s p e r f e c t k n o w l e d g e o f i t s  

i n d i v i d u a l p a g e r e q u e s t s e q u e n c e . O u r r e s u l t s a r e w i t h r e s p e c t t o a w o r s t - c a s e i n t e r l e a v i n g o f t h e i n d i v i d u a l p a g e  

r e q u e s t s e q u e n c e s o f t h e   P  a p p l i c a t i o n p r o c e s s e s .  

W e i n t r o d u c e a n o t i o n o f f a i r n e s s i n t h e m o r e r e a l i s t i c s i t u a t i o n w h e n a p p l i c a t i o n p r o c e s s e s d o n o t a l w a y s m a k e  

g o o d c a c h e r e p l a c e m e n t d e c i s i o n s . W e s h o w t h a t o u r a l g o r i t h m e n s u r e s t h a t n o a p p l i c a t i o n p r o c e s s n e e d s t o e v i c t o n e  

o f i t s c a c h e d p a g e s t o s e r v i c e s o m e p a g e f a u l t c a u s e d b y a m i s t a k e o f s o m e o t h e r a p p l i c a t i o n . O u r a l g o r i t h m i s n o t  

o n l y f a i r , b u t r e m a i n s e c i e n t ; t h e g l o b a l p a g i n g p e r f o r m a n c e c a n b e b o u n d e d i n t e r m s o f t h e n u m b e r o f m i s t a k e s  

t h a t a p p l i c a t i o n p r o c e s s e s m a k e .  

2 . 1 I n t r o d u c t i o n      

C a c h i n g i s a u s e f u l t e c h n i q u e f o r o b t a i n i n g h i g h p e r f o r m a n c e i n t h e s e d a y s w h e r e t h e l a t e n c y o f d i s k a c c e s s i s r e l a t i v e l y  

h i g h . T o d a y ' s c o m p u t e r s t y p i c a l l y h a v e s e v e r a l a p p l i c a t i o n p r o c e s s e s r u n n i n g c o n c u r r e n t l y o n t h e m , b y m e a n s o f t i m e  

s h a r i n g a n d m u l t i p l e p r o c e s s o r s . S o m e p r o c e s s e s h a v e s p e c i a l k n o w l e d g e o f t h e i r f u t u r e a c c e s s p a t t e r n s . C a o e t a l  

C F L 9 4 a , C F L 9 4 b ] e x p l o i t t h i s s p e c i a l k n o w l e d g e t o d e v e l o p e e c t i v e l e c a c h i n g s t r a t e g i e s .  

A n a p p l i c a t i o n p r o v i d i n g s p e c i c i n f o r m a t i o n a b o u t i t s f u t u r e n e e d s i s e q u i v a l e n t t o t h e a p p l i c a t i o n h a v i n g i t s o w n  

c a c h i n g s t r a t e g y f o r m a n a g i n g i t s o w n p a g e s i n c a c h e . W e c o n s i d e r t h e   m u l t i - a p p l i c a t i o n c a c h i n g   p r o b l e m , f o r m a l l y  

d e n e d i n S e c t i o n 2 . 3 , i n w h i c h   P  c o n c u r r e n t l y e x e c u t i n g a p p l i c a t i o n p r o c e s s e s s h a r e a c o m m o n c a c h e o f s i z e   k  I n 

1 0 

Page 24: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 24/203

S e c t i o n 2 . 4 w e p r o p o s e a n o n l i n e a p p l i c a t i o n - c o n t r o l l e d c a c h i n g s c h e m e i n w h i c h d e c i s i o n s n e e d t o b e t a k e n a t t w o  

l e v e l s : w h e n a p a g e n e e d s t o b e e v i c t e d f r o m c a c h e , t h e g l o b a l s t r a t e g y c h o o s e s a v i c t i m p r o c e s s , b u t t h e p r o c e s s  

i t s e l f d e c i d e s w h i c h o f i t s p a g e s w i l l b e e v i c t e d f r o m c a c h e .  

E a c h a p p l i c a t i o n p r o c e s s m a y u s e a n y a v a i l a b l e i n f o r m a t i o n a b o u t i t s f u t u r e p a g e r e q u e s t s w h e n d e c i d i n g w h i c h  

o f i t s p a g e s t o e v i c t . H o w e v e r , w e a s s u m e   n o g l o b a l i n f o r m a t i o n   a b o u t t h e i n t e r l e a v i n g o f t h e i n d i v i d u a l p a g e r e q u e s t  

s e q u e n c e s ; a l l o u r b o u n d s a r e w i t h r e s p e c t t o a   w o r s t - c a s e i n t e r l e a v i n g   o f t h e i n d i v i d u a l r e q u e s t s e q u e n c e s .  

C o m p e t i t i v e r a t i o s s m a l l e r t h a n t h e   H 

l o w e r b o u n d f o r c l a s s i c a l c a c h i n g F K L  

9 1 ] a r e p o s s i b l e f o r m u l t i -  

a p p l i c a t i o n c a c h i n g , b e c a u s e e a c h a p p l i c a t i o n m a y e m p l o y f u t u r e i n f o r m a t i o n a b o u t i t s i n d i v i d u a l p a g e r e q u e s t  

s e q u e n c e .  

T h e d e t e r m i n i s t i c a p p l i c a t i o n - c o n t r o l l e d a l g o r i t h m p r o p o s e d b y C a o , F e l t e n , a n d L i C F L 9 4 a ] a c h i e v e s a  

c o m p e t i t i v e r a t i o o f 2   P  + 2 , a s w e p r o v e i n S e c t i o n 2 . 6 . 3 . W e s h o w i n S e c t i o n s 2 . 5 { 2 . 7 t h a t o u r n e w r a n d o m i z e d o n l i n e  

a p p l i c a t i o n - c o n t r o l l e d c a c h i n g a l g o r i t h m i m p r o v e s t h e c o m p e t i t i v e r a t i o t o 2  H 

P    1 

+ 2    2 l n  P  , w h i c h i s o p t i m a l u p  

t o a f a c t o r o f 2 i n t h e r e a l i s t i c s c e n a r i o w h e n   P < k  . ( I f w e u s e t h e a l g o r i t h m o f F K L  

9 1 ] f o r t h e c a s e   P    k  , t h e  

r e s u l t i n g b o u n d i s o p t i m a l u p t o a f a c t o r o f 2 f o r a l l   P  . ) O u r r e s u l t s a r e s i g n i c a n t s i n c e   P  i s o f t e n   m u c h   s m a l l e r  

t h a n   k  , p e r h a p s b y s e v e r a l o r d e r s o f m a g n i t u d e .  

I n S e c t i o n 2 . 6 . 3 , w e a l s o p r o v e t h a t n o d e t e r m i n i s t i c o n l i n e a p p l i c a t i o n - c o n t r o l l e d a l g o r i t h m c a n h a v e a c o m p e t i t i v e  

r a t i o b e t t e r t h a n   P  + 1 . T h u s t h e d i e r e n c e b e t w e e n o u r c o m p e t i t i v e r a t i o a n d t h a t a t t a i n e d b y t h e a l g o r i t h m b y  

C a o , F e l t e n , a n d L i i s a f u r t h e r i n d i c a t i o n o f t h e ( w e l l - k n o w n ) p o w e r o f r a n d o m i z a t i o n w h i l e s o l v i n g o n l i n e p r o b l e m s  

i n g e n e r a l a n d o n l i n e p a g i n g , i n p a r t i c u l a r .  

I n t h e s c e n a r i o w h e r e a p p l i c a t i o n p r o c e s s e s o c c a s i o n a l l y m a k e b a d p a g e r e p l a c e m e n t d e c i s i o n s ( o r \ m i s t a k e s " ) ,  

w e s h o w i n S e c t i o n 2 . 8 t h a t o u r o n l i n e a l g o r i t h m i n c u r s v e r y f e w p a g e f a u l t s g l o b a l l y a s a f u n c t i o n o f t h e n u m b e r o f  

m i s t a k e s . O u r a l g o r i t h m i s a l s o   f a i r   , i n t h e s e n s e t h a t t h e m i s t a k e s m a d e b y o n e p r o c e s s o r i n i t s p a g e r e p l a c e m e n t  

d e c i s i o n s d o n o t w o r s e n t h e p a g e f a u l t r a t e o f o t h e r p r o c e s s o r s .  

2 . 2 C l a s s i c a l C a c h i n g a n d C o m p e t i t i v e A n a l y s i s    

T h e w e l l - k n o w n   c l a s s i c a l c a c h i n g ( o r p a g i n g ) p r o b l e m   d e a l s w i t h a t w o - l e v e l m e m o r y h i e r a r c h y c o n s i s t i n g o f a f a s t  

c a c h e   o f s i z e   k  a n d  s l o w m e m o r y   o f a r b i t r a r y s i z e . A s e q u e n c e o f r e q u e s t s t o p a g e s i s t o b e s a t i s e d i n t h e i r o r d e r  

o f o c c u r r e n c e . I n o r d e r t o s a t i s f y a p a g e r e q u e s t , t h e p a g e m u s t b e i n f a s t m e m o r y . W h e n a r e q u e s t e d p a g e i s n o t  

i n f a s t m e m o r y , a   p a g e f a u l t   o c c u r s , a n d s o m e p a g e m u s t b e e v i c t e d f r o m f a s t m e m o r y t o s l o w m e m o r y i n o r d e r t o  

m a k e r o o m f o r t h e n e w p a g e t o b e p u t i n t o f a s t m e m o r y . T h e c a c h i n g ( o r p a g i n g ) p r o b l e m i s t o d e c i d e w h i c h p a g e  

m u s t b e e v i c t e d f r o m t h e c a c h e . T h e c o s t t o b e m i n i m i z e d i s t h e n u m b e r o f p a g e f a u l t s i n c u r r e d o v e r t h e c o u r s e o f  

s e r v i c i n g t h e p a g e r e q u e s t s .  

B e l a d y B e l 6 6 ] g i v e s a s i m p l e o p t i m u m o i n e a l g o r i t h m f o r t h e c a c h i n g p r o b l e m ; t h e p a g e c h o s e n f o r e v i c t i o n i s t h e  

H e r e   H 

r e p r e s e n t s t h e   n  t h h a r m o n i c n u m b e r  

i  = 1 

1  = i    l n  n  . 

1 1 

Page 25: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 25/203

o n e i n c a c h e w h o s e n e x t r e q u e s t i s f u r t h e s t i n t h e f u t u r e . I n o r d e r t o q u a n t i f y t h e p e r f o r m a n c e o f a n o n l i n e a l g o r i t h m ,  

S l e a t o r a n d T a r j a n S T 8 5 ] i n t r o d u c e t h e n o t i o n o f c o m p e t i t i v e n e s s , w h i c h i n t h e c o n t e x t o f c a c h i n g c a n b e d e n e d  

a s f o l l o w s : F o r a c a c h i n g a l g o r i t h m   A  , l e t   F 

(    ) b e t h e n u m b e r o f p a g e f a u l t s g e n e r a t e d b y   A  w h i l e p r o c e s s i n g p a g e  

r e q u e s t s e q u e n c e     I f  A  i s a r a n d o m i z e d a l g o r i t h m , w e l e t   F 

(    ) b e t h e   e x p e c t e d   n u m b e r o f p a g e f a u l t s g e n e r a t e d  

b y  A  o n p r o c e s s i n g     , w h e r e t h e e x p e c t a t i o n i s w i t h r e s p e c t t o t h e r a n d o m c h o i c e s m a d e b y t h e a l g o r i t h m . A n  

o n l i n e a l g o r i t h m   A  i s c a l l e d   c - c o m p e t i t i v e   i f f o r e v e r y p a g e r e q u e s t s e q u e n c e     , w e h a v e   F 

(    )    c    F 

O P T 

(    ) +  b  , 

w h e r e   b  i s s o m e x e d c o n s t a n t . T h e c o n s t a n t   c  i s c a l l e d t h e   c o m p e t i t i v e r a t i o   o f  A  . U n d e r t h i s m e a s u r e , a n o n l i n e  

a l g o r i t h m ' s p e r f o r m a n c e n e e d s t o b e r e l a t i v e l y g o o d o n w o r s t - c a s e p a g e r e q u e s t s e q u e n c e s i n o r d e r f o r t h e a l g o r i t h m  

t o b e c o n s i d e r e d g o o d .  

S l e a t o r a n d T a r j a n S T 8 5 ] s h o w a l o w e r b o u n d o f   k  o n t h e c o m p e t i t i v e r a t i o o f d e t e r m i n i s t i c c a c h i n g a l g o r i t h m .  

F i a t e t a l F K L  

9 1 ] p r o v e a l o w e r b o u n d o f   H 

i f r a n d o m i z e d a l g o r i t h m s a r e a l l o w e d . T h e y a l s o g i v e a s i m p l e a n d  

e l e g a n t r a n d o m i z e d a l g o r i t h m f o r t h e p r o b l e m t h a t a c h i e v e s a c o m p e t i t i v e r a t i o o f 2   H 

. S l e a t o r a n d M c G e o c h M S 9 1 ]  

g i v e a r a t h e r i n v o l v e d r a n d o m i z e d a l g o r i t h m t h a t a t t a i n s t h e t h e o r e t i c a l l y o p t i m a l c o m p e t i t i v e r a t i o o f   H 

2 . 3 M u l t i - a p p l i c a t i o n C a c h i n g P r o b l e m          

I n t h i s p a p e r w e t a k e u p t h e t h e o r e t i c a l i s s u e o f h o w b e s t t o u s e a p p l i c a t i o n p r o c e s s e s ' k n o w l e d g e a b o u t t h e i r i n d i v i d u a l  

f u t u r e p a g e r e q u e s t s s o a s t o o p t i m i z e c a c h i n g p e r f o r m a n c e . F o r a n a l y s i s p u r p o s e s w e u s e a n o n l i n e f r a m e w o r k s i m i l a r  

t o t h a t o f F K L  

9 1 , M S 9 1 ] . A s m e n t i o n e d b e f o r e , t h e c a c h i n g a l g o r i t h m s i n F K L  

9 1 , M S 9 1 ] u s e   a b s o l u t e l y n o  

i n f o r m a t i o n   a b o u t f u t u r e p a g e r e q u e s t s . I n t u i t i v e l y , k n o w l e d g e a b o u t f u t u r e p a g e r e q u e s t s c a n b e e x p l o i t e d t o d e c i d e  

w h i c h p a g e t o e v i c t f r o m t h e c a c h e a t t h e t i m e o f a p a g e f a u l t . I n p r a c t i c e a n a p p l i c a t i o n o f t e n h a s a d v a n c e k n o w l e d g e  

o f i t s i n d i v i d u a l f u t u r e p a g e r e q u e s t s . C a o , F e l t e n a n d L i C F L 9 4 a , C F L 9 4 b ] i n t r o d u c e d s t r a t e g i e s t h a t t r y t o c o m b i n e  

t h e a d v a n c e k n o w l e d g e o f t h e p r o c e s s o r s i n o r d e r t o m a k e i n t e l l i g e n t p a g e r e p l a c e m e n t d e c i s i o n s .  

I n t h e   m u l t i - a p p l i c a t i o n c a c h i n g p r o b l e m   w e c o n s i d e r a c a c h e c a p a b l e o f s t o r i n g   k  p a g e s t h a t i s s h a r e d  

b y  P  d i e r e n t a p p l i c a t i o n p r o c e s s e s , w h i c h w e d e n o t e   P 

,  P 

,  ,  P 

. E a c h p a g e i n c a c h e a n d m e m o r y  

b e l o n g s t o e x a c t l y o n e p r o c e s s . T h e i n d i v i d u a l r e q u e s t s e q u e n c e s o f t h e p r o c e s s e s m a y b e i n t e r l e a v e d i n  

a n a r b i t r a r y ( w o r s t - c a s e ) m a n n e r .  

W o r s t - c a s e m e a s u r e i s o f t e n c r i t i c i z e d w h e n u s e d f o r e v a l u a t i n g c a c h i n g a l g o r i t h m s f o r i n d i v i d u a l a p p l i c a t i o n  

r e q u e s t s e q u e n c e s B I R S 9 1 , K P R 9 2 ] , b u t w e f e e l t h a t t h e w o r s t - c a s e m e a s u r e i s a p p r o p r i a t e f o r c o n s i d e r i n g a g l o b a l  

p a g i n g s t r a t e g y f o r a c a c h e s h a r e d b y c o n c u r r e n t a p p l i c a t i o n p r o c e s s e s t h a t h a v e k n o w l e d g e o f t h e i r i n d i v i d u a l p a g e  

r e q u e s t s e q u e n c e s . T h e l o c a l i t y o f r e f e r e n c e w i t h i n e a c h a p p l i c a t i o n ' s i n d i v i d u a l r e q u e s t s e q u e n c e i s a c c o u n t e d f o r i n  

o u r m o d e l b y e a c h a p p l i c a t i o n p r o c e s s ' s k n o w l e d g e o f i t s o w n f u t u r e r e q u e s t s . T h e w o r s t - c a s e n a t u r e o f o u r m o d e l  

i s t h a t i t a s s u m e s n o t h i n g a b o u t t h e o r d e r a n d d u r a t i o n s o f t i m e f o r w h i c h a p p l i c a t i o n p r o c e s s e s a r e a c t i v e . I n  

1 2 

Page 26: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 26/203

t h i s m o d e l o u r w o r s t - c a s e m e a s u r e o f c o m p e t i t i v e p e r f o r m a n c e a m o u n t s t o c o n s i d e r i n g a   w o r s t - c a s e i n t e r l e a v i n g   o f 

i n d i v i d u a l s e q u e n c e s .  

T h e a p p r o a c h o f C a o e t a l C F L 9 4 a ] i s t o h a v e t h e k e r n e l d e t e r m i n i s t i c a l l y c h o o s e t h e p r o c e s s o w n i n g t h e l e a s t  

r e c e n t l y u s e d p a g e a t t h e t i m e o f a p a g e f a u l t a n d a s k t h a t p r o c e s s t o e v i c t a p a g e o f i t s c h o i c e ( w h i c h m a y b e d i e r e n t  

f r o m t h e l e a s t r e c e n t l y u s e d p a g e ) . I n S e c t i o n 2 . 6 . 3 , w e s h o w u n d e r t h e a s s u m p t i o n t h a t p r o c e s s e s a l w a y s m a k e g o o d  

p a g e r e p l a c e m e n t d e c i s i o n s t h a t C a o e t a l ' s a l g o r i t h m h a s a c o m p e t i t i v e r a t i o b e t w e e n   P  + 1 a n d 2  P  + 2 . T h e a l g o r i t h m  

w e p r e s e n t i n t h e n e x t s e c t i o n a n d a n a l y z e t h e r e a f t e r i m p r o v e s t h e c o m p e t i t i v e r a t i o t o 2  H 

P    1 

+ 2    2 l n  P 

2 . 4 O n l i n e A l g o r i t h m f o r M u l t i - a p p l i c a t i o n C a c h i n g      

O u r a l g o r i t h m i s a n o n l i n e a p p l i c a t i o n - c o n t r o l l e d c a c h i n g s t r a t e g y f o r a n o p e r a t i n g s y s t e m k e r n e l t o m a n a g e a s h a r e d  

c a c h e i n a n e c i e n t a n d f a i r m a n n e r . W e s h o w i n t h e s u b s e q u e n t s e c t i o n s t h a t t h e c o m p e t i t i v e r a t i o o f o u r a l g o r i t h m  

i s 2  H 

P    1 

+ 2    2 l n  P  a n d t h a t i t i s o p t i m a l t o w i t h i n a f a c t o r o f a b o u t 2 a m o n g a l l o n l i n e a l g o r i t h m s . ( I f   P    k  , w e 

c a n u s e t h e a l g o r i t h m o f F K L  

9 1 ] . )  

O n a p a g e f a u l t , w e r s t c h o o s e a v i c t i m p r o c e s s a n d t h e n a s k i t t o e v i c t a s u i t a b l e p a g e . O u r a l g o r i t h m c a n  

d e t e c t m i s t a k e s m a d e b y a p p l i c a t i o n p r o c e s s e s , w h i c h e n a b l e s u s t o r e p r i m a n d s u c h a p p l i c a t i o n p r o c e s s e s b y h a v i n g  

t h e m p a y f o r t h e i r m i s t a k e s . I n o u r s c h e m e , w e m a r k p a g e s a s w e l l a s p r o c e s s e s i n a s y s t e m a t i c w a y w h i l e p r o c e s s i n g  

t h e r e q u e s t s t h a t c o n s t i t u t e a p h a s e .  

D e n i t i o n 1   T h e g l o b a l s e q u e n c e o f p a g e r e q u e s t s i s p a r t i t i o n e d i n t o a c o n s e c u t i v e s e q u e n c e o f   p h a s e s  ; e a c h p h a s e  

i s a s e q u e n c e o f p a g e r e q u e s t s . A t t h e b e g i n n i n g o f e a c h p h a s e , a l l p a g e s a n d p r o c e s s e s a r e u n m a r k e d . A p a g e g e t s  

m a r k e d d u r i n g a p h a s e w h e n i t i s r e q u e s t e d . A p r o c e s s i s m a r k e d w h e n a l l o f i t s p a g e s i n c a c h e a r e m a r k e d . A n e w  

p h a s e b e g i n s w h e n a p a g e i s r e q u e s t e d t h a t i s n o t i n c a c h e a n d a l l t h e p a g e s i n c a c h e a r e m a r k e d . A p a g e a c c e s s e d  

d u r i n g a p h a s e i s c a l l e d   c l e a n   w i t h r e s p e c t t o t h a t p h a s e i f i t w a s n o t i n t h e o n l i n e a l g o r i t h m ' s c a c h e a t t h e b e g i n n i n g  

o f a p h a s e . A r e q u e s t t o a c l e a n p a g e i s c a l l e d a   c l e a n p a g e r e q u e s t  . E a c h p h a s e a l w a y s b e g i n s w i t h a c l e a n p a g e  

r e q u e s t .  

O u r m a r k i n g s c h e m e i s s i m i l a r t o t h e o n e i n F K L  

9 1 ] f o r t h e c l a s s i c a l c a c h i n g p r o b l e m . H o w e v e r , u n l i k e t h e  

a l g o r i t h m i n F K L  

9 1 ] , t h e a l g o r i t h m w e d e v e l o p i s a n o n - m a r k i n g a l g o r i t h m , i n t h e s e n s e t h a t o u r a l g o r i t h m m a y  

e v i c t m a r k e d p a g e s . I n a d d i t i o n , o u r n o t i o n o f p h a s e i n D e n i n t i o n 1 i s d i e r e n t f r o m t h e n o t i o n o f p h a s e i n F K L  

9 1 ] ,  

w h i c h c a n b e l o o k e d u p o n a s a s p e c i a l c a s e o f o u r m o r e g e n e r a l n o t i o n . W e p u t t h e d i e r e n c e s i n t o p e r s p e c t i v e i n  

S e c t i o n 2 . 4 . 1 .  

O u r a l g o r i t h m w o r k s a s f o l l o w s w h e n a p a g e    p  b e l o n g i n g t o p r o c e s s   P 

i s r e q u e s t e d :  

1 . I f    p  i s i n c a c h e :  

1 3 

Page 27: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 27/203

( a ) I f    p  i s n o t m a r k e d , w e m a r k i t .  

( b ) I f p r o c e s s   P 

h a s n o u n m a r k e d p a g e s i n c a c h e , w e m a r k   P 

2 . I f    p  i s n o t i n c a c h e :  

( a ) I f p r o c e s s   P 

i s u n m a r k e d a n d p a g e    p  i s  n o t  a c l e a n p a g e w i t h r e s p e c t t o t h e o n g o i n g p h a s e ( i . e ,   P 

h a s 

m a d e a m i s t a k e e a r l i e r i n t h e p h a s e b y e v i c t i n g    p  ) t h e n :  

i . W e a s k p r o c e s s   P 

t o m a k e a p a g e r e p l a c e m e n t d e c i s i o n a n d e v i c t o n e o f i t s p a g e s f r o m c a c h e i n o r d e r  

t o b r i n g p a g e    p  i n t o c a c h e . W e m a r k p a g e    p  a n d a l s o m a r k p r o c e s s   P 

i f i t n o w h a s n o u n m a r k e d p a g e s  

i n c a c h e .  

( b ) E l s e ( p r o c e s s   P 

i s m a r k e d o r p a g e    p  i s a c l e a n p a g e , o r b o t h ) :  

i . I f a l l p a g e s i n c a c h e a r e m a r k e d , w e r e m o v e m a r k s f r o m a l l p a g e s a n d p r o c e s s e s , a n d w e s t a r t a n e w  

p h a s e , b e g i n n i n g w i t h t h e c u r r e n t r e q u e s t f o r    p 

i i . L e t   S  d e n o t e t h e s e t o f u n m a r k e d p r o c e s s e s h a v i n g p a g e s i n t h e c a c h e . W e r a n d o m l y c h o o s e a p r o c e s s   P 

f r o m   S  , e a c h p r o c e s s b e i n g c h o s e n w i t h a u n i f o r m p r o b a b i l i t y 1  =  j  S  j 

i i i . W e a s k p r o c e s s   P 

t o m a k e a p a g e r e p l a c e m e n t d e c i s i o n a n d e v i c t o n e o f i t s p a g e s f r o m c a c h e i n o r d e r  

t o b r i n g p a g e    p  i n t o c a c h e . W e m a r k p a g e    p  a n d a l s o m a r k p r o c e s s   P 

i f i t n o w h a s n o u n m a r k e d p a g e  

i n c a c h e .  

N o t e t h a t i n S t e p s 2 ( a ) i a n d 2 ( b ) i i i o u r a l g o r i t h m s e e k s p a g i n g d e c i s i o n s f r o m a p p l i c a t i o n p r o c e s s e s t h a t a r e  

u n m a r k e d . C o n s i d e r a n u n m a r k e d p r o c e s s   P 

t h a t h a s b e e n a s k e d t o e v i c t a p a g e i n a p h a s e , a n d c o n s i d e r   P 

' s p a g e s  

i n c a c h e a t t h a t t i m e . L e t   u 

d e n o t e t h e   f a r t h e s t u n m a r k e d   p a g e o f p r o c e s s   P 

; t h a t i s ,   u 

i s t h e u n m a r k e d p a g e  

o f p r o c e s s   P 

w h o s e n e x t r e q u e s t o c c u r s f u r t h e s t i n t h e f u t u r e a m o n g a l l o f   P 

' s u n m a r k e d c a c h e d p a g e s . N o t e t h a t  

p r o c e s s   P 

m a y h a v e m a r k e d p a g e s i n c a c h e w h o s e n e x t r e q u e s t s o c c u r a f t e r t h e r e q u e s t f o r   u 

D e n i t i o n 2   T h e  g o o d s e t   o f a n u n m a r k e d p r o c e s s   P 

a t t h e c u r r e n t p o i n t i n t h e p h a s e i s t h e s e t c o n s i s t i n g o f i t s  

f a r t h e s t u n m a r k e d p a g e   u 

i n c a c h e a n d e v e r y m a r k e d p a g e o f   P 

i n c a c h e w h o s e n e x t r e q u e s t o c c u r s   a f t e r   t h e n e x t  

r e q u e s t f o r p a g e   u 

. A p a g e r e p l a c e m e n t d e c i s i o n m a d e b y a n u n m a r k e d p r o c e s s   P 

i n e i t h e r S t e p 2 ( a ) i o r S t e p 2 ( b ) i i i  

t h a t e v i c t s a p a g e f r o m i t s g o o d s e t i s r e g a r d e d a s a   g o o d d e c i s i o n   w i t h r e s p e c t t o t h e o n g o i n g p h a s e . A n y p a g e f r o m  

t h e g o o d s e t o f  P 

i s a  g o o d p a g e   f o r e v i c t i o n p u r p o s e s a t t h e t i m e o f t h e d e c i s i o n . A n y d e c i s i o n m a d e b y a n u n m a r k e d  

p r o c e s s   P 

t h a t i s n o t a g o o d d e c i s i o n i s r e g a r d e d a s a   m i s t a k e   b y p r o c e s s   P 

I f a p r o c e s s   P 

m a k e s a m i s t a k e b y e v i c t i n g a c e r t a i n p a g e f r o m c a c h e , w e c a n d e t e c t t h e m i s t a k e m a d e b y   P 

i f 

a n d w h e n t h e s a m e p a g e i s r e q u e s t e d a g a i n b y   P 

i n t h e s a m e p h a s e w h i l e   P 

i s s t i l l u n m a r k e d .  

I n S e c t i o n s 2 . 6 a n d 2 . 7 w e s p e c i c a l l y a s s u m e t h a t a p p l i c a t i o n p r o c e s s e s a r e a l w a y s a b l e t o m a k e g o o d d e c i s i o n s  

a b o u t p a g e r e p l a c e m e n t . I n S e c t i o n 2 . 8 w e c o n s i d e r f a i r n e s s p r o p e r t i e s o f o u r a l g o r i t h m i n t h e m o r e r e a l i s t i c s c e n a r i o  

w h e r e p r o c e s s e s c a n m a k e m i s t a k e s .  

1 4 

Page 28: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 28/203

2 . 4 . 1 R e l a t i o n t o P r e v i o u s W o r k o n C l a s s i c a l C a c h i n g  

O u r m a r k i n g s c h e m e a p p r o a c h i s i n s p i r e d b y a s i m i l a r a p p r o a c h f o r t h e c l a s s i c a l c a c h i n g p r o b l e m i n F K L  

9 1 ] .  

H o w e v e r , t h e p h a s e s d e n e d b y o u r a l g o r i t h m a r e s i g n i c a n t l y d i e r e n t i n n a t u r e f r o m t h o s e i n F K L  

9 1 ] . O u r p h a s e  

e n d s w h e n t h e r e a r e   k  d i s t i n c t m a r k e d p a g e s i n c a c h e ; m o r e t h a n   k  d i s t i n c t p a g e s m a y b e r e q u e s t e d i n t h e p h a s e .  

T h e p h a s e s d e p e n d u p o n t h e r a n d o m c h o i c e s m a d e b y t h e a l g o r i t h m a n d a r e p r o b a b i l i s t i c i n n a t u r e . O n t h e o t h e r  

h a n d , a p h a s e d e n e d i n F K L  

9 1 ] e n d s w h e n e x a c t l y   k  d i s t i n c t p a g e s h a v e b e e n a c c e s s e d , s o t h a t g i v e n t h e i n p u t  

r e q u e s t s e q u e n c e , t h e p h a s e s c a n b e d e t e r m i n e d i n d e p e n d e n t l y o f t h e c a c h i n g a l g o r i t h m b e i n g u s e d .  

T h e d e n i t i o n i n F K L  

9 1 ] i s s u i t e d t o f a c i l i t a t e t h e a n a l y s i s o f o n l i n e c a c h i n g a l g o r i t h m s t h a t n e v e r e v i c t m a r k e d  

p a g e s , c a l l e d   m a r k i n g a l g o r i t h m s  . I n t h e c a s e o f m a r k i n g a l g o r i t h m s , s i n c e m a r k e d p a g e s a r e n e v e r e v i c t e d , a s s o o n  

a s  k  d i s t i n c t p a g e s a r e r e q u e s t e d , t h e r e a r e   k  d i s t i n c t m a r k e d p a g e s   i n  c a c h e . T h i s m e a n s t h a t t h e p h a s e s d e t e r m i n e d  

b y o u r d e n i t i o n f o r t h e s p e c i a l c a s e o f m a r k i n g a l g o r i t h m s a r e e x a c t l y t h e s a m e a s t h e p h a s e s d e t e r m i n e d b y t h e  

d e n i t i o n i n F K L  

9 1 ] . N o t e t h a t o u r a l g o r i t h m i s i n g e n e r a l   n o t  a m a r k i n g a l g o r i t h m s i n c e i t m a y e v i c t m a r k e d  

p a g e s . W h i l e m a r k i n g a l g o r i t h m s a l w a y s e v i c t u n m a r k e d p a g e s , o u r a l g o r i t h m a l w a y s c a l l s o n u n m a r k e d p r o c e s s e s t o  

e v i c t p a g e s ; t h e a c t u a l p a g e s e v i c t e d m a y b e m a r k e d .  

2 . 5 L o w e r B o u n d s f o r    O P T 

a n d C o m p e t i t i v e R a t i o      

I n S e c t i o n 2 . 6 . 3 , w e p r o v e a l o w e r b o u n d o f m i n  f  P  + 1  ; k  g  o n t h e c o m p e t i t i v e r a t i o o f a n y   d e t e r m i n i s t i c   o n l i n e  

a l g o r i t h m f o r m u l t i - a p p l i c a t i o n c a c h i n g . I n t h i s s e c t i o n , w e p r o v e t h e s t r o n g e r r e s u l t t h a t t h a t t h e c o m p e t i t i v e r a t i o  

o f  a n y  o n l i n e c a c h i n g a l g o r i t h m c a n b e n o b e t t e r t h a n m i n  f  H 

P    1 

; H 

g  : T h i s l o w e r b o u n d h o l d s e v e n f o r r a n d o m i z e d  

c a c h i n g a l g o r i t h m s .  

L e t u s d e n o t e b y   O P T  t h e o p t i m a l o i n e a l g o r i t h m f o r c a c h i n g t h a t w o r k s a s f o l l o w s : W h e n a p a g e f a u l t o c c u r s ,  

O P T  e v i c t s t h e p a g e w h o s e n e x t r e q u e s t i s f u r t h e s t i n t h e f u t u r e r e q u e s t s e q u e n c e a m o n g a l l p a g e s i n c a c h e .  

A s i n F K L  

9 1 ] , w e w i l l c o m p a r e t h e n u m b e r o f p a g e f a u l t s g e n e r a t e d b y o u r o n l i n e a l g o r i t h m d u r i n g a p h a s e w i t h  

t h e n u m b e r o f p a g e f a u l t s g e n e r a t e d b y   O P T  d u r i n g t h a t p h a s e . W e e x p r e s s t h e n u m b e r o f p a g e f r o n t s a s a f u n c t i o n  

o f t h e n u m b e r o f c l e a n p a g e r e q u e s t s d u r i n g t h e p h a s e . H e r e w e s t a t e a n d p r o v e a l o w e r b o u n d o n t h e ( a m o r t i z e d )  

n u m b e r o f p a g e f a u l t s g e n e r a t e d b y   O P T  i n a s i n g l e p h a s e . T h e p r o o f i s a s i m p l e g e n e r a l i z a t i o n o f a n a n a l o g o u s  

p r o o f i n F K L  

9 1 ] , w h i c h d e a l s o n l y w i t h t h e d e t e r m i n i s t i c p h a s e s o f m a r k i n g a l g o r i t h m s .  

L e m m a 1   C o n s i d e r a n y p h a s e    

o f o u r o n l i n e a l g o r i t h m i n w h i c h    ̀

c l e a n p a g e s a r e r e q u e s t e d . T h e n O P T i n c u r s  

a n a m o r t i z e d c o s t o f a t l e a s t    ̀

=  2  o n t h e r e q u e s t s m a d e i n t h a t p h a s e .  

B y \ a m o r t i z e d " i n L e m m a 1 w e m e a n f o r e a c h   j    1 t h a t t h e n u m b e r o f p a g e f a u l t s m a d e b y  

O P T  w h i l e s e r v i n g t h e r s t   j  p h a s e s i s a t l e a s t  

i  = 1 

 ̀

=  2 , w h e r e    ̀

i s t h e n u m b e r o f c l e a n p a g e  

r e q u e s t s i n t h e   i  t h p h a s e .  

1 5 

Page 29: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 29/203

P r o o f  : L e t   d 

b e t h e n u m b e r o f c l e a n p a g e s i n   O P T  ' s c a c h e a t t h e b e g i n n i n g o f p h a s e    

; t h a t i s ,   d 

i s t h e n u m b e r  

o f p a g e s r e q u e s t e d i n    

t h a t a r e i n   O P T  ' s c a c h e b u t n o t i n o u r a l g o r i t h m ' s c a c h e a t t h e b e g i n n i n g o f    

. L e t   d 

i  + 1 

r e p r e s e n t t h e s a m e q u a n t i t y f o r t h e n e x t p h a s e    

i  + 1 

. L e t   d 

i  + 1 

=  d 

+  d 

, w h e r e   d 

o f t h e   d 

i  + 1 

c l e a n p a g e s i n  

O P T  ' s c a c h e a t t h e b e g i n n i n g o f    

i  + 1 

a r e m a r k e d d u r i n g    

a n d  d 

o f t h e m a r e n o t m a r k e d d u r i n g    

. N o t e t h a t  

= 0 a n d   d 

  k  f o r a l l   i 

O f t h e    ̀

c l e a n p a g e s r e q u e s t e d d u r i n g    

, o n l y   d 

a r e i n   O P T  ' s c a c h e , s o   O P T  g e n e r a t e s a t l e a s t    ̀

  d 

p a g e  

f a u l t s d u r i n g    

. O n t h e o t h e r h a n d , w h i l e p r o c e s s i n g t h e r e q u e s t s i n    

,  O P T  c a n n o t u s e   d 

o f t h e c a c h e l o c a t i o n s ,  

s i n c e a t t h e b e g i n n i n g o f    

i  + 1 

t h e r e a r e   d 

p a g e s i n   O P T  ' s c a c h e t h a t a r e n o t m a r k e d d u r i n g    

. ( T h e s e   d 

p a g e s  

w o u l d h a v e t o b e i n   O P T  ' s c a c h e b e f o r e    

e v e n b e g a n . ) T h e r e a r e   k  m a r k e d p a g e s i n o u r a l g o r i t h m ' s c a c h e a t t h e  

e n d o f    

, a n d t h e r e a r e   d 

o t h e r p a g e s m a r k e d d u r i n g    

t h a t a r e o u t o f o u r a l g o r i t h m ' s c a c h e . S o t h e n u m b e r o f  

d i s t i n c t p a g e s r e q u e s t e d d u r i n g    

i s a t l e a s t   d 

+  k  . H e n c e ,   O P T  s e r v e s a t l e a s t   d 

+  k  r e q u e s t s c o r r e s p o n d i n g t o  

 

w i t h o u t u s i n g   d 

o f t h e c a c h e l o c a t i o n s . T h i s m e a n s t h a t   O P T  g e n e r a t e s a t l e a s t (  k  +  d 

)    (  k    d 

) =  d 

i  + 1 

f a u l t s d u r i n g    

. T h e r e f o r e , t h e n u m b e r o f f a u l t s   O P T  g e n e r a t e s o n    

i s a t l e a s t  

m a x  f   ̀

  d 

; d 

i  + 1 

g  

 ̀

  d 

+  d 

i  + 1 

L e t u s c o n s i d e r t h e r s t   j  p h a s e s . I n t h e   j  t h p h a s e o f t h e s e q u e n c e ,   O P T  h a s a t l e a s t    ̀

  d 

  (   ̀

  d 

)  =  2 f a u l t s .  

I n t h e r s t p h a s e ,  O P T  g e n e r a t e s   k  f a u l t s a n d    ̀

=  k  . T h u s t h e s u m o f   O P T  ' s f a u l t s o v e r a l l p h a s e s i s a t l e a s t  

 ̀

j    1 

X   

i  = 2 

 ̀

  d 

+  d 

i  + 1 

 ̀

  d 

 

X   

i  = 1 

 ̀

=  2  ; 

w h e r e w e u s e t h e f a c t t h a t   d 

  k  =   ̀

. T h u s b y d e n i t i o n , t h e a m o r t i z e d n u m b e r o f f a u l t s   O P T  g e n e r a t e s o v e r a n y  

p h a s e    

i s a t l e a s t    ̀

=  2

N e x t w e w i l l c o n s t r u c t a l o w e r b o u n d f o r t h e c o m p e t i t i v e r a t i o o f   a n y  r a n d o m i z e d o n l i n e a l g o r i t h m e v e n w h e n  

a p p l i c a t i o n p r o c e s s e s h a v e p e r f e c t k n o w l e d g e o f t h e i r i n d i v i d u a l r e q u e s t s e q u e n c e s . T h e p r o o f i s a s t r a i g h t f o r w a r d  

a d a p t a t i o n o f t h e p r o o f o f t h e   H 

l o w e r b o u n d f o r c l a s s i c a l c a c h i n g F K L  

9 1 ] . H o w e v e r , i n t h e s i t u a t i o n a t h a n d , t h e  

a d v e r s a r y h a s m o r e r e s t r i c t i o n s o n t h e r e q u e s t s e q u e n c e t h a t h e c a n u s e t o p r o v e t h e l o w e r b o u n d , t h e r e b y r e s u l t i n g  

i n a l o w e r i n g o f t h e l o w e r b o u n d .  

T h e o r e m 1   T h e c o m p e t i t i v e r a t i o o f a n y r a n d o m i z e d a l g o r i t h m f o r t h e m u l t i - a p p l i c a t i o n c a c h i n g p r o b l e m i s a t l e a s t  

m i n  f  H 

P    1 

; H 

g  e v e n i f a p p l i c a t i o n p r o c e s s e s h a v e p e r f e c t k n o w l e d g e o f t h e i r i n d i v i d u a l r e q u e s t s e q u e n c e s .  

P r o o f  : I f  P > k  , t h e   H 

l o w e r b o u n d o n t h e c l a s s i c a l c a c h i n g p r o b l e m f r o m F K L  

9 1 ] i s d i r e c t l y a p p l i c a b l e b y  

c o n s i d e r i n g t h e c a s e w h e r e e a c h p r o c e s s a c c e s s e s o n l y o n e p a g e e a c h . T h i s g i v e s a l o w e r b o u n d o f   H 

o n c o m p e t i t i v e  

r a t i o .  

1 6 

Page 30: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 30/203

I n t h e c a s e w h e n   P    k  , w e c o n s t r u c t a m u l t i - a p p l i c a t i o n c a c h i n g p r o b l e m b a s e d u p o n t h e n e m e s i s s e q u e n c e u s e d  

i n F K L  

9 1 ] f o r c l a s s i c a l c a c h i n g . I n F K L  

9 1 ] a l o w e r b o u n d o f   H 

0  i s p r o v e d f o r t h e s p e c i a l c a s e o f a c a c h e o f  

s i z e   k 

a n d a t o t a l o f   k 

+ 1 p a g e s , w h i c h w e d e n o t e   c 

,  c 

,  ,  c 

+ 1 

. A l l b u t o n e o f t h e p a g e s c a n t i n c a c h e a t  

t h e s a m e t i m e . O u r c o r r e s p o n d i n g m u l t i - a p p l i c a t i o n c a c h i n g p r o b l e m c o n s i s t s o f   P  =  k 

+ 1 a p p l i c a t i o n p r o c e s s e s  

,  P 

,  ,  P 

s o t h a t t h e r e i s o n e p r o c e s s c o r r e s p o n d i n g t o e a c h p a g e o f t h e c l a s s i c a l c a c h i n g l o w e r b o u n d i n s t a n c e  

f o r a   k 

- s i z e d c a c h e . P r o c e s s   P 

o w n s   r 

p a g e s    p 

i  1 

,   p 

i  2 

,  : : : p  

i r 

. T h e t o t a l n u m b e r  

P  

i  = 1 

o f p a g e s a m o n g a l l  

t h e p r o c e s s e s i s   k  + 1 , w h e r e   k  i s t h e c a c h e s i z e ; t h a t i s , a l l b u t o n e o f t h e p a g e s a m o n g a l l t h e p r o c e s s e s c a n t i n  

m e m o r y s i m u l t a n e o u s l y .  

I n t h e i n s t a n c e o f t h e m u l t i - a p p l i c a t i o n c a c h i n g p r o b l e m w e c o n s t r u c t , t h e r e q u e s t s e q u e n c e f o r e a c h p r o c e s s   P 

c o n s i s t s o f r e p e t i t i o n s o f t h e d o u b l e r o u n d - r o b i n s e q u e n c e  

 p 

i  1 

; p 

i  2 

; : : : ; p  

i r 

; p 

i  1 

; p 

i  2 

; : : : ; p  

i r 

( 2 . 1 )  

o f l e n g t h 2  r 

. W e r e f e r t o t h e d o u b l e r o u n d - r o b i n s e q u e n c e ( 2 . 1 ) a s a   t o u c h   o f p r o c e s s   P 

. W h e n t h e a d v e r s a r y  

g e n e r a t e s r e q u e s t s c o r r e s p o n d i n g t o a t o u c h o f p r o c e s s   P 

, w e s a y t h a t i t \ t o u c h e s p r o c e s s   P 

G i v e n a n a r b i t r a r y a d v e r s a r i a l s e q u e n c e f o r t h e c l a s s i c a l c a c h i n g p r o b l e m d e s c r i b e d a b o v e , w e c o n s t r u c t a n a d v e r -  

s a r i a l s e q u e n c e f o r t h e m u l t i - a p p l i c a t i o n c a c h i n g p r o b l e m b y r e p l a c i n g e a c h r e q u e s t f o r p a g e   c 

i n t h e f o r m e r p r o b l e m  

b y a t o u c h o f p r o c e s s   P 

i n t h e l a t t e r p r o b l e m . W e c a n t r a n s f o r m a n a l g o r i t h m f o r t h i s i n s t a n c e o f m u l t i - a p p l i c a t i o n  

c a c h i n g i n t o o n e f o r t h e c l a s s i c a l c a c h i n g p r o b l e m b y t h e f o l l o w i n g c o r r e s p o n d e n c e : I f t h e m u l t i - a p p l i c a t i o n a l g o r i t h m  

e v i c t s a p a g e f r o m p r o c e s s   P 

w h i l e s e r v i c i n g t h e t o u c h o f p r o c e s s   P 

, t h e c l a s s i c a l c a c h i n g a l g o r i t h m e v i c t s p a g e   c 

i n o r d e r t o s e r v i c e t h e r e q u e s t t o p a g e   c 

. I n L e m m a 2 b e l o w , w e s h o w t h a t t h e r e i s a n o p t i m u m o n l i n e a l g o r i t h m  

f o r t h e a b o v e i n s t a n c e o f m u l t i - a p p l i c a t i o n c a c h i n g t h a t n e v e r e v i c t s a p a g e b e l o n g i n g t o p r o c e s s   P 

w h i l e s e r v i c i n g a  

f a u l t o n a r e q u e s t f o r a p a g e f r o m p r o c e s s   P 

. T h u s t h e t r a n s f o r m a t i o n i s v a l i d , i n t h a t p a g e   c 

i s a l w a y s r e s i d e n t i n  

c a c h e a f t e r t h e p a g e r e q u e s t t o   c 

i s s e r v i c e d . T h i s r e d u c t i o n i m m e d i a t e l y i m p l i e s t h a t t h e c o m p e t i t i v e r a t i o f o r t h i s  

i n s t a n c e o f m u l t i - a p p l i c a t i o n c a c h i n g m u s t b e a t l e a s t   H 

0  =  H 

P    1 

L e m m a 2   F o r t h e a b o v e i n s t a n c e o f m u l t i - a p p l i c a t i o n c a c h i n g , a n y o n l i n e a l g o r i t h m   A  c a n b e c o n v e r t e d i n t o a n  

o n l i n e a l g o r i t h m   A 

t h a t i s a t l e a s t a s g o o d i n a n a m o r t i z e d s e n s e a n d t h a t h a s t h e p r o p e r t y t h a t a l l t h e p a g e s f o r  

p r o c e s s   P 

a r e i n c a c h e i m m e d i a t e l y a f t e r a t o u c h o f   P 

i s p r o c e s s e d .  

P r o o f   : I n t u i t i v e l y , t h e d o u b l e r o u n d - r o b i n s e q u e n c e s f o r c e a n o p t i m a l o n l i n e a l g o r i t h m t o s e r v i c e t h e t o u c h o f a  

p r o c e s s b y e v i c t i n g a p a g e b e l o n g i n g t o   a n o t h e r   p r o c e s s . W e c o n s t r u c t o n l i n e a l g o r i t h m   A 

f r o m   A  i n a n o n l i n e  

m a n n e r . S u p p o s e t h a t b o t h   A  a n d  A 

f a u l t d u r i n g a t o u c h o f p r o c e s s   P 

. I f a l g o r i t h m   A  e v i c t s a p a g e o f   P 

, f o r s o m e  

j  6=  i  , t h e n   A 

d o e s t h e s a m e . I f a l g o r i t h m   A  e v i c t s a p a g e o f   P 

d u r i n g t h e r s t r o u n d - r o b i n w h i l e s e r v i c i n g a t o u c h  

o f  P 

, t h e n t h e r e w i l l b e a p a g e f a u l t d u r i n g t h e s e c o n d r o u n d - r o b i n . I f   A  t h e n e v i c t s a p a g e o f a n o t h e r p r o c e s s d u r i n g  

t h e s e c o n d r o u n d - r o b i n , t h e n   A 

e v i c t s t h a t p a g e d u r i n g t h e r s t r o u n d - r o b i n a n d i n c u r s n o f a u l t d u r i n g t h e s e c o n d  

1 7 

Page 31: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 31/203

r o u n d - r o b i n . T h e r s t p a g e f a u l t o f   A  w a s w a s t e d ; t h e o t h e r p a g e c o u l d h a v e b e e n e v i c t e d i n s t e a d d u r i n g t h e r s t  

r o u n d - r o b i n . I f i n s t e a d   A  e v i c t s a n o t h e r p a g e o f   P 

d u r i n g t h e s e c o n d r o u n d - r o b i n , t h e n   A 

e v i c t s a n a r b i t r a r y p a g e  

o f a n o t h e r p r o c e s s d u r i n g t h e r s t r o u n d - r o b i n , a n d   A 

i n c u r s n o p a g e f a u l t d u r i n g t h e s e c o n d r o u n d - r o b i n . T h u s , i f  

A  e v i c t s a p a g e o f   P 

, i t i n c u r s a t l e a s t o n e m o r e p a g e f a u l t t h a n d o e s   A 

I f  A  f a u l t s d u r i n g a t o u c h o f   P 

, b u t   A 

d o e s n ' t , t h e r e i s n o p a g i n g d e c i s i o n f o r   A 

t o m a k e . I f   A  d o e s n o t f a u l t  

d u r i n g a t o u c h o f   P 

, b u t   A 

d o e s f a u l t , t h e n   A 

e v i c t s t h e p a g e t h a t i s n o t i n   A  ' s c a c h e . T h e p a g e f a u l t f o r   A 

i s 

c h a r g e d t o t h e e x t r a p a g e f a u l t t h a t   A  i n c u r r e d e a r l i e r w h e n   A 

e v i c t e d o n e o f   P 

' s p a g e s .  

T h u s t h e n u m b e r o f p a g e f a u l t s t h a t   A 

i n c u r s i s n o m o r e t h a n t h e n u m b e r o f p a g e f a u l t s t h a t   A  i n c u r s . B y  

c o n s t r u c t i o n , a l l p a g e s o f p r o c e s s   P 

a r e i n a l g o r i t h m   A 

' s c a c h e i m m e d i a t e l y a f t e r a t o u c h o f p r o c e s s   P 

T h e d o u b l e r o u n d - r o b i n s e q u e n c e s i n t h e a b o v e r e d u c t i o n c a n b e r e p l a c e d b y s i n g l e r o u n d - r o b i n s e q u e n c e s b y  

r e d o i n g t h e e x p l i c i t l o w e r b o u n d a r g u m e n t o f F K L  

9 1 ] .  

2 . 6 H o l e s    

I n t h i s s e c t i o n , w e i n t r o d u c e t h e n o t i o n o f h o l e s , w h i c h p l a y s a k e y r o l e i n t h e a n a l y s i s o f o u r o n l i n e c a c h i n g a l g o r i t h m .  

I n S e c t i o n 2 . 6 . 2 , w e m e n t i o n s o m e c r u c i a l p r o p e r t i e s o f h o l e s o f o u r a l g o r i t h m u n d e r t h e a s s u m p t i o n t h a t a p p l i c a t i o n s  

a l w a y s m a k e g o o d p a g e r e p l a c e m e n t d e c i s i o n s . T h e s e p r o p e r t i e s a r e a l s o u s e f u l i n b o u n d i n g t h e p a g e f a u l t s t h a t c a n  

o c c u r i n a p h a s e w h e n a p p l i c a t i o n s m a k e m i s t a k e s i n t h e i r p a g e r e p l a c e m e n t d e c i s i o n s .  

D e n i t i o n 3   T h e e v i c t i o n o f a c a c h e d p a g e a t t h e t i m e o f a p a g e f a u l t o n a c l e a n p a g e r e q u e s t i s s a i d t o c r e a t e a   h o l e  

a t t h e e v i c t e d p a g e . I n t u i t i v e l y , a h o l e i s t h e l a c k o f s p a c e f o r s o m e p a g e , s o t h a t t h a t p a g e ' s p l a c e i n c a c h e c o n t a i n s  

a h o l e a n d n o t t h e p a g e . I f p a g e    p 

i s e v i c t e d f o r s e r v i c i n g t h e c l e a n p a g e r e q u e s t , p a g e    p 

i s s a i d t o b e a s s o c i a t e d  

w i t h t h e h o l e . I f p a g e    p 

i s s u b s e q u e n t l y r e q u e s t e d a n d a n o t h e r p a g e    p 

i s e v i c t e d t o s e r v i c e t h e r e q u e s t , t h e h o l e i s  

s a i d t o   m o v e   t o   p 

, a n d n o w    p 

i s s a i d t o b e a s s o c i a t e d w i t h t h e h o l e . A n d s o o n , u n t i l t h e e n d o f t h e p h a s e . W e s a y  

t h a t   h o l e   h  m o v e s t o p r o c e s s   P 

t o m e a n t h a t t h e h o l e   h  m o v e s t o s o m e p a g e    p  b e l o n g i n g t o p r o c e s s   P 

2 . 6 . 1 G e n e r a l o b s e r v a t i o n s a b o u t h o l e s  

A l l r e q u e s t s t o c l e a n p a g e s d u r i n g a p h a s e a r e p a g e f a u l t s a n d c r e a t e h o l e s . T h e n u m b e r o f h o l e s c r e a t e d d u r i n g  

a p a r t i c u l a r p h a s e e q u a l s t h e n u m b e r o f c l e a n p a g e s r e q u e s t e d d u r i n g t h a t p h a s e . A p a r t f r o m c l e a n p a g e r e q u e s t s ,  

r e q u e s t s t o h o l e s a l s o c a u s e p a g e f a u l t s t o o c c u r . B y a   r e q u e s t t o a h o l e   w e m e a n a r e q u e s t f o r t h e p a g e a s s o c i a t e d  

w i t h t h a t h o l e . A s w e p r o c e e d d o w n t h e r e q u e s t s e q u e n c e d u r i n g a p h a s e , t h e p a g e a s s o c i a t e d w i t h a p a r t i c u l a r h o l e  

v a r i e s w i t h t i m e . C o n s i d e r a h o l e   h  t h a t i s c r e a t e d a t a p a g e    p 

t h a t i s e v i c t e d t o s e r v e a r e q u e s t f o r c l e a n p a g e    p 

W h e n a r e q u e s t i s m a d e f o r p a g e    p 

, s o m e p a g e    p 

i s e v i c t e d , a n d   h  m o v e s t o    p 

. S i m i l a r l y w h e n p a g e    p 

i s r e q u e s t e d ,  

h  m o v e s t o s o m e    p 

, a n d s o o n . L e t    p 

,   p 

,  ,   p 

b e t h e t e m p o r a l s e q u e n c e o f p a g e s a l l a s s o c i a t e d w i t h h o l e   h  i n a 

1 8 

Page 32: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 32/203

p a r t i c u l a r p h a s e s u c h t h a t p a g e    p 

i s e v i c t e d w h e n c l e a n p a g e    p 

i s r e q u e s t e d , p a g e    p 

, w h e r e   i >  1 , i s e v i c t e d w h e n  

 p 

i    1 

i s r e q u e s t e d a n d t h e r e q u e s t f o r    p 

f a l l s i n t h e n e x t p h a s e . T h e n t h e n u m b e r o f f a u l t s i n c u r r e d i n t h e p a r t i c u l a r  

p h a s e b e i n g c o n s i d e r e d o n a c c o u n t o f r e q u e s t s t o   h  i s  m    1

2 . 6 . 2 U s e f u l p r o p e r t i e s o f h o l e s  

I n t h i s s e c t i o n w e m a k e t h e f o l l o w i n g o b s e r v a t i o n s a b o u t h o l e s u n d e r t h e a s s u m p t i o n t h a t a p p l i c a t i o n p r o c e s s e s m a k e  

o n l y g o o d d e c i s i o n s .  

L e m m a 3   L e t  u 

b e t h e f a r t h e s t u n m a r k e d p a g e i n c a c h e o f p r o c e s s   P 

a t s o m e p o i n t i n a p h a s e . T h e n p r o c e s s   P 

i s a m a r k e d p r o c e s s b y t h e t i m e t h e r e q u e s t f o r p a g e   u 

i s s e r v e d .  

P r o o f   : T h i s f o l l o w s f r o m t h e d e n i t i o n o f f a r t h e s t u n m a r k e d p a g e a n d t h e n a t u r e o f t h e m a r k i n g s c h e m e e m p l o y e d  

i n o u r a l g o r i t h m .  

L e m m a 4   S u p p o s e t h a t t h e r e i s a r e q u e s t f o r p a g e    p 

, w h i c h i s a s s o c i a t e d w i t h h o l e   h  . S u p p o s e t h a t p r o c e s s   P 

o w n s  

p a g e    p 

. T h e n p r o c e s s   P 

i s a l r e a d y m a r k e d a t t h e t i m e o f t h e p r e s e n t r e q u e s t f o r p a g e    p 

P r o o f  : P a g e    p 

i s a s s o c i a t e d w i t h h o l e   h  b e c a u s e p r o c e s s   P 

e v i c t e d p a g e    p 

w h e n a s k e d t o m a k e a p a g e r e p l a c e m e n t  

d e c i s i o n , i n o r d e r t o s e r v e e i t h e r a c l e a n r e q u e s t o r a p a g e f a u l t a t t h e p r e v i o u s p a g e a s s o c i a t e d w i t h   h  . I n e i t h e r c a s e ,  

p a g e    p 

w a s a g o o d p a g e a t t h e t i m e p r o c e s s   P 

m a d e t h e p a r t i c u l a r p a g i n g d e c i s i o n . S i n c e p r o c e s s   P 

w a s u n m a r k e d  

a t t h e t i m e t h e d e c i s i o n w a s m a d e ,    p 

w a s e i t h e r t h e f a r t h e s t u n m a r k e d p a g e o f p r o c e s s   P 

t h e n o r s o m e m a r k e d p a g e  

o f p r o c e s s   P 

w h o s e n e x t r e q u e s t i s a f t e r t h e r e q u e s t f o r   P 

' s f a r t h e s t u n m a r k e d p a g e . B y L e m m a 3 , p r o c e s s   P 

i s a 

m a r k e d p r o c e s s a t t h e t i m e o f t h e r e q u e s t f o r p a g e    p 

L e m m a 5   S u p p o s e t h a t p a g e    p 

i s a s s o c i a t e d w i t h h o l e   h  . L e t   P 

d e n o t e t h e p r o c e s s o w n i n g p a g e    p 

. S u p p o s e p a g e  

 p 

i s r e q u e s t e d a t s o m e t i m e d u r i n g t h e p h a s e . T h e n h o l e   h  d o e s n o t m o v e t o p r o c e s s   P 

s u b s e q u e n t l y d u r i n g t h e  

c u r r e n t p h a s e .  

P r o o f  : T h e h o l e   h  b e l o n g s t o p r o c e s s   P 

. B y L e m m a 4 w h e n a r e q u e s t i s m a d e t o   h  ,  P 

i s a l r e a d y m a r k e d a n d w i l l  

r e m a i n m a r k e d u n t i l t h e e n d o f t h e p h a s e . S i n c e o n l y u n m a r k e d p r o c e s s e s a r e c h o s e n t o t o e v i c t p a g e s , a r e q u e s t f o r  

h  t h e r e a f t e r c a n n o t r e s u l t i n e v i c t i o n o f a n y p a g e b e l o n g i n g t o   P 

, s o a h o l e c a n n e v e r m o v e t o a p r o c e s s m o r e t h a n  

o n c e .  

L e t t h e r e b e   R  u n m a r k e d p r o c e s s e s a t t h e t i m e o f a r e q u e s t t o a h o l e   h  . F o r a n y u n m a r k e d p r o c e s s   P 

, 1    j    R  , 

l e t  u 

d e n o t e t h e f a r t h e s t u n m a r k e d p a g e o f p r o c e s s   P 

a t t h e t i m e o f t h e r e q u e s t t o h o l e   h  . W i t h o u t l o s s o f g e n e r a l i t y ,  

l e t u s r e l a b e l t h e p r o c e s s e s s o t h a t  

; u 

; u 

; : : : ; u  

( 2 . 2 )  

i s t h e t e m p o r a l o r d e r o f t h e r s t s u b s e q u e n t a p p e a r a n c e o f t h e p a g e s   u 

i n t h e g l o b a l p a g e r e q u e s t s e q u e n c e .  

1 9 

Page 33: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 33/203

L e m m a 6   I n t h e s i t u a t i o n d e s c r i b e d i n ( 2 . 2 ) a b o v e , s u p p o s e d u r i n g t h e p a g e r e q u e s t f o r h o l e   h  t h a t t h e h o l e m o v e s  

t o a g o o d p a g e    p 

o f u n m a r k e d p r o c e s s   P 

t o s e r v e t h e c u r r e n t r e q u e s t f o r   h  . T h e n   h  c a n n e v e r m o v e t o a n y o f t h e  

p r o c e s s e s   P 

,  P 

,  ,  P 

i    1 

d u r i n g t h e c u r r e n t p h a s e .  

P r o o f  : T h e r s t s u b s e q u e n t r e q u e s t f o r t h e g o o d p a g e    p 

t h a t   P 

e v i c t s , b y d e n i t i o n , m u s t b e t h e s a m e a s o r m u s t  

b e a f t e r t h e r s t s u b s e q u e n t r e q u e s t f o r t h e f a r t h e s t u n m a r k e d p a g e   u 

. S o p r o c e s s   P 

w i l l b e m a r k e d b y t h e n e x t  

t i m e h o l e   h  i s r e q u e s t e d , b y L e m m a 4 . O n t h e o t h e r h a n d , t h e r s t s u b s e q u e n t r e q u e s t s o f t h e r e s p e c t i v e f a r t h e s t  

u n m a r k e d p a g e s   u 

,  ,  u 

i    1 

a p p e a r b e f o r e t h a t o f p a g e   u 

. T h u s , b y L e m m a 3 , t h e p r o c e s s e s   P 

,  P 

,  ,  P 

i    1 

a r e 

a l r e a d y m a r k e d b e f o r e t h e n e x t t i m e h o l e   h  ( p a g e    p 

) g e t s r e q u e s t e d a n d w i l l r e m a i n m a r k e d f o r t h e r e m a i n d e r o f t h e  

p h a s e . H e n c e , b y t h e f a c t t h a t o n l y u n m a r k e d p r o c e s s e s g e t c h o s e n , h o l e   h  c a n n e v e r m o v e t o a n y o f t h e p r o c e s s e s  

,  P 

,  ,  P 

i    1 

N e x t w e u s e t h e c o n c e p t o f h o l e s t o p r o v e a l o w e r b o u n d o n t h e c o m p e t i t i v e r a t i o o f a n y d e t e r m i n i s t i c o n l i n e  

m u l t i - a p p l i c a t i o n c a c h i n g a l g o r i t h m , a n d a n u p p e r b o u n d o n t h e c o m p e t i t i v e r a t i o o f t h e a l g o r i t h m b y C F L 9 4 a ] .  

2 . 6 . 3 R e l a t i o n t o t h e a l g o r i t h m o f C a o e t a l .  

T h e a l g o r i t h m p r o p o s e d b y C a o , F e l t e n a n d L i C F L 9 4 a ] f o r t h e m u l t i - a p p l i c a t i o n c a c h i n g p r o b l e m a m o u n t s t o  

e v i c t i n g , a t t h e t i m e o f a p a g e f a u l t , t h e f a r t h e s t p a g e f r o m c a c h e b e l o n g i n g t o t h e p r o c e s s t h a t o w n s t h e L R U p a g e  

i n c a c h e . T h u s , f o r a g i v e n i n t e r l e a v i n g o f i n d i v i d u a l r e q u e s t s e q u e n c e s , t h e p a g i n g d e c i s i o n s m a d e b y t h a t a l g o r i t h m  

a r e d e t e r m i n i s t i c . W e n o w p r o v e t h a t n o d e t e r m i n i s t i c o n l i n e a l g o r i t h m f o r t h e m u l t i - a p p l i c a t i o n c a c h i n g p r o b l e m c a n  

h a v e a c o m p e t i t i v e r a t i o b e t t e r t h a n   P  + 1 , a n d t h a t t h e c o m p e t i t i v e r a t i o a t t a i n e d b y t h e a l g o r i t h m p r o p o s e d b y C a o ,  

F e l t e n a n d L i C F L 9 4 a ] a t t a i n s a c o m p e t i t i v e r a t i o o f 2   P  + 2 . T h e p e r f o r m a n c e o f t h e a l g o r i t h m i n C F L 9 4 a ] i s t h u s  

w i t h i n a f a c t o r o f t w o o f t h e b e s t p o s s i b l e p e r f o r m a n c e b y a n y d e t e r m i n i s t i c o n l i n e a l g o r i t h m f o r t h e m u l t i - a p p l i c a t i o n  

c a c h i n g p r o b l e m .  

T h e a l g o r i t h m p r o p o s e d b y C a o , F e l t e n a n d L i C F L 9 4 a ] f o r t h e m u l t i - a p p l i c a t i o n c a c h i n g p r o b l e m a m o u n t s t o  

e v i c t i n g , a t t h e t i m e o f a p a g e f a u l t , t h e   f a r t h e s t   p a g e f r o m c a c h e b e l o n g i n g t o t h e p r o c e s s t h a t o w n s t h e L R U p a g e  

i n c a c h e .  

T h e o r e m 2   T h e a l g o r i t h m o f C a o , F e l t e n , a n d L i i s   ( 2  P  + 2 )  - c o m p e t i t i v e . A g e n e r a l i z e d v e r s i o n o f t h e a l g o r i t h m  

o f C a o , F e l t e n , a n d L i i n w h i c h , a t t h e t i m e o f a p a g e f a u l t , t h e p r o c e s s o w n i n g t h e L R U p a g e i n c a c h e e v i c t s a n y  

( d e t e r m i n i s t i c a l l y c h o s e n ) g o o d p a g e , i s a l s o   ( 2  P  + 2 )  - c o m p e t i t i v e .  

P r o o f  : L e t t h e r e b e    ̀ c l e a n p a g e r e q u e s t s i n a p h a s e . T h e n t h e r e a r e    ̀ f a u l t s c o r r e s p o n d i n g t o c l e a n p a g e r e q u e s t s  

r e s u l t i n g i n    ̀ h o l e s . T h e a l g o r i t h m e v i c t s o n l y   g o o d   p a g e s f r o m c a c h e , s o h o l e s a r e a s s o c i a t e d o n l y w i t h s u c h p a g e s .  

B y L e m m a 5 w e c a n c o n c l u d e t h a t e a c h h o l e c a n r e s u l t i n a t m o s t o n e p a g e f a u l t p e r p r o c e s s u p t o t h e e n d o f t h e  

2 0 

Page 34: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 34/203

p h a s e , s o t h a t t h e t o t a l n u m b e r o f p a g e f a u l t s i n t h e p h a s e i s b o u n d e d b y    ̀ +  ` P  . U s i n g T h e o r e m 1 g i v e s t h e a b o v e  

c o m p e t i t i v e f a c t o r .  

T h e o r e m 3   T h e c o m p e t i t i v e r a t i o o f a n y d e t e r m i n i s t i c o n l i n e a l g o r i t h m f o r t h e m u l t i - a p p l i c a t i o n c a c h i n g p r o b l e m  

i s a t l e a s t   m i n  f  P  + 1  ; k  g 

P r o o f   : W e r s t c o n s i d e r t h e c a s e i n w h i c h   P  + 1    k  . S i n c e t h e a l g o r i t h m i s d e t e r m i n i s t i c , w e c a n c o n s t r u c t a n  

i n t e r l e a v e t h a t c o s t s t h e a l g o r i t h m a f a c t o r o f   P  + 1 t i m e s t h e n u m b e r o f f a u l t s t h a t   O P T  w i l l i n c u r . F o r i n s t a n c e ,  

c o n s i d e r a s i n g l e c l e a n r e q u e s t i n e a c h p h a s e . O n t h e b a s i s o f o u r k n o w l e d g e o f t h e d e t e r m i n i s t i c c h o i c e s m a d e b y  

t h e a l g o r i t h m , w e c a n e a s i l y m a k e t h e r e s u l t i n g h o l e v i s i t e a c h p r o c e s s a t l e a s t o n c e s o t h a t t h e d e t e r m i n i s t i c o n l i n e  

a l g o r i t h m i n c u r s a t l e a s t   P  + 1 f a u l t s p e r p h a s e w h e r e a s   O P T  i n c u r s j u s t o n e f a u l t .  

O n t h e o t h e r h a n d i n t h e c a s e w h e n   P  + 1  > k  , t h e c l a s s i c a l p a g i n g l o w e r b o u n d o f   k  f r o m S T 8 5 ] b e c o m e s  

a p p l i c a b l e , h e n c e p r o v i n g t h e t h e o r e m .  

G i v e n t h e n o t i o n o f g o o d p a g e s t h a t w e d e v e l o p e d a b o v e , i t t u r n s o u t t h a t w e c a n d e n e a s l i g h t l y m o r e g e n e r a l  

v e r s i o n o f t h e a l g o r i t h m i n C F L 9 4 a ] w i t h o u t c h a n g i n g i t s p a g i n g p e r f o r m a n c e . B a s i c a l l y , i n o r d e r t o a t t a i n t h e  

c o m p e t i t i v e r a t i o o f 2  P  + 2 , i t i s e n o u g h , a t t h e t i m e o f a p a g e f a u l t , t o e v i c t f r o m c a c h e   a n y g o o d p a g e   b e l o n g i n g t o  

t h e p r o c e s s t h a t o w n s t h e L R U p a g e i n c a c h e . W e s a y t h a t t h i s i s a s l i g h t l y m o r e g e n e r a l v e r s i o n t h a n t h e a l g o r i t h m  

p r e s e n t e d i n C F L 9 4 a ] b e c a u s e i t m a y v e r y o f t e n b e t h e c a s e t h a t t h e g o o d s e t o f t h e p r o c e s s t h a t o w n s t h e L R U  

p a g e c o n t a i n s s e v e r a l p a g e s o t h e r t h a n t h e f a r t h e s t p a g e o f t h a t p r o c e s s .  

2 . 7 C o m p e t i t i v e A n a l y s i s o f o u r O n l i n e A l g o r i t h m          

O u r m a i n r e s u l t i s T h e o r e m 4 , w h i c h s t a t e s t h a t o u r o n l i n e a l g o r i t h m f o r t h e m u l t i - a p p l i c a t i o n c a c h i n g p r o b l e m i s  

r o u g h l y 2 l n   P  - c o m p e t i t i v e , a s s u m i n g a p p l i c a t i o n p r o c e s s e s a l w a y s m a k e g o o d d e c i s i o n s ( e . g . , i f e a c h p r o c e s s k n o w s  

i t s o w n f u t u r e p a g e r e q u e s t s ) . B y t h e l o w e r b o u n d o f T h e o r e m 1 , i t f o l l o w s t h a t o u r a l g o r i t h m i s o p t i m a l i n t e r m s o f  

c o m p e t i t i v e r a t i o u p t o a f a c t o r o f 2 .  

T h e o r e m 4   T h e c o m p e t i t i v e r a t i o o f o u r o n l i n e a l g o r i t h m i n S e c t i o n 2 . 4 f o r t h e m u l t i - a p p l i c a t i o n c a c h i n g p r o b l e m ,  

a s s u m i n g t h a t g o o d e v i c t i o n s a r e a l w a y s m a d e , i s a t m o s t   2  H 

P    1 

+ 2  . O u r c o m p e t i t i v e r a t i o i s w i t h i n a f a c t o r o f  

a b o u t   2  o f t h e b e s t p o s s i b l e c o m p e t i t i v e r a t i o f o r t h i s p r o b l e m .  

T h e r e s t o f t h i s s e c t i o n i s d e v o t e d t o p r o v i n g T h e o r e m 4 . T o c o u n t t h e n u m b e r o f f a u l t s g e n e r a t e d b y o u r a l g o r i t h m  

i n a p h a s e , w e m a k e u s e o f t h e p r o p e r t i e s o f h o l e s f r o m t h e p r e v i o u s s e c t i o n . I f    ̀ r e q u e s t s a r e m a d e t o c l e a n p a g e s  

2 1 

Page 35: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 35/203

d u r i n g a p h a s e , t h e r e a r e    ̀ h o l e s t h a t m o v e a b o u t d u r i n g t h e p h a s e . W e c a n c o u n t t h e n u m b e r o f f a u l t s g e n e r a t e d b y  

o u r a l g o r i t h m d u r i n g t h e p h a s e a s  

 ̀ + 

 ̀

X   

i  = 1 

;  ( 2 . 3 )  

w h e r e   N 

i s t h e n u m b e r o f t i m e s h o l e   h 

i s r e q u e s t e d d u r i n g t h e p h a s e . A s s u m i n g g o o d d e c i s i o n s a r e a l w a y s m a d e ,  

w e w i l l n o w p r o v e f o r e a c h p h a s e a n d f o r a n y h o l e   h 

t h a t t h e e x p e c t e d v a l u e o f   N 

i s b o u n d e d b y   H 

P    1 

C o n s i d e r t h e r s t r e q u e s t t o a h o l e   h  d u r i n g t h e p h a s e . L e t   R 

b e t h e n u m b e r o f u n m a r k e d p r o c e s s e s a t t h a t  

p o i n t o f t i m e . L e t   C 

b e t h e r a n d o m v a r i a b l e a s s o c i a t e d w i t h t h e n u m b e r o f p a g e f a u l t s b e c a u s e o f r e q u e s t s t o h o l e  

h  d u r i n g t h e p h a s e .  

L e m m a 7   T h e e x p e c t e d n u m b e r   E  (  C 

)  o f p a g e f a u l t s c a u s e d b y r e q u e s t s t o h o l e   h  i s a t m o s t   H 

P r o o f   : W e p r o v e t h i s b y i n d u c t i o n o v e r   R 

. W e h a v e   E  (  C 

) = 0 a n d   E  (  C 

) = 1 . S u p p o s e f o r 0     j    R 

  1 t h a t  

E  (  C 

)    H 

. U s i n g t h e s a m e t e r m i n o l o g y a n d n o t a t i o n a s i n L e m m a 6 , l e t t h e f a r t h e s t u n m a r k e d p a g e s o f t h e   R 

u n m a r k e d p r o c e s s e s a t t h e t i m e o f t h e r e q u e s t f o r   h  a p p e a r i n t h e t e m p o r a l o r d e r  

; u 

; u 

; : : : ; u  

i n t h e g l o b a l r e q u e s t s e q u e n c e . W e r e n u m b e r t h e   R 

u n m a r k e d p r o c e s s e s f o r c o n v e n i e n c e s o t h a t p a g e   u 

i s t h e  

f a r t h e s t u n m a r k e d p a g e o f u n m a r k e d p r o c e s s   P 

W h e n t h e h o l e   h  i s r e q u e s t e d , o u r a l g o r i t h m r a n d o m l y c h o o s e s o n e o f t h e   R 

u n m a r k e d p r o c e s s e s , s a y , p r o c e s s  

, a n d a s k s p r o c e s s   P 

t o e v i c t a s u i t a b l e p a g e . U n d e r o u r a s s u m p t i o n , t h e h o l e   h  m o v e s t o s o m e g o o d p a g e    p 

o f 

p r o c e s s   P 

. F r o m L e m m a s 5 a n d 6 , i f o u r a l g o r i t h m c h o o s e s u n m a r k e d p r o c e s s   P 

s o t h a t i t s g o o d p a g e    p 

i s e v i c t e d ,  

t h e n   a t m o s t   R 

  i  p r o c e s s e s r e m a i n u n m a r k e d   t h e n e x t t i m e   h  i s r e q u e s t e d . S i n c e e a c h o f t h e   R 

u n m a r k e d  

p r o c e s s e s i s c h o s e n w i t h a p r o b a b i l i t y o f 1  = R 

, w e h a v e  

E  (  C 

)    1 + 

X   

i  = 1 

E  (  C 

  i 

= 1 + 

  1 

X   

i  = 0 

E  (  C 

  1 + 

  1 

X   

i  = 0 

=  H 

T h e l a s t e q u a l i t y f o l l o w s e a s i l y b y i n d u c t i o n a n d a l g e b r a i c m a n i p u l a t i o n s .  

2 2 

Page 36: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 36/203

W e n o w c o m p l e t e t h e p r o o f o f T h e o r e m 4 . B y L e m m a 4 t h e m a x i m u m p o s s i b l e n u m b e r o f u n m a r k e d p r o c e s s e s  

a t t h e t i m e a h o l e   h  i s r s t r e q u e s t e d i s   P    1 . L e m m a 7 i m p l i e s t h a t t h e a v e r a g e n u m b e r o f t i m e s a n y h o l e c a n  

b e r e q u e s t e d d u r i n g a p h a s e i s b o u n d e d b y   H 

P    1 

. B y ( 2 . 3 ) , t h e t o t a l n u m b e r o f p a g e f a u l t s d u r i n g t h e p h a s e i s  

a t m o s t    ̀ ( 1 +  H 

P    1 

) . W e h a v e a l r e a d y s h o w n i n L e m m a 1 t h a t t h e   O P T  a l g o r i t h m i n c u r s a n a m o r t i z e d c o s t o f  

a t l e a s t   ` =  2 f o r t h e r e q u e s t s m a d e i n t h e p h a s e . T h e r e f o r e , t h e c o m p e t i t i v e r a t i o o f o u r a l g o r i t h m i s b o u n d e d b y  

 ̀ ( 1 +  H 

P    1 

)  =  (  ` =  2 ) = 2  H 

P    1 

+ 2 . A p p l y i n g t h e l o w e r b o u n d o f T h e o r e m 1 c o m p l e t e s t h e p r o o f .  

2 . 8 A p p l i c a t i o n - C o n t r o l l e d C a c h i n g w i t h F a i r n e s s    

I n t h i s s e c t i o n w e a n a l y z e o u r a l g o r i t h m ' s p e r f o r m a n c e i n t h e r e a l i s t i c s c e n a r i o w h e r e a p p l i c a t i o n p r o c e s s e s c a n m a k e  

m i s t a k e s , a s d e n e d i n D e n i t i o n 2 . W e b o u n d t h e n u m b e r o f p a g e f a u l t s i t i n c u r s i n a p h a s e i n t e r m s o f p a g e f a u l t s  

c a u s e d b y m i s t a k e s m a d e b y a p p l i c a t i o n p r o c e s s e s d u r i n g t h a t p h a s e . T h e m a i n i d e a h e r e i s t h a t i f a n a p p l i c a t i o n  

p r o c e s s   P 

c o m m i t s a m i s t a k e b y e v i c t i n g a c e r t a i n p a g e    p  a n d t h e n d u r i n g t h e s a m e p h a s e r e q u e s t s p a g e    p  w h i l e  

p r o c e s s   P 

i s s t i l l u n m a r k e d , o u r a l g o r i t h m m a k e s p r o c e s s   P 

p a y f o r t h e m i s t a k e i n S t e p 2 ( a ) i .  

O n t h e o t h e r h a n d , i f p a g e    p  ' s e v i c t i o n f r o m p r o c e s s   P 

w a s a m i s t a k e , b u t p r o c e s s   P 

i s m a r k e d w h e n p a g e    p  i s 

l a t e r r e q u e s t e d i n t h e s a m e p h a s e , s a y , a t t i m e   t  , t h e n p r o c e s s   P 

' s m i s t a k e i s \ n o t w o r t h d e t e c t i n g " f o r t h e f o l l o w i n g  

r e a s o n : S i n c e e v i c t i n g p a g e    p  w a s a m i s t a k e , i t m u s t m e a n t h a t a t t h e t i m e   t 

o f   p  ' s e v i c t i o n , t h e r e e x i s t e d a s e t   U 

o f o n e o r m o r e u n m a r k e d p a g e s o f p r o c e s s   P 

i n c a c h e w h o s e s u b s e q u e n t r e q u e s t s a p p e a r   a f t e r   t h e n e x t r e q u e s t f o r  

p a g e    p  . P r o c e s s   P 

i s m a r k e d a t t h e t i m e o f t h e n e x t r e q u e s t f o r    p  , i m p l y i n g t h a t a l l p a g e s i n   U  w e r e   e v i c t e d   b y 

a t s o m e t i m e s   t 

,  t 

,  : : : t  

j  U  j  + 1 

a f t e r t h e m i s t a k e o f e v i c t i n g    p  . I f i n s t e a d a t t i m e   t 

,  t 

,  : : : t  

j  U  j  + 1 

p r o c e s s   P 

m a k e s t h e s p e c i c g o o d p a g i n g d e c i s i o n s o f e v i c t i n g t h e f a r t h e s t u n m a r k e d p a g e s ,   t h e s a m e s e t   f   p  g   U  o f p a g e s w i l l  

b e o u t c a c h e a t t i m e   t  I n o u r n o t i o n o f f a i r n e s s w e c h o o s e t o i g n o r e a l l s u c h m i s t a k e s a n d c o n s i d e r t h e m \ n o t w o r t h  

d e t e c t i n g . "  

D e n i t i o n 4   D u r i n g a n o n g o i n g p h a s e , a n y p a g e f a u l t c o r r e s p o n d i n g t o a r e q u e s t f o r a p a g e    p  o f a n   u n m a r k e d  

p r o c e s s   P 

i s c a l l e d a n   u n f a i r f a u l t   i f t h e r e q u e s t f o r p a g e    p  i s n o t a c l e a n p a g e r e q u e s t . A l l f a u l t s d u r i n g t h e p h a s e  

t h a t a r e n o t u n f a i r a r e c a l l e d   f a i r f a u l t s  

T h e u n f a i r f a u l t s a r e p r e c i s e l y t h o s e p a g e f a u l t s w h i c h a r e c a u s e d b y m i s t a k e s c o n s i d e r e d \ w o r t h d e t e c t i n g . " W e  

s t a t e t h e f o l l o w i n g t w o l e m m a s t h a t f o l l o w t r i v i a l l y f r o m t h e d e n i t i o n s o f m i s t a k e s , g o o d d e c i s i o n s , u n f a i r f a u l t s ,  

a n d f a i r f a u l t s .  

L e m m a 8   D u r i n g a p h a s e , a l l p a g e r e q u e s t s t h a t g e t p r o c e s s e d i n S t e p 2 ( a ) i o f o u r a l g o r i t h m a r e p r e c i s e l y t h e u n f a i r  

f a u l t s o f t h a t p h a s e . T h a t i s , u n f a i r f a u l t s c o r r e s p o n d t o m i s t a k e s t h a t g e t c a u g h t i n S t e p 2 ( a ) i o f o u r a l g o r i t h m .  

L e m m a 9   A l l f a i r f a u l t s a r e p r e c i s e l y t h o s e r e q u e s t s t h a t g e t p r o c e s s e d i n S t e p 2 ( b ) i i i .  

2 3 

Page 37: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 37/203

W e n o w c o n s i d e r t h e b e h a v i o r o f h o l e s i n t h e c u r r e n t m i s t a k e - p r o n e s c e n a r i o .  

L e m m a 1 0   T h e n u m b e r o f h o l e s i n a p h a s e e q u a l s t h e n u m b e r o f c l e a n p a g e s r e q u e s t e d i n t h e p h a s e .  

L e m m a 1 1   C o n s i d e r a h o l e   h  a s s o c i a t e d w i t h a p a g e    p  o f a p r o c e s s   P 

. I f a r e q u e s t f o r   h  i s a n u n f a i r f a u l t , p r o c e s s  

i s s t i l l u n m a r k e d a n d t h e h o l e   h  m o v e s t o s o m e o t h e r p a g e b e l o n g i n g t o p r o c e s s   P 

. I f a r e q u e s t f o r h o l e   h  i s a f a i r  

f a u l t , t h e n p r o c e s s   P 

i s a l r e a d y m a r k e d a n d t h e h o l e   h  c a n n e v e r m o v e t o p r o c e s s   P 

s u b s e q u e n t l y d u r i n g t h e p h a s e .  

P r o o f  : I f t h e r e q u e s t f o r h o l e   h  i s a n u n f a i r f a u l t , t h e n b y d e n i t i o n p r o c e s s   P 

i s u n m a r k e d a n d b y L e m m a 8 ,   h 

m o v e s t o s o m e o t h e r p a g e    p 

o f p r o c e s s   P 

. I f t h e r e q u e s t f o r   h  i s a f a i r f a u l t , t h e n b y d e n i t i o n a n d t h e f a c t t h a t t h e  

r e q u e s t f o r   h  i s n o t a c l e a n p a g e r e q u e s t , p r o c e s s   P 

i s m a r k e d . S i n c e o u r a l g o r i t h m n e v e r c h o o s e s a m a r k e d p r o c e s s  

f o r e v i c t i o n , i t f o l l o w s t h a t   h  c a n n e v e r v i s i t p r o c e s s   P 

s u b s e q u e n t l y d u r i n g t h e p h a s e .  

D u r i n g a p h a s e , a h o l e   h  i s c r e a t e d i n s o m e p r o c e s s , s a y   P 

, b y s o m e c l e a n p a g e r e q u e s t . I t t h e n m o v e s a r o u n d  

z e r o o r m o r e t i m e s w i t h i n p r o c e s s   P 

o n a c c o u n t o f   P 

' s m i s t a k e s , u n t i l a r e q u e s t f o r h o l e   h  i s a f a i r f a u l t , u p o n w h i c h  

i t m o v e s t o s o m e o t h e r p r o c e s s   P 

, n e v e r t o c o m e b a c k t o p r o c e s s   P 

d u r i n g t h e p h a s e . I t b e h a v e s s i m i l a r l y i n p r o c e s s  

, a n d s o o n u p t o t h e e n d o f t h e p h a s e . L e t   T 

d e n o t e t h e t o t a l n u m b e r o f f a u l t s a t t r i b u t e d t o r e q u e s t s t o h o l e   h 

d u r i n g a p h a s e , o f w h i c h   F 

f a u l t s a r e f a i r f a u l t s a n d   U 

f a u l t s a r e u n f a i r f a u l t s . W e h a v e   T 

=  F 

+  U 

B y L e m m a 1 1 a n d t h e s a m e p r o o f t e c h n i q u e s a s t h o s e i n t h e p r o o f s o f L e m m a 7 a n d T h e o r e m 4 , w e c a n p r o v e  

t h e f o l l o w i n g k e y l e m m a :  

L e m m a 1 2   T h e e x p e c t e d n u m b e r   E  (  F 

)  o f p a g e r e q u e s t s t o h o l e   h  d u r i n g a p h a s e t h a t r e s u l t i n f a i r f a u l t s i s a t  

m o s t   H 

P    1 

B y L e m m a 1 0 , o u r a l g o r i t h m i n c u r s a t m o s t    ̀ + 

P  

 ̀

i  = 1 

p a g e f a u l t s i n a p h a s e w i t h    ̀ c l e a n p a g e r e q u e s t s . T h e  

e x p e c t e d v a l u e o f t h i s q u a n t i t y i s a t m o s t    ̀ (  H 

P    1 

+ 1 ) +  

P  

 ̀

i  = 1 

, b y L e m m a 1 2 .  

T h e e x p r e s s i o n  

P  

 ̀

i  = 1 

i s t h e n u m b e r o f   u n f a i r f a u l t s  , t h a t i s , t h e n u m b e r o f m i s t a k e s c o n s i d e r e d \ w o r t h  

d e t e c t i n g . " O u r a l g o r i t h m i s v e r y e c i e n t i n t h a t t h e n u m b e r o f u n f a i r f a u l t s i s a n a d d i t i v e t e r m . F o r a n y p h a s e    

w i t h    ̀ c l e a n r e q u e s t s , w e d e n o t e  

P  

 ̀

i  = 1 

a s  M 

 

T h e o r e m 5   T h e n u m b e r o f f a u l t s i n a p h a s e     w i t h    ̀ c l e a n p a g e r e q u e s t s a n d   M 

 

u n f a i r f a u l t s i s b o u n d e d b y  

 ̀ ( 1 +  H 

P    1 

) +  M 

 

. A t t h e t i m e o f e a c h o f t h e   M 

 

u n f a i r f a u l t s , t h e a p p l i c a t i o n p r o c e s s t h a t m a k e s t h e m i s t a k e t h a t  

c a u s e s t h e f a u l t m u s t e v i c t a p a g e f r o m i t s o w n c a c h e . N o a p p l i c a t i o n p r o c e s s i s e v e r a s k e d t o e v i c t a p a g e t o s e r v i c e  

a n u n f a i r f a u l t c a u s e d b y s o m e o t h e r a p p l i c a t i o n p r o c e s s .  

2 4 

Page 38: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 38/203

2 . 8 . 1 E x t e n d i n g F a i r n e s s t o t h e a l g o r i t h m b y C a o e t a l .  

I t t u r n s o u t t h a t o u r n o t i o n o f f a i r n e s s e x t e n d s , w i t h o u t a n y c h a n g e , t o t h e g e n e r a l i z e d v e r s i o n o f t h e d e t e r m i n i s t i c  

a l g o r i t h m o f C F L 9 4 a ] t h a t w e m e n t i o n e d i n S e c t i o n 2 . 6 . 3 . I t i s e a s y t o s e e t h a t i n t h e c a s e o f t h e g e n e r a l i z e d v e r s i o n  

o f t h e a l g o r i t h m o f C F L 9 4 a ] , a p r o c e s s i n c u r s a n u n f a i r f a u l t o n l y i f , a t s o m e t i m e i n t h e p a s t , t h a t p r o c e s s h a d t h e  

L R U p a g e a n d t h e p a g e i t e v i c t e d w a s n o t a g o o d p a g e . C o n s e q u e n t l y , a r e s u l t s i m i l a r t o T h e o r e m 5 w i t h ( 1 +   H 

P    1 

r e p l a c e d b y ( 1 +   P  ) h o l d s f o r t h e g e n e r a l i z e d v e r s i o n o f t h e a l g o r i t h m o f C F L 9 4 a ] .  

2 . 9 C o n c l u s i o n s a n d F u t u r e W o r k      

C a c h e m a n a g e m e n t s t r a t e g i e s a r e o f p r i m e i m p o r t a n c e f o r h i g h p e r f o r m a n c e c o m p u t i n g . W e c o n s i d e r t h e c a s e w h e r e  

t h e r e a r e   P  i n d e p e n d e n t p r o c e s s e s r u n n i n g o n t h e s a m e c o m p u t e r s y s t e m a n d s h a r i n g a c o m m o n c a c h e o f s i z e   k 

A p p l i c a t i o n s o f t e n h a v e a d v a n c e k n o w l e d g e o f t h e i r p a g e r e q u e s t s e q u e n c e s . I n t h i s p a p e r w e h a v e a d d r e s s t h e i s s u e  

o f e x p l o i t i n g t h i s a d v a n c e k n o w l e d g e t o d e v i s e i n t e l l i g e n t s t r a t e g i e s t o m a n a g e t h e s h a r e d c a c h e , i n a t h e o r e t i c a l  

s e t t i n g . W e h a v e p r e s e n t e d a s i m p l e a n d e l e g a n t r a n d o m i z e d a p p l i c a t i o n - c o n t r o l l e d c a c h i n g a l g o r i t h m f o r t h e m u l t i -  

a p p l i c a t i o n c a c h i n g p r o b l e m t h a t a c h i e v e s a c o m p e t i t i v e r a t i o o f 2  H 

P    1 

+ 2 . O u r r e s u l t i s a s i g n i c a n t i m p r o v e m e n t  

o v e r t h e c o m p e t i t i v e r a t i o s o f 2  P  + 2 C F L 9 4 a ] f o r d e t e r m i n i s t i c m u l t i - a p p l i c a t i o n c a c h i n g a n d (  H 

) f o r c l a s s i c a l  

c a c h i n g , s i n c e t h e c a c h e s i z e   k  i s o f t e n o r d e r s o f m a g n i t u d e g r e a t e r t h a n   P  . W e h a v e p r o v e n t h a t n o o n l i n e a l g o r i t h m  

f o r t h i s p r o b l e m c a n h a v e a c o m p e t i t i v e r a t i o s m a l l e r t h a n m i n   f  H 

P    1 

; H 

g  , e v e n i f a p p l i c a t i o n p r o c e s s e s h a v e p e r f e c t  

k n o w l e d g e o f i n d i v i d u a l r e q u e s t s e q u e n c e s . W e c o n j e c t u r e t h a t a n u p p e r b o u n d o f   H 

P    1 

c a n b e p r o v e n , u p t o s e c o n d  

o r d e r t e r m s , p e r h a p s u s i n g t e c h n i q u e s f r o m M S 9 1 ] , a l t h o u g h t h e r e s u l t i n g a l g o r i t h m i s n o t l i k e l y t o b e p r a c t i c a l .  

U s i n g o u r n o t i o n o f m i s t a k e s w e a r e a b l e t o c o n s i d e r a m o r e r e a l i s t i c s e t t i n g w h e n a p p l i c a t i o n p r o c e s s e s m a k e b a d  

p a g i n g d e c i s i o n s a n d s h o w t h a t o u r a l g o r i t h m i s a f a i r a n d e c i e n t a l g o r i t h m i n s u c h a s i t u a t i o n . N o a p p l i c a t i o n  

n e e d s t o p a y f o r s o m e o t h e r a p p l i c a t i o n p r o c e s s ' s m i s t a k e , a n d w e c a n b o u n d t h e g l o b a l c a c h i n g p e r f o r m a n c e o f o u r  

a l g o r i t h m i n t e r m s o f t h e n u m b e r o f m i s t a k e s . O u r n o t i o n s o f g o o d p a g e r e p l a c e m e n t d e c i s i o n s , m i s t a k e s , a n d f a i r n e s s  

i n t h i s c o n t e x t a r e n e w .  

O n e r e l a t e d a r e a o f p o s s i b l e f u t u r e w o r k i s t o c o n s i d e r a l t e r n a t i v e m o d e l s t o o u r m o d e l o f w o r s t - c a s e i n t e r l e a v i n g :  

A m o s t c h a l l e n g i n g p r o b l e m i s t o c o n s i d e r a p p l i c a t i o n - c o n t r o l l e d p a g i n g w i t h r e a l i s t i c c o n s t r a i n t s b a s e d o n   c o n t e x t  

s w i t c h i n g   a n d  C P U s c h e d u l i n g .   I n r e a l i s t i c s y s t e m s , w h e n a p r o c e s s i n c u r s a p a g e f a u l t , i t g e t s c o n t e x t s w i t c h e d  

a n d s o m e o t h e r p r o c e s s g e t s s c h e d u l e d a c c o r d i n g t o t h e C P U s c h e d u l i n g a l g o r i t h m . W e n o t e t h a t t h a t t h e r e q u e s t  

s e q u e n c e t h a t l e a d s t o a l o w e r b o u n d o n t h e p e r f o r m a n c e o f o n l i n e p a g i n g n e e d s t h e a d v e r s a r y t o b e u n c o n s t r a i n e d .  

T h e d i c u l t y t h a t a r i s e s f r o m t h e c o n t e x t s w i t c h i n g a n d C P U s c h e d u l i n g c o n s t r a i n t s i s t h a t t h e r e q u e s t s e q u e n c e  

c a n n o t b e c o n s i d e r e d t o b e x e d a p r i o r i . T h i s i s b e c a u s e c o n t e x t s w i t c h e v e n t s d e p e n d o n p r e v i o u s p a g i n g d e c i s i o n s  

a n d a l s o d e t e r m i n e t h e i n t e r l e a v i n g o f t h e r e q u e s t s e q u e n c e s , w h i c h i n t u r n d e t e r m i n e s g o o d p a g i n g d e c i s i o n s . W e  

t h e r e f o r e r e f e r t o t h e o n l i n e p a g i n g p r o b l e m u n d e r c o n t e x t s w i t c h i n g a n d C P U s c h e d u l i n g p r o b l e m a s a   d y n a m i c  

2 5 

Page 39: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 39/203

p a g i n g p r o b l e m   . A t t h i s p o i n t o f t i m e , w e d o n o t k n o w t o w h a t e x t e n t o r u n d e r w h a t r e s t r i c t i o n s t h e a b o v e p r o b l e m  

c a n b e t h e o r e t i c a l l y s o l v e d .  

A n o t h e r i n t e r e s t i n g a r e a w o u l d b e c o n s i d e r c a c h i n g i n a s i t u a t i o n w h e r e s o m e a p p l i c a t i o n s h a v e g o o d k n o w l e d g e  

o f f u t u r e p a g e r e q u e s t s w h i l e o t h e r a p p l i c a t i o n s h a v e n o k n o w l e d g e o f f u t u r e r e q u e s t s . W e c o u l d a l s o c o n s i d e r p a g e s  

s h a r e d a m o n g a p p l i c a t i o n p r o c e s s e s .  

2 6 

Page 40: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 40/203

C h a p t e r 3      

S i m p l e R a n d o m i z e d M e r g e s o r t f o r    

P a r a l l e l D i s k s    

S u m m a r y      

W e c o n s i d e r t h e p r o b l e m o f s o r t i n g a l e o f   N  r e c o r d s o n t h e   D  - d i s k m o d e l o f p a r a l l e l I / O i n w h i c h t h e r e a r e t w o  

s o u r c e s o f p a r a l l e l i s m : b l o c k t r a n s f e r a n d m u l t i p l e d i s k s . R e c o r d s a r e t r a n s f e r r e d t o a n d f r o m d i s k c o n c u r r e n t l y  

i n b l o c k s o f   B  c o n t i g u o u s r e c o r d s . I n e a c h I / O o p e r a t i o n , u p t o o n e b l o c k c a n b e t r a n s f e r r e d t o o r f r o m e a c h o f  

t h e  D  d i s k s i n p a r a l l e l . W e p r o p o s e a s i m p l e , e c i e n t , r a n d o m i z e d m e r g e s o r t a l g o r i t h m c a l l e d S R M t h a t u s e s a  

f o r e c a s t - a n d - u s h a p p r o a c h t o o v e r c o m e t h e i n h e r e n t d i c u l t i e s o f s i m p l e m e r g i n g o n p a r a l l e l d i s k s . S R M e x h i b i t s a  

l i m i t e d u s e o f r a n d o m i z a t i o n a n d a l s o h a s a u s e f u l d e t e r m i n i s t i c v e r s i o n . G e n e r a l i z i n g t h e t e c h n i q u e o f f o r e c a s t i n g ,  

o u r a l g o r i t h m i s a b l e t o r e a d i n , a t a n y t i m e , t h e \ r i g h t " b l o c k f r o m a n y d i s k , a n d u s i n g t h e t e c h n i q u e o f u s h i n g , o u r  

a l g o r i t h m e v i c t s , w i t h o u t a n y I / O o v e r h e a d , j u s t t h e \ r i g h t " b l o c k s f r o m m e m o r y t o m a k e s p a c e f o r n e w o n e s t o b e  

r e a d i n . T h e d i s k l a y o u t o f S R M i s s u c h t h a t i t e n j o y s p e r f e c t w r i t e p a r a l l e l i s m , a v o i d i n g f u n d a m e n t a l i n e c i e n c i e s  

o f p r e v i o u s m e r g e s o r t a l g o r i t h m s . B y a n a l y s i s o f g e n e r a l i z e d m a x i m u m o c c u p a n c y p r o b l e m s w e a r e a b l e t o d e r i v e a n  

a n a l y t i c a l u p p e r b o u n d o n S R M ' s e x p e c t e d o v e r h e a d v a l i d f o r a r b i t r a r y i n p u t s .  

T h e u p p e r b o u n d d e r i v e d o n e x p e c t e d I / O p e r f o r m a n c e o f S R M i n d i c a t e s t h a t S R M i s p r o v a b l y b e t t e r t h a n  

d i s k - s t r i p e d m e r g e s o r t ( D S M ) f o r r e a l i s t i c p a r a m e t e r v a l u e s   D  ,  M  , a n d   B  . A v e r a g e - c a s e s i m u l a t i o n s s h o w f u r t h e r i m -  

p r o v e m e n t o n t h e a n a l y t i c a l u p p e r b o u n d . U n l i k e p r e v i o u s l y p r o p o s e d o p t i m a l s o r t i n g a l g o r i t h m s , S R M o u t p e r f o r m s  

D S M e v e n w h e n t h e n u m b e r   D  o f p a r a l l e l d i s k s i s s m a l l .  

3 . 1 I n t r o d u c t i o n      

T h e c l a s s i c a l p r o b l e m o f s o r t i n g a n d r e l a t e d p r o c e s s i n g i s r e p o r t e d t o c o n s u m e r o u g h l y 2 0 p e r c e n t o f c o m p u t i n g  

r e s o u r c e s i n l a r g e - s c a l e i n s t a l l a t i o n s K n u 9 8 , L V 8 5 ] . I n t h e l i g h t o f t h e r a p i d l y i n c r e a s i n g g a p b e t w e e n p r o c e s s o r  

s p e e d s a n d d i s k m e m o r y a c c e s s t i m e s , p o p u l a r l y r e f e r r e d t o a s t h e   I / O b o t t l e n e c k   , t h e s p e c i c p r o b l e m o f   e x t e r n a l  

m e m o r y s o r t i n g   a s s u m e s p a r t i c u l a r i m p o r t a n c e . I n e x t e r n a l s o r t i n g , t h e r e c o r d s t o b e s o r t e d a r e s i m p l y t o o m a n y  

t o t i n i n t e r n a l m e m o r y a n d s o h a v e t o b e s t o r e d o n d i s k , t h u s n e c e s s i t a t i n g I / O a s a f u n d a m e n t a l , f r e q u e n t l y u s e d  

o p e r a t i o n d u r i n g s o r t i n g .  

O n e w a y t o a l l e v i a t e t h e e e c t s o f t h e I / O b o t t l e n e c k i s t o u s e p a r a l l e l d i s k s y s t e m s H G K  

9 4 , P G K 8 8 , U n i 8 9 ,  

G S 8 4 , M a g 8 7 ] . A g g a r w a l a n d V i t t e r A V 8 8 ] , g e n e r a l i z i n g i n i t i a l w o r k d o n e b y F l o y d F l o 7 2 ] a n d H o n g a n d K u n g  

2 7 

Page 41: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 41/203

M    2  D B  . 

I n t e r n a l m e m o r y  

D  d i s k s  

B l o c k I / O  

F i g u r e 3 . 1  : T h e P a r a l l e l D i s k M o d e l V S 9 4 ] :   D  ,  B  ,  M  a n d  N  r e s p e c t i v e l y d e n o t e t h e n u m b e r o f i n d e p e n d e n t d i s k  

d r i v e s , t h e s i z e o f e a c h d i s k b l o c k , t h e s i z e o f i n t e r n a l m e m o r y , a n d t h e s i z e o f t h e i n p u t .  

H K 8 1 b ] , l a i d t h e f o u n d a t i o n f o r I / O a l g o r i t h m s b y s t u d y i n g t h e I / O c o m p l e x i t y o f s o r t i n g a n d r e l a t e d p r o b l e m s .  

T h e m o d e l t h e y s t u d i e d A V 8 8 ] c o n s i d e r s a n i n t e r n a l m e m o r y o f s i z e   M  a n d I / O r e a d s o r w r i t e s t h a t e a c h r e s u l t i n a  

t r a n s f e r o f   D  b l o c k s , w h e r e e a c h b l o c k i s c o m p r i s e d o f   B  c o n t i g u o u s r e c o r d s , f r o m o r t o d i s k s . S u b s e q u e n t l y , V i t t e r  

a n d S h r i v e r V S 9 4 ] c o n s i d e r e d t h e r e a l i s t i c , t w o - l e v e l   P a r a l l e l D i s k M o d e l ( P D M )   i l l u s t r a t e d i n F i g u r e 3 . 1 , i n w h i c h  

s e c o n d a r y m e m o r y i s p a r t i t i o n e d i n t o   D  p h y s i c a l l y d i s t i n c t a n d i n d e p e n d e n t d i s k d r i v e s o r r e a d - w r i t e h e a d s t h a t c a n  

s i m u l t a n e o u s l y t r a n s m i t a b l o c k o f d a t a , w i t h t h e r e q u i r e m e n t t h a t   M    2  D B 

I n t h e   D  - d i s k t w o - l e v e l m e m o r y h i e r a r c h y V S 9 4 ] , t h e r e a r e t w o s o u r c e s o f p a r a l l e l i s m . F i r s t , a s i n t r a d i t i o n a l I / O  

s y s t e m s , r e c o r d s a r e t r a n s f e r r e d c o n c u r r e n t l y i n b l o c k s o f   B  c o n t i g u o u s r e c o r d s . S e c o n d l y , i n a s i n g l e I / O o p e r a t i o n ,  

e a c h o f t h e   D  d i s k s c a n s i m u l t a n e o u s l y t r a n s f e r o n e ( b u t o n l y o n e ) b l o c k o f   B  r e c o r d s , s o t h a t e a c h I / O o p e r a t i o n  

c a n p o t e n t i a l l y t r a n s f e r   D B  r e c o r d s i n p a r a l l e l .  

T o b e m o r e p r e c i s e ,   D  i s t h e n u m b e r o f b l o c k s t h a t c a n b e t r a n s m i t t e d i n p a r a l l e l a t t h e s p e e d a t w h i c h d a t a c o m e s  

o o r g o e s o n t o t h e m a g n e t i c d i s k m e d i a . T h e p a r a m e t e r   D  m a y t h u s b e s m a l l e r t h a n t h e a c t u a l n u m b e r o f d i s k s i f  

t h e c h a n n e l b a n d w i d t h f r o m t h e d i s k s i s n o t s u c i e n t f o r e a c h d i s k t o t r a n s m i t o r r e c e i v e a b l o c k s i m u l t a n e o u s l y . I t  

t h e n m i g h t b e u s e f u l t o c o n s i d e r t w o d i s k p a r a m e t e r s   D  a n d  D 

, w h e r e   D  i s t h e c h a n n e l b a n d w i d t h i n t e r m s o f t h e  

n u m b e r o f b l o c k s c o m i n g o o r g o i n g o n t o d i s k t h a t c a n b e t r a n s f e r r e d s i m u l t a n e o u s l y , a n d   D 

i s t h e n u m b e r o f d i s k s  

s h a r i n g t h e b a n d w i d t h . A s l o n g a s a t l e a s t   D  o f t h e   D 

d i s k s h a v e a b l o c k t o t r a n s m i t , t h e I / O c h a n n e l c a n r e m a i n  

b u s y . H y b r i d m o d e l s w i t h m u l t i p l e c h a n n e l s a n d s e v e r a l d i s k s p e r c h a n n e l a r e a l s o p o s s i b l e . I n t h i s c h a p t e r , w e a d o p t  

t h e s i m p l e r a n d m o r e r e s t r i c t i v e m o d e l i n w h i c h   D  =  D 

a n d d e v e l o p a l g o r i t h m s t h a t a r e n e a r - o p t i m a l e v e n f o r t h i s  

m o r e r e s t r i c t i v e m o d e l . A m o r e d e t a i l e d d i s c u s s i o n o f d i s k m o d e l s a n d c h a r a c t e r i s t i c s a p p e a r s i n R W 9 4 ] .  

T h e p r o b l e m o f e x t e r n a l s o r t i n g i n t h e   D  - d i s k m o d e l h a s b e e n e x t e n s i v e l y s t u d i e d . A l g o r i t h m s h a v e b e e n d e v e l o p e d  

t h a t u s e a n a s y m p t o t i c a l l y o p t i m a l (  

D B 

l o g (  N = B  ) 

l o g (  M = B  ) 

) n u m b e r o f I / O o p e r a t i o n s  

, a s w e l l a s d o i n g a n o p t i m a l a m o u n t  

o f w o r k i n i n t e r n a l m e m o r y . T h e p r e v i o u s l y d e v e l o p e d s o r t i n g a l g o r i t h m s f o r t h e   D  - d i s k m o d e l h a v e l a r g e r t h a n  

T h r o u g h o u t t h i s c h a p t e r w e u s e t h e s t a n d a r d a s y m p t o t i c n o t a t i o n   f  (  n  ) =  O  (  g  (  n  ) ) t o m e a n t h a t  

t h e r e a r e c o n s t a n t s   C  ,  n 

>  0 s u c h t h a t   j  f  (  n  )  j   C  j  g  (  n  )  j  f o r a l l   n    n 

. W e s a y t h a t   f  (  n  ) = 

(  g  (  n  ) ) i f   g  (  n  ) =  O  (  f  (  n  ) ) . W e w r i t e   f  (  n  ) = (  g  (  n  ) ) i f   f  (  n  ) =  O  (  g  (  n  ) ) a n d   f  (  n  ) = (  g  (  n  ) ) . 

2 8 

Page 42: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 42/203

d e s i r e d c o n s t a n t f a c t o r s , a n d s o m e a r e c o m p l i c a t e d t o i m p l e m e n t . A s a r e s u l t , t h e s i m p l e t e c h n i q u e o f   m e r g e s o r t  

w i t h d i s k s t r i p i n g   ( D S M ) , w h i c h c a n b e a s y m p t o t i c a l l y s u b - o p t i m a l i n t e r m s o f n u m b e r o f I / O s b y a m u l t i p l i c a t i v e  

f a c t o r o f l n (  M = B  ) , i s c o m m o n l y u s e d i n p r a c t i c e f o r e x t e r n a l s o r t i n g o n p a r a l l e l d i s k s N V 9 0 , N V 9 3 ] . I n D S M , t h e  

d i s k s a r e c o o r d i n a t e d s o t h a t i n e a c h p a r a l l e l r e a d a n d w r i t e , t h e l o c a t i o n s o f t h e b l o c k s a c c e s s e d o n e a c h d i s k a r e  

t h e s a m e , w h i c h h a s t h e l o g i c a l e e c t o f s o r t i n g w i t h   D 

= 1 d i s k a n d b l o c k s i z e   B 

=  D B  . I n e a c h m e r g e p a s s ,  

R  = (  M = D B   ) r u n s a r e m e r g e d t o g e t h e r a t a t i m e , e x c e p t p o s s i b l y i n t h e l a s t p a s s . T h e n u m b e r o f p a s s e s r e q u i r e d  

i s t h u s l n (  N = M  )  =  l n (  M = D B   ) , w i t h a n a d d i t i o n a l p a s s f o r i n i t i a l r u n f o r m a t i o n . T h e r e s u l t i n g I / O c o m p l e x i t y o f D S M  

i s (  

D B 

( 1 + 

l o g (  N = M  ) 

l o g (  M = D B   ) 

) ) . T h e a d v a n t a g e o f D S M i s i t s s i m p l i c i t y , w h i c h r e s u l t s i n v e r y s m a l l c o n s t a n t f a c t o r s , t h u s  

m a k i n g i t a t t r a c t i v e f o r e c i e n t i m p l e m e n t a t i o n o n e x i s t i n g p a r a l l e l d i s k s y s t e m s . B u t t h e d i s a d v a n t a g e o f D S M i s  

t h a t i t b e c o m e s i n e c i e n t a s t h e n u m b e r o f d i s k s g e t s l a r g e r .  

T h u s , o n t h e o n e h a n d w e h a v e e x t e r n a l s o r t i n g a l g o r i t h m s t h a t a r e o p t i m a l ( u p t o a c o n s t a n t f a c t o r ) b u t a r e n o t  

e c i e n t i n p r a c t i c e u n l e s s t h e n u m b e r o f d i s k s i s v e r y l a r g e , a n d o n t h e o t h e r h a n d w e h a v e a s i m p l e d i s k s t r i p i n g  

t e c h n i q u e t h a t w o r k s w e l l w i t h a s m a l l n u m b e r o f d i s k s .  

I n o r d e r t o r e a l i z e a n o p t i m a l a n d p r a c t i c a l   D  d i s k e x t e r n a l m e r g e s o r t , i t i s n e c e s s a r y t o m e r g e   R  = (  M = B  ) 

r u n s a t a t i m e i n s u c h a m a n n e r t h a t t h e n u m b e r o f I / O s r e q u i r e d i n e a c h m e r g e p a s s i s (  N = D B   ) . A n i n t e r e s t i n g  

o b s e r v a t i o n m a d e i n K n u 9 8 , S e c t i o n 5 . 4 . 9 , P a g e 3 7 0 ] b y K n u t h i s t h a t t h e s o - c a l l e d   G i l b r e a t h p r i n c i p l e   , b a s e d u p o n  

a n e l e g a n t c a r d t r i c k , c a n b e u s e d t o d e s i g n a s i m p l e I / O a l g o r i t h m t o m e r g e t o g e t h e r   R  = 2 r u n s s t r i p e d a c r o s s  

D  d i s k s i n t h e i d e a l n u m b e r o f I / O o p e r a t i o n s . B u t t h e r e i s n o a n a l o g o f t h e G i l b r e a t h p r i n c i p l e w h e n   R >  2

F u n d a m e n t a l d i c u l t i e s n e e d t o b e o v e r c o m e w h i l e m e r g i n g t o g e t h e r a l a r g e n u m b e r o f r u n s s t r i p e d a c r o s s   D  d i s k s  

w h e n t h e a v e r a g e a m o u n t o f i n t e r n a l m e m o r y a v a i l a b l e a s b u e r s p a c e f o r e a c h r u n i s o n l y   O  ( 1 ) b l o c k s .  

I n t h i s c h a p t e r , w e p r e s e n t a n e l e g a n t t e c h n i q u e t o m e r g e   R  = (  M = B  ) r u n s s t r i p e d a c r o s s   D  d i s k s u s i n g p a r a l l e l  

I / O o p e r a t i o n s . O u r   S i m p l e R a n d o m i z e d M e r g e s o r t   ( S R M ) t e c h n i q u e i s p r a c t i c a l a n d p r o v a b l y e c i e n t f o r a w i d e  

r a n g e o f v a l u e s o f   D  . W e s h o w t h a t S R M i s a s y m p t o t i c a l l y o p t i m a l f o r s o r t i n g w i t h i n v e r y s m a l l c o n s t a n t f a c t o r s  

w h e n   M  = (  D B  l o g  D  ) , w h i c h i s g e n e r a l l y s a t i s e d i n p r a c t i c e . M o r e o v e r , e v e n f o r r a n g e s o f   D  ,  M  , a n d   B  w h e n  

S R M i s s u b - o p t i m a l , i t s t i l l r e m a i n s e c i e n t a n d f a s t e r t h a n D S M , a s b o r n e o u t b y o u r t h e o r e t i c a l a n a l y s i s a n d  

e m p i r i c a l s i m u l a t i o n s .  

I n t h e n e x t s e c t i o n w e d e s c r i b e S R M a n d s o m e p r e v i o u s a p p r o a c h e s t o e x t e r n a l m e r g e s o r t , a n d w e l i s t o u r m a i n  

t h e o r e t i c a l r e s u l t T h e o r e m 6 , w h i c h g i v e s a n a n a l y t i c a l u p p e r b o u n d o n S R M ' s e x p e c t e d n u m b e r o f I / O s i n t h e w o r s t  

c a s e . S e c t i o n s 3 . 3 { 3 . 8 f o c u s o n S R M a n d i t s a n a l y s i s . S e c t i o n 3 . 3 d i s c u s s e s t h e b a s i c i d e a o f S R M a n d t h e w a y t h a t  

r e c o r d s a r e d i s t r i b u t e d o n t h e d i s k s , w h i c h i s i m p o r t a n t t o a t t a i n e c i e n t r e a d a n d w r i t e p a r a l l e l i s m . S e c t i o n 3 . 4  

W e s a y t h a t   f  (  n  ) =  o  (  g  (  n  ) ) i f   f  (  n  )  = g  (  n  )  !  0 a s  n  ! 1  . T h e a b o v e a s y m p t o t i c n o t a t i o n s c a n  

b e a p p l i e d i n a g e n e r a l i z e d m a n n e r a s w e l l . F o r e x a m p l e , w e w r i t e   f  (  n  ) =  g  (  n  ) +  O  (  h  (  n  ) ) i f  

f  (  n  )    g  (  n  ) =  O  (  h  (  n  ) ) , a n d w e s a y t h a t   f  (  n  )    g  (  n  ) +  O  (  h  (  n  ) ) i f t h e r e i s s o m e   j  (  n  ) s u c h t h a t  

f  (  n  )    j  (  n  ) a n d   j  (  n  ) =  g  (  n  ) +  O  (  h  (  n  ) ) . 

2 9 

Page 43: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 43/203

d i s c u s s e s t h e f o r e c a s t i n g d a t a s t r u c t u r e n e e d e d f o r p a r a l l e l r e a d s . S e c t i o n 3 . 5 d e s c r i b e s t h e m e r g e p r o c e s s i n d e t a i l .  

W e a n a l y z e t h e m e r g e p r o c e s s i n S e c t i o n s 3 . 6 , 3 . 7 , a n d 3 . 7 . 1 a n d p r o v e T h e o r e m 6 . I n S e c t i o n 3 . 8 , w e b r i e y d i s c u s s  

t h e p o t e n t i a l b e n e t s o f a d e t e r m i n i s t i c v e r s i o n o f o u r a l g o r i t h m .  

I n S e c t i o n s 3 . 9 a n d 3 . 1 0 , w e d e m o n s t r a t e t h e p r a c t i c a l m e r i t o f S R M b y c o m p a r i s o n w i t h D S M . W e b a s e o u r  

c o m p a r i s o n s o n b o t h o u r a n a l y t i c a l w o r s t - c a s e e x p e c t e d b o u n d s a s w e l l a s t h e m o r e o p t i m i s t i c e m p i r i c a l s i m u l a t i o n s  

o f a v e r a g e - c a s e p e r f o r m a n c e , f o r a w i d e v a r i e t y o f v a l u e s f o r t h e p a r a m e t e r s   M  ,  D  , a n d   B 

3 . 2 M a i n R e s u l t s    

3 . 2 . 1 B a c k g r o u n d  

T h e r s t s t e p i n m e r g e s o r t i n g a l e o f   N  r e c o r d s i s t o s o r t t h e r e c o r d s i n t e r n a l l y , o n e h a l f m e m o r y l o a d a t a t i m e  

s o a s t o o v e r l a p c o m p u t a t i o n w i t h I / O , t o g e t 2  N = M  s o r t e d r u n s e a c h o f l e n g t h   M =  2 . T e c h n i q u e s l i k e r e p l a c e m e n t  

s e l e c t i o n K n u 9 8 ] c a n p r o d u c e r o u g h l y   N = M  r u n s e a c h o f l e n g t h a b o u t   M  . T h e n , i n a s e r i e s o f p a s s e s o v e r t h e l e ,  R 

s o r t e d r u n s o f r e c o r d s a r e r e p e a t e d l y m e r g e d t o g e t h e r u n t i l t h e l e i s s o r t e d . A t e a c h s t e p o f t h e m e r g e , t h e r e c o r d  

w i t h t h e s m a l l e s t k e y v a l u e a m o n g t h e   R  l e a d i n g r e c o r d s o f t h e   R  r u n s b e i n g m e r g e d i s a p p e n d e d t o t h e o u t p u t r u n .  

T h e m e r g e o r d e r p a r a m e t e r   R  i s p r e f e r a b l y c h o s e n a s c l o s e t o   M =  2  B  a s p o s s i b l e s o a s t o r e d u c e t h e n u m b e r o f p a s s e s  

a n d s t i l l a l l o w d o u b l e b u e r i n g .  

I n o r d e r t o c a r r y o u t a m e r g e , t h e l e a d i n g p o r t i o n s o f a l l t h e r u n s n e e d t o b e i n m a i n m e m o r y . A s s o o n a s a n y  

r u n ' s l e a d i n g p o r t i o n i n m e m o r y g e t s d e p l e t e d b y t h e m e r g e p r o c e s s , a n I / O r e a d o p e r a t i o n i s r e q u i r e d . S i n c e a l a r g e  

n u m b e r o f r u n s ( c l o s e t o   M =  2  B  r u n s ) a r e m e r g e d t o g e t h e r a t a t i m e , t h e a m o u n t o f m e m o r y a v a i l a b l e f o r b u e r i n g  

l e a d i n g p o r t i o n s o f r u n s i s v e r y s m a l l o n a v e r a g e . I t i s o f p a r a m o u n t i m p o r t a n c e t h a t o n l y t h o s e b l o c k s t h a t w i l l b e  

r e q u i r e d i n t h e n e a r f u t u r e w i t h r e s p e c t t o t h e m e r g e p r o c e s s a r e f e t c h e d i n t o m a i n m e m o r y b y t h e p a r a l l e l r e a d s .  

H o w e v e r , t h i s m e m o r y m a n a g e m e n t i s d i c u l t t o a c h i e v e s i n c e t h e o r d e r i n w h i c h t h e d a t a i n v a r i o u s d i s k b l o c k s w i l l  

p a r t i c i p a t e i n t h e m e r g e p r o c e s s i s i n p u t d e p e n d e n t a n d u n k n o w n . V i t t e r a n d S h r i v e r V S 9 4 ] g i v e f u r t h e r i n t u i t i o n  

r e g a r d i n g t h e d i c u l t y o f m e r g e s o r t i n g o n p a r a l l e l d i s k s . I n G r e e d S o r t N V 9 0 ] , t h e t r i c k o f \ a p p r o x i m a t e m e r g i n g "  

i s u s e d t o c i r c u m v e n t t h i s d i c u l t y . A g g a r w a l a n d P l a x t o n A P 9 4 ] u s e t h e S h a r e s o r t t e c h n i q u e t h a t d o e s r e p e a t e d  

m e r g i n g w i t h a c c o m p a n y i n g o v e r h e a d .  

R e c e n t l y , P a i e t a l P S V 9 4 ] c o n s i d e r e d t h e a v e r a g e - c a s e p e r f o r m a n c e o f a s i m p l e m e r g i n g s c h e m e f o r   R  =  D  s o r t e d  

r u n s , o n e r u n o n e a c h d i s k . T h e y u s e a n a p p r o x i m a t e m o d e l o f a v e r a g e - c a s e i n p u t s a n d r e q u i r e t h a t t h e i n t e r n a l  

m e m o r y b e s u c i e n t l y l a r g e . T h e y a l s o r e q u i r e t h a t e a c h r u n r e s i d e e n t i r e l y o n a s i n g l e d i s k ; i n o r d e r t o g e t f u l l  

o u t p u t b a n d w i d t h , t h e o u t p u t r u n m u s t b e s t r i p e d a c r o s s d i s k s . A m e r g e s o r t b a s e d u p o n t h e i r m e r g e s c h e m e t h u s  

r e q u i r e s a n e x t r a t r a n s p o s i t i o n p a s s b e t w e e n m e r g e p a s s e s s o t h a t s t r i p e d o u t p u t r u n s o f t h e p r e v i o u s m e r g e p a s s c a n  

b e r e a l i g n e d o n t o i n d i v i d u a l d i s k s .  

3 0 

Page 44: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 44/203

3 . 2 . 2 O v e r v i e w o f S R M  

W e p r e s e n t a n e c i e n t , p r a c t i c a l , r a n d o m i z e d a l g o r i t h m f o r e x t e r n a l s o r t i n g c a l l e d   S i m p l e R a n d o m i z e d M e r g e s o r t  

( S R M ) . O u r a l g o r i t h m u s e s a g e n e r a l i z a t i o n o f t h e f o r e c a s t i n g t e c h n i q u e K n u 9 8 ] i n o r d e r t o c a r r y o u t p a r a l l e l  

p r e f e t c h i n g o f a p p r o p r i a t e d i s k b l o c k s d u r i n g m e r g i n g . R a n d o m i z a t i o n i s u s e d o n l y w h i l e c h o o s i n g , f o r e a c h i n p u t  

r u n , t h e d i s k o n w h i c h t o p l a c e t h e r s t b l o c k o f t h e r u n ; t h e r e m a i n i n g b l o c k s o f t h a t r u n a r e c y c l i c a l l y s t r i p e d a c r o s s  

t h e d i s k s . T h e u s e o f r a n d o m i z a t i o n i s t h u s v e r y r e s t r i c t e d ; t h e m e r g i n g i t s e l f i s d e t e r m i n i s t i c .  

I f t h e i n t e r n a l m e m o r y a v a i l a b l e i s o f s i z e   M  , w i t h b l o c k s i z e   B  a n d w i t h   D  p a r a l l e l d i s k s , S R M m e r g e s   R  r u n s  

t o g e t h e r a t a t i m e i n e a c h m e r g e p a s s , w h e r e   R  i s t h e l a r g e s t i n t e g e r s a t i s f y i n g   M = B    2  R  + 4  D  +  R D = B   . W e n o t e  

t h a t   M = B  i s t h e n u m b e r o f i n t e r n a l m e m o r y b l o c k s a v a i l a b l e . H e n c e t h e m e r g e o r d e r ( t h e n u m b e r o f r u n s S R M  

m e r g e s t o g e t h e r a t a t i m e ) i s d e t e r m i n e d b y t h e a m o u n t o f i n t e r n a l m e m o r y a t i t s d i s p o s a l . A s a f u n c t i o n o f   M  ,  B  , 

a n d  D  , t h e m e r g e o r d e r   R  i s g i v e n b y (  M = B    4  D  )  =  ( 2 +  D = B  ) . I n t h e t h e r e a l i s t i c c a s e t h a t   D  =  O  (  B  ) , S R M m e r g e s  

a n o p t i m a l n u m b e r ( n a m e l y ,   R  = (  M = B  ) ) o f r u n s t o g e t h e r a t a t i m e . F o r s i m p l i c i t y i n t h e e x p o s i t i o n , w e a s s u m e  

t h a t   D  =  O  (  B  ) . ( W e c a n u s e t h e p a r t i a l s t r i p i n g t e c h n i q u e o f V S 9 4 ] t o e n f o r c e t h e a s s u m p t i o n i f n e e d e d . )  

T h e r e a r e t w o a s p e c t s t o o u r a n a l y s i s o f t h e a l g o r i t h m | o n e t h e o r e t i c a l a n d o n e p r a c t i c a l . T h e r s t ( a n d m a i n )  

p a r t o f o u r a n a l y s i s i s b o u n d i n g t h e e x p e c t e d n u m b e r o f I / O s o f S R M , w h e r e t h e e x p e c t a t i o n i s w i t h r e s p e c t t o t h e  

r a n d o m i z a t i o n i n t e r n a l t o S R M a n d t h e b o u n d o n t h e e x p e c t a t i o n h o l d s f o r a n y i n p u t . S R M u s e s a n e l e g a n t i n t e r n a l  

m e m o r y m a n a g e m e n t s c h e m e t o s o l v e t h e f u n d a m e n t a l p r e f e t c h i n g d i c u l t i e s o f s i m p l e m e r g i n g o n p a r a l l e l d i s k s  

a l l u d e d t o e a r l i e r i n S e c t i o n 3 . 2 . 1 . B e l o w w e b r i e y s k e t c h t h i s t e c h n i q u e :  

A t a n y t i m e w h i l e m e r g i n g t o g e t h e r   R  r u n s , l e t u s c o n s i d e r h o w S R M r e a d s i n t h e n e x t   R  b l o c k s o n d i s k r e q u i r e d  

b y t h e m e r g e p r o c e s s . O b s e r v i n g t h a t t h e n e x t   R  b l o c k s o n d i s k w i l l n o t , i n g e n e r a l , b e u n i f o r m l y d i s t r i b u t e d a m o n g  

t h e  D  d i s k s , w e d e n o t e a s   d 

 

t h e m a x i m u m n u m b e r o f b l o c k s a m o n g t h e s e   R  b l o c k s t h a t r e s i d e o n a s i n g l e d i s k .  

T h e b l o c k s o f t h e   R  i n p u t r u n s a r e s t r i p e d a c r o s s t h e d i s k s . I n o r d e r t o m a x i m i z e p a r a l l e l i s m , i n e a c h I / O r e a d  

o p e r a t i o n , S R M f e t c h e s i n t o m e m o r y o n e b l o c k f r o m e a c h d i s k w h e n e v e r t h e r e i s s p a c e t o a c c o m m o d a t e   D  b l o c k s i n  

m a i n m e m o r y . I n a n y I / O r e a d o p e r a t i o n , t h e b l o c k t h a t i s r e a d i n f r o m e a c h d i s k i s t h e o n e t h a t c o n t a i n s t h e s m a l l e s t  

k e y a m o n g a l l t h e i n p u t b l o c k s o n t h a t d i s k t h a t a r e n o t y e t i n m e m o r y . T h i s i s a c h i e v e d b y u s i n g t h e f o r e c a s t i n g  

t e c h n i q u e . I n t h e e v e n t t h a t t h e r e i s o n l y e n o u g h f r e e m e m o r y t o r e a d i n   F  a d d i t i o n a l d i s k b l o c k s , w h e r e   F < D  , 

S R M  u s h e s o u t   D    F  p r e v i o u s l y r e a d b l o c k s f r o m m e m o r y b a c k t o d i s k . A m o n g t h e b l o c k s a l r e a d y i n m e m o r y ,  

t h e  D    F  b l o c k s c h o s e n f o r u s h i n g a r e p r e c i s e l y t h e   D    F  b l o c k s t h a t w i l l p a r t i c i p a t e i n t h e m e r g e f a r t h e s t i n  

t h e f u t u r e . T h e i n t e r n a l m e m o r y b u e r S R M t h a t u s e s i s j u s t l a r g e e n o u g h t o e n s u r e t h a t n o b l o c k t h a t i s a m o n g  

t h e  R  b l o c k s r e q u i r e d n e x t b y t h e m e r g e i s e v e r u s h e d o u t . M o r e o v e r , t h e r e i s n o a c t u a l I / O t h a t a c c o m p a n i e s t h e  

u s h i n g o p e r a t i o n ; S R M m e r e l y p r e t e n d s t h a t t h o s e b l o c k s h a d n e v e r b e e n r e a d i n t o m e m o r y . T h e f o r e c a s t i n g a n d  

u s h i n g a r e e n o u g h t o e n s u r e t h a t b r i n g i n g p r e c i s e l y t h o s e   R  b l o c k s t h a t a r e n e x t r e q u i r e d b y t h e m e r g e f r o m d i s k  

i n t o m e m o r y w i l l t a k e n o m o r e t h a n   d 

 

I / O r e a d o p e r a t i o n s .  

T h i s m e m o r y m a n a g e m e n t s c h e m e e n a b l e s u s t o o b t a i n a h a n d l e o n S R M ' s p e r f o r m a n c e . W e a r e a b l e t o r e l a t e  

3 1 

Page 45: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 45/203

S R M ' s p e r f o r m a n c e t o a c o m b i n a t o r i a l p r o b l e m w e c a l l t h e   d e p e n d e n t m a x i m u m o c c u p a n c y   p r o b l e m , w h i c h i s a  

g e n e r a l i z a t i o n o f t h e c l a s s i c a l m a x i m u m o c c u p a n c y p r o b l e m K S C 7 8 , V F 9 0 ] .  

O u r m a i n t h e o r e m b e l o w g i v e s e x p r e s s i o n s f o r t h e I / O p e r f o r m a n c e o f S R M f o r t h r e e p a t t e r n s o f g r o w t h r a t e  

b e t w e e n t h e n u m b e r   M = B  o f b l o c k s i n i n t e r n a l m e m o r y a n d t h e n u m b e r   D  o f d i s k s i n t h e p a r a l l e l d i s k s y s t e m . T h e  

d i e r e n t s i z e s o f i n t e r n a l m e m o r y c o n s i d e r e d c o r r e s p o n d t o c e r t a i n v a l u e s o f t h e m e r g e o r d e r   R  a s d e n e d b y t h e  

f o r m u l a   R  = (  M = B    4  D  )  =  ( 2 +  D = B  ) g i v e n a b o v e . T h e g e n e r a l f o r m u l a t i o n i n t e r m s o f o c c u p a n c y s t a t i s t i c s i s g i v e n  

l a t e r .  

T h e o r e m 6   U n d e r t h e a s s u m p t i o n t h a t   D  =  O  (  B  )  , t h e m e r g e o r d e r   R  = (  M = B  )  o f S R M i s o p t i m a l . S R M  

m e r g e s o r t u s e s  

D B 

( 1 + 

l n (  N = M  ) 

l n  R 

)  I / O w r i t e o p e r a t i o n s  

, w h i c h i s o p t i m a l . T h e e x p e c t e d n u m b e r R e a d s  

S R M 

o f I / O  

r e a d o p e r a t i o n s d o n e b y S R M c a n b e b o u n d e d f r o m a b o v e a s f o l l o w s :  

1 . I f   R  =  k D  f o r c o n s t a n t   k  , a s  R  ,  D  ! 1  , w e h a v e  

R e a d s  

S R M 

 

D B 

l n (  N = M  ) 

l n  k D 

l n  D 

k  l n l n   D 

 

  

1 + 

l n l n l n   D 

l n l n   D 

1 + l n   k 

l n l n   D 

+  O 

  

( l o g l o g l o g   D  ) 

( l o g l o g   D  ) 

 

D B 

2 . I f   R  =  r D  l n  D  f o r c o n s t a n t   r  , a s  R  ,  D  ! 1  , w e h a v e  

R e a d s  

S R M 

 

D B 

+  c 

D B 

l n (  N = M  ) 

l n (  r D  l n  D  ) 

+  O  ( 1 ) 

w h i c h i s o p t i m a l w i t h i n a c o n s t a n t f a c t o r , n a m e l y   c  . T h e m a g n i t u d e o f   c  d e p e n d s u p o n   r 

3 . I f   R  =  r D  l n  D  w h e r e   r  = ( 1 )  , w e h a v e  

R e a d s  

S R M 

 

D B 

l n (  N = M  ) 

l n (  r D  l n  D  ) 

 

  

1 + 

r  

l n  r 

2  r  l n  D 

+  O 

  

l o g  r 

r  l o g  D 

 

D B 

S t r i c t l y s p e a k i n g , t h e e x p r e s s i o n s f o r t h e e x a c t n u m b e r o f \ p a s s e s " a n d h e n c e t h e n u m b e r o f  

I / O o p e r a t i o n s r e q u i r e d t o s o r t   N  r e c o r d s u s i n g a m e r g e s o r t i n v o l v e s a p p l y i n g t h e c e i l i n g (  d e  ) 

f u n c t i o n t o c e r t a i n l o g a r i t h m i c t e r m s . E m p l o y i n g t h e s e e x a c t e x p r e s s i o n s w o u l d m e a n d e a l i n g  

w i t h a c o m p l i c a t e d d e p e n d e n c e u p o n   N  , w i t h o u t h a v i n g a n y s i g n i c a n t i m p a c t o n o u r r e s u l t s  

f o r l a r g e   N  . T h u s i n t h i s e x p o s i t i o n w e c h o o s e t o o v e r l o o k t h i s i s s u e a n d n o t a p p l y t h e c e i l i n g  

f u n c t i o n , t h u s o b t a i n i n g s i m p l i e d e x p r e s s i o n s f o r I / O c o m p l e x i t y .  

3 2 

Page 46: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 46/203

w h i c h i s a s y m p t o t i c a l l y o p t i m a l ; t h a t i s , t h e f a c t o r o f p r o p o r t i o n a l i t y m u l t i p l y i n g t h e   (  N = D B   ) 

l n (  N = M  ) 

l n (  r D  l n  D  ) 

t e r m  

i s 1 .  

T h e m e r g e s o r t a l g o r i t h m b y P a i e t a l P S V 9 4 ] u s e s s i g n i c a n t l y m o r e I / O s a n d i n t e r n a l m e m o r y . I n t h e i r s c h e m e ,  

t h e i n t e r n a l m e m o r y s i z e n e e d s t o b e (  D 

B  ) t o a t t a i n a n e c i e n t m e r g i n g a l g o r i t h m .  

T h e o t h e r a s p e c t o f o u r a n a l y s i s d e a l s w i t h t h e p r a c t i c a l m e r i t o f o u r S R M m e r g e s o r t a l g o r i t h m o n e x i s t i n g  

p a r a l l e l d i s k s y s t e m s . I n S e c t i o n s 3 . 9 a n d 3 . 1 0 , w e c o n s i d e r i m p l e m e n t a t i o n s o f d i s k s t r i p i n g ( D S M ) a n d S R M  

m e r g e s o r t a l g o r i t h m s f o r t h e i n t e r e s t i n g c a s e   R  =  k D  , i n w h i c h t h e n u m b e r o f b l o c k s i n i n t e r n a l m e m o r y s c a l e s  

l i n e a r l y w i t h t h e n u m b e r o f d i s k s   D  b e i n g u s e d . W e d e m o n s t r a t e t h a t S R M ' s g o o d I / O p e r f o r m a n c e i s n o t m e r e l y  

a s y m p t o t i c , b u t e x t e n d s t o p r a c t i c a l s i t u a t i o n s a s w e l l . L i k e D S M , S R M a l s o o v e r l a p s I / O o p e r a t i o n s a n d i n t e r n a l  

c o m p u t a t i o n , w h i c h i s i m p o r t a n t i n p r a c t i c e .  

3 . 3 S R M D a t a L a y o u t    

O u r p r i m a r y g o a l i n t h i s c h a p t e r i s t o t a k e a d v a n t a g e o f m e r g e s o r t ' s s i m p l i c i t y a n d p o t e n t i a l f o r h i g h e c i e n c y i n  

p r a c t i c e w h e n u s e d w i t h p a r a l l e l d i s k s y s t e m s . W e u s e s t r i p e d i n p u t r u n s i n o u r m e r g i n g p r o c e d u r e s o t h a t t h e o u t p u t  

r u n s o f o n e m e r g e p a s s w r i t t e n w i t h f u l l w r i t e p a r a l l e l i s m c a n p a r t i c i p a t e a s i n p u t r u n s i n t h e n e x t p a s s w i t h o u t a n y  

r e o r d e r i n g o r t r a n s p o s i t i o n . I n t h i s s c h e m e , i f t h e 0 t h b l o c k o f a r u n   r  i s o n d i s k   d 

, t h e n t h e   i  t h b l o c k r e s i d e s o n d i s k  

(  i  +  d 

) m o d   D  . S t r i p i n g a l o n e i s n o t e n o u g h t o e n s u r e g o o d p e r f o r m a n c e . I f m a n y r u n s a r e b e i n g m e r g e d a n d t h e  

d i s k   d 

f o r e a c h r u n   r  i s c h o s e n d e t e r m i n i s t i c a l l y , t h e m e r g i n g a l g o r i t h m c a n h a v e a b y s m a l w o r s t c a s e p e r f o r m a n c e .  

T h r o u g h o u t t h e e n t i r e d u r a t i o n o f t h e m e r g e , t h e   R  l e a d i n g b l o c k s o f t h e   R  r u n s m a y a l w a y s l i e o n t h e s a m e d i s k ,  

t h u s c a u s i n g I / O t h r o u g h p u t t o b e o n l y a f a c t o r o f 1  = D  o f o p t i m a l .  

A n a t u r a l a l t e r n a t i v e t h a t w e p u r s u e i n t h i s c h a p t e r i s t o c o n s i d e r a r a n d o m i z e d a p p r o a c h t o m e r g e s o r t . W e  

r a n d o m l y a s s i g n t h e s t a r t i n g d i s k   d 

f o r e a c h i n p u t r u n   r  . T h e n , o n a v e r a g e , i t i s n o t n e c e s s a r y t o r e a d m a n y b l o c k s  

f r o m t h e s a m e d i s k a t o n e t i m e . T h e a n a l y s i s i n v o l v e s a n i n t e r e s t i n g r e d u c t i o n t o a m a x i m u m b u c k e t o c c u p a n c y  

p r o b l e m .  

I n o r d e r t o f a c i l i t a t e a n a l y s i s ,   f o r e a c h r u n   r  w e c h o o s e t h e d i s k   d 

o n w h i c h   r  ' s i n i t i a l b l o c k w i l l r e s i d e i n d e -  

p e n d e n t l y a n d i d e n t i c a l l y w i t h u n i f o r m p r o b a b i l i t y .   T h e l o c a t i o n o f e v e r y s u b s e q u e n t b l o c k o f r u n   r  i s d e t e r m i n e d  

d e t e r m i n i s t i c a l l y b y c y c l i n g t h r o u g h t h e d i s k s . W e w i l l m e a s u r e o u r a l g o r i t h m ' s p e r f o r m a n c e b y b o u n d i n g t h e   e x p e c t e d  

n u m b e r o f I / O s r e q u i r e d t o m e r g e   R  r u n s f o r a n y   a r b i t r a r y   ( t h a t i s ,   w o r s t - c a s e   ) s e t o f i n p u t r u n s ; t h e e x p e c t a t i o n  

i s w i t h r e s p e c t t o t h e r a n d o m i z a t i o n i n t h e p l a c e m e n t o f t h e r s t b l o c k o f t h e r u n s . T h e a c t u a l k e y v a l u e s o f t h e  

r e c o r d s t h a t c o n s t i t u t e t h e r u n s c a n b e a r b i t r a r y a n d t h e i r r e l a t i v e o r d e r d o e s n o t a e c t t h e b o u n d s w e d e r i v e .  

I f w e c o n s i d e r t h e p r o b l e m o f d e t e r m i n i s t i c m e r g e s o r t i n g w i t h r a n d o m i n p u t s , a s o p p o s e d t o r a n d o m i z e d m e r g e -  

s o r t i n g , w e b e l i e v e t h a t t h e s a m e a n a l y s i s t e c h n i q u e c a n y i e l d s i m i l a r b o u n d s ( b u t f o r t h e a v e r a g e - c a s e ) f o r a v e r s i o n  

o f o u r a l g o r i t h m i n w h i c h t h e s t a r t i n g d i s k   d 

f o r r u n   r  i s d e t e r m i n i s t i c a l l y c h o s e n t o b e u n i f o r m l y s t a g g e r e d , s o t h a t  

3 3 

Page 47: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 47/203

= 0 f o r   r  = 0  ;  1  ; : : : ; R = D     1 ,  d 

= 1 f o r   r  =  R = D ; R = D   + 1  ; : : : ;  2  R = D    1 a n d s o o n . M o r e o v e r , a s w e i n d i c a t e  

i n S e c t i o n 3 . 8 , b y t a k i n g i n t o c o n s i d e r a t i o n t h e l e n g t h s o f t h e r u n s b e i n g m e r g e d i n d i e r e n t s t a g e s o f t h e m e r g e s o r t , i t  

m a y b e p o s s i b l e t o i m p r o v e t h e b o u n d o n o v e r a l l a v e r a g e I / O p e r f o r m a n c e . I n t h i s c h a p t e r , h o w e v e r , w e c o n c e n t r a t e  

o n o u r S R M m e t h o d , s i n c e a v e r y l i m i t e d a m o u n t o f e x p l i c i t r a n d o m i z a t i o n i n S R M ( u s e d t o d e t e r m i n e t h e r a n d o m  

s t a r t i n g d i s k s   d 

) e n a b l e s u s t o g e t a r o u n d t h e a v e r a g e - c a s e a s s u m p t i o n o f t h e d e t e r m i n i s t i c v e r s i o n , t h u s f a c i l i t a t i n g  

t h e e l e g a n t a n a l y s i s p r e s e n t e d h e r e .  

3 . 4 F o r e c a s t i n g F o r m a t a n d D a t a S t r u c t u r e      

A s o b s e r v e d e a r l i e r , e a c h o f t h e   R  r u n s t h a t p a r t i c i p a t e i n a m e r g e i s o u t p u t o n t o d i s k e i t h e r d u r i n g t h e r u n f o r m a t i o n  

s t a g e o r d u r i n g s o m e e a r l i e r m e r g e . T h i s e n a b l e s u s t o b e g i n e a c h r u n o n a u n i f o r m l y r a n d o m d i s k . W e c a n a l s o  

f o r m a t e a c h b l o c k o f e v e r y r u n s o a s t o i m p l a n t s o m e   f u t u r e   i n f o r m a t i o n a s e x p l a i n e d b e l o w . T h i s i s a g e n e r a l i z a t i o n  

o f t h e   f o r e c a s t i n g   t e c h n i q u e o f K n u 9 8 ] . W e d e n o t e t h e   i  t h b l o c k o f a r u n   r  a s  b 

r ; i 

a n d t h e   s m a l l e s t ( r s t ) k e y   i n 

b l o c k   b 

r ; i 

a s  k 

r ; i 

. B l o c k s o f a r u n   r  a r e f o r m a t t e d a s f o l l o w s :  

  I m p l a n t e d i n t h e i n i t i a l b l o c k   b 

r ;  0 

o f r u n   r  a r e t h e k e y v a l u e s   k 

r ; j 

f o r 0     j    D    1 . ( T y p i c a l l y i n p r a c t i c e ,  

t h e  D  k e y v a l u e s w i l l i n d e e d t i n a s m a l l p o r t i o n o f o n e b l o c k . E v e n i f t h i s i s n o t s o , s i n c e   D  =  O  (  B  ) , t h i s  

i n f o r m a t i o n w i l l t i n a t m o s t   O  ( 1 ) b l o c k s . )  

  I m p l a n t e d i n t h e   i  t h b l o c k   b 

r ; i 

, w h e r e   i >  0 , o f r u n   r  i s t h e s i n g l e k e y v a l u e   k 

r ;  (  i  +  D  ) 

T h e e x t r a i n f o r m a t i o n f o r f o r e c a s t i n g i n e a c h b l o c k i s o n l y o n e k e y v a l u e , n o t o n e r e c o r d . S o t h e e x t r a s p a c e t a k e n  

u p b y t h e f o r e c a s t i n g f o r m a t o f r u n s i s n e g l i g i b l e . F o r s i m p l i c i t y , w e a s s u m e t h a t a l l k e y v a l u e s a r e d i s t i n c t .  

D e n i t i o n 5   A t a n y t i m e   t  d u r i n g t h e m e r g e , c o n s i d e r t h e u n p r o c e s s e d p o r t i o n s o f t h e   R  r u n s . A m o n g t h e s e r e c o r d s ,  

t h e r e c o r d w i t h t h e s m a l l e s t k e y i s c a l l e d t h e   n e x t   r e c o r d o f t h e m e r g e a t t i m e   t  . A b l o c k b e l o n g i n g t o a n y r u n i s  

s a i d t o b e g i n   p a r t i c i p a t i n g   i n t h e m e r g e p r o c e s s a t t h e t i m e   t  w h e n i t s r s t r e c o r d b e c o m e s t h e n e x t r e c o r d o f t h e  

m e r g e . A b l o c k c e a s e s t o p a r t i c i p a t e i n t h e m e r g e a s s o o n a s a l l o f i t s r e c o r d s g e t d e p l e t e d b y t h e m e r g e . A t a n y  

p o i n t o f t i m e , c o n s i d e r a l l t h e b l o c k s n o t i n m e m o r y t h a t r e s i d e o n d i s k   i  . T h e   s m a l l e s t b l o c k o f r u n   j  o n d i s k   i  i s 

t h e b l o c k t h a t w i l l b e t h e e a r l i e s t p a r t i c i p a t i n g b l o c k a m o n g a l l t h e b l o c k s o f r u n   j  o n d i s k   i  . T h e   s m a l l e s t b l o c k o n  

d i s k   i  i s t h e t h e e a r l i e s t p a r t i c i p a t i n g b l o c k o n d i s k   i  a t t h a t t i m e . A t a n y t i m e , t h e   l e a d i n g   b l o c k o f a r u n i s t h e  

b l o c k ( p o s s i b l y p a r t l y c o n s u m e d ) t h a t c o n t a i n s t h e s m a l l e s t k e y v a l u e i n t h a t r u n a t t h a t t i m e . N o t e t h a t a b l o c k  

c a n b e c o m e a l e a d i n g b l o c k m u c h b e f o r e b e g i n n i n g t o p a r t i c i p a t e i n t h e m e r g e .  

O n a n I / O r e a d , t h e b l o c k r e a d i n b y S R M f r o m d i s k   i  i s a l w a y s t h e s m a l l e s t b l o c k o n d i s k   i  a t t h a t t i m e . T o b e  

a b l e t o d o t h i s , S R M m a i n t a i n s a f o r e c a s t i n g d a t a s t r u c t u r e .  

3 4 

Page 48: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 48/203

Page 49: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 49/203

t h e s e , S R M m a i n t a i n s a d y n a m i c a l l y c h a n g i n g p a r t i t i o n   f  M 

; M 

; M 

; M 

g  o f 2  R  + 4  D  p h y s i c a l b l o c k s o f i n t e r n a l  

m e m o r y .  

D e n i t i o n 7   T h e s e t   M 

o f  R  i n t e r n a l b l o c k s i s m a i n t a i n e d s u c h t h a t a t a n y t i m e , i f t h e l e a d i n g b l o c k o f a n y r u n  

i s i n i n t e r n a l m e m o r y , i t s i n t e r n a l b l o c k i s i n   M 

. T h e s e t   M 

c o n t a i n s   D  i n t e r n a l b l o c k s m a i n t a i n e d s u c h t h a t e a c h  

I / O r e a d o p e r a t i o n o f S R M c a n r e a d i n   D  b l o c k s f r o m d i s k s i n t o t h e i n t e r n a l m e m o r y b l o c k s o f   M 

. T h e r e m a i n i n g  

R  +  D  i n t e r n a l m e m o r y b l o c k s c o m p r i s e t h e s e t   M 

. T h e s e t s a r e m a i n t a i n e d s u c h t h a t a s s o o n a s t h e r e a r e   D 

u n o c c u p i e d i n t e r n a l b l o c k s , a p a r a l l e l r e a d c a n b e i n i t i a t e d i n t o   M 

. I n a d d i t i o n , S R M u s e s a s e t   M 

o f 2  D  i n t e r n a l  

m e m o r y b l o c k s a s a n o u t p u t b u e r .  

T h e  D  i n t e r n a l m e m o r y b l o c k s o f   M 

a r e u s e d s p e c i c a l l y t o i n i t i a t e I / O r e a d o p e r a t i o n s a t t h e e a r l i e s t p o s s i b l e  

t i m e , p o t e n t i a l l y b r i n g i n g i n b l o c k s e v e n b e f o r e t h e y b e g i n p a r t i c i p a t i n g . T h e o u t p u t b u e r   M 

i s l a r g e e n o u g h t o  

e n s u r e t h a t t h e o u t p u t r u n c a n b e w r i t t e n o u t w i t h f u l l p a r a l l e l i s m i n t h e f o r e c a s t i n g f o r m a t d e s c r i b e d e a r l i e r .  

T h e f o r e c a s t i n g d a t a s t r u c t u r e F D S a n d r e l a t e d a u x i l i a r y d a t a s t r u c t u r e s o c c u p y n o t m o r e t h a n a b o u t   R D = B  

b l o c k s .  

3 . 5 . 2 M a i n t a i n i n g t h e d y n a m i c p a r t i t i o n o f i n t e r n a l m e m o r y  

A s i n t e r n a l m e r g i n g p r o c e e d s a n d t h e p a r a l l e l I / O o p e r a t i o n s k e e p t r a n s f e r r i n g b l o c k s b e t w e e n t h e p a r a l l e l d i s k s y s t e m  

a n d i n t e r n a l m e m o r y , i n t e r n a l m e m o r y b l o c k s n e e d t o b e e x c h a n g e d a m o n g t h e s e t s   M 

,  M 

,  M 

, a n d   M 

i n o r d e r  

t o e n s u r e t h a t t h e a s s e r t i o n s i n D e n i t i o n 7 a r e m e t . B e l o w , w e d e s c r i b e t h r e e t y p e s o f e x c h a n g e s o f i n t e r n a l m e m o r y  

b l o c k s i n t h e m a n a g e m e n t o f   M 

,  M 

, a n d   M 

1 . C o n s i d e r a n y s t a t e o f i n t e r n a l m e r g e p r o c e s s i n g w h e n t h e l a s t r e c o r d i n t h e l e a d i n g b l o c k o f a r u n   r  g e t s  

c o n s u m e d b y t h e m e r g e . I f r u n   r  ' s n e w l e a d i n g b l o c k o c c u p i e s a n i n t e r n a l b l o c k o f   M 

, t h e n   M 

a n d  M 

m u t u a l l y e x c h a n g e t h e i n t e r n a l b l o c k s c o r r e s p o n d i n g t o t h e n e w a n d o l d l e a d i n g b l o c k s s o t h a t   M 

g e t s a n  

u n o c c u p i e d i n t e r n a l b l o c k a n d   M 

g e t s a n o c c u p i e d o n e .  

2 . C o n s i d e r a n y I / O r e a d o p e r a t i o n t h a t h a s j u s t c o m p l e t e d . I / O r e a d o p e r a t i o n s a l w a y s r e a d i n b l o c k s i n t o t h e  

D  i n t e r n a l m e m o r y b l o c k s o f s e t   M 

. I f t h e r e a d o p e r a t i o n b r i n g s i n t o   M 

a b l o c k t h a t i s t h e l e a d i n g b l o c k  

o f s o m e r u n   r  , t h e n   M 

a n d  M 

e x c h a n g e i n t e r n a l b l o c k s c o r r e s p o n d i n g t o t h e o l d a n d n e w l e a d i n g b l o c k s , s o  

t h a t   M 

g e t s a n u n o c c u p i e d i n t e r n a l b l o c k a n d   M 

g e t s a n o c c u p i e d o n e .  

3 . W h e n e v e r   M 

h a s a t l e a s t o n e u n o c c u p i e d i n t e r n a l m e m o r y b l o c k a n d   M 

h a s a t l e a s t o n e o c c u p i e d i n t e r n a l  

m e m o r y b l o c k ,   M 

a n d  M 

e x c h a n g e i n t e r n a l m e m o r y b l o c k s s o t h a t   M 

o b t a i n s a n u n o c c u p i e d b l o c k a n d  

g e t s a n o c c u p i e d o n e .  

I n a d d i t i o n , r e c o r d s a r e a d d e d t o b l o c k s o f   M 

a s t h e i n t e r n a l m e r g i n g p r o c e e d s .  

3 6 

Page 50: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 50/203

3 . 5 . 3 M a i n t a i n i n g t h e F o r e c a s t i n g D a t a S t r u c t u r e  

W h e n e v e r a b l o c k b e l o n g i n g t o r u n   j  i s r e a d i n t o m e m o r y f r o m d i s k   i  , t h e f o r e c a s t i n g d a t a f r o m t h a t b l o c k i s u s e d  

t o u p d a t e t h e e n t r y   H 

  j  ] o f F D S .  

W e w i l l s e e i n D e n i t i o n 1 0 t h a t S R M m a y a t t i m e s u s h a b l o c k b e l o n g i n g t o r u n   j  t o t h e d i s k   i  i t o r i g i n a t e d  

f r o m . T h i s w i l l n o t r e q u i r e a n y I / O b u t m e r e l y r e q u i r e t h a t t h e e n t r y   H 

  j  ] o f F D S b e u p d a t e d w i t h t h e s m a l l e s t  

k e y o f t h e p a r t i c u l a r b l o c k b e i n g u s h e d . I f m o r e t h a n o n e b l o c k f r o m a p a r t i c u l a r r u n   j  a r e u s h e d t o g e t h e r , a l l t o  

t h e s a m e d i s k   i  , t h e n t h e e n t r y   H 

  j  ] i s u p d a t e d w i t h t h e s m a l l e s t k e y v a l u e a m o n g a l l t h e b l o c k s f r o m r u n   j  b e i n g  

u s h e d t o d i s k   i 

3 . 5 . 4 T e r m i n o l o g y a n d N o t a t i o n  

D e n i t i o n 8   S u p p o s e w e o r d e r a s e t   A  o f b l o c k s i n a s c e n d i n g o r d e r b y t h e b l o c k s ' s m a l l e s t k e y v a l u e s . W e d e n e  

R a n k  

(  b  ) , f o r   b  2  A  , t o b e t h e r a n k o f b l o c k   b  i n t h i s o r d e r . T h e r s t ( s m a l l e s t - v a l u e d ) b l o c k h a s r a n k 1 a n d t h e l a s t  

( l a r g e s t - v a l u e d ) b l o c k h a s r a n k   j  A  j  . F o r a n y t i m e   t  d u r i n g t h e m e r g e , w e d e n e t h e f o l l o w i n g t e r m s :  

d e n o t e s t h e s e t o f f u l l b l o c k s i n i n t e r n a l m e m o r y s u c h t h a t n o b l o c k   b  i n  F 

i s t h e l e a d i n g b l o c k o f a n y r u n  

a t t i m e   t 

d e n o t e s t h e s e t o f   D  b l o c k s , e a c h o f w h i c h i s t h e s m a l l e s t b l o c k o n o n e o f t h e   D  d i s k s .  

  F s e t  

(  l  ) =  f  b  j  b  2 F 

;  R a n k  

(  b  )  j F 

j   l  + 1  g  d e n o t e s t h e s e t o f t h e   l  h i g h e s t r a n k e d b l o c k s o f   F 

B y 

d e n i t i o n , n o b l o c k o f   F s e t  

(  l  ) i s a l e a d i n g b l o c k .  

  O u t R a n k  

= m i n  

b  2 S 

f  R a n k  

(  b  )  g  d e n o t e s t h e r a n k o f t h e s m a l l e s t - r a n k e d b l o c k o f   S 

i n t h e s e t   F 

D e n i t i o n 9   T h e o p e r a t i o n   P a r R e a d  

i s e x e c u t e d a t a t i m e   t  o n l y w h e n   D  u n o c c u p i e d i n t e r n a l b l o c k s a r e a v a i l a b l e  

i n  M 

. U s i n g F D S , i t r e a d s i n t h e s e t   S 

o f  D  b l o c k s i n t o   M 

, e x c h a n g i n g i n t e r n a l b l o c k s o f   M 

w i t h   M 

a s i n  

p o i n t 2 o f S e c t i o n 3 . 5 . 1 i f n e c e s s a r y . F D S i s u p d a t e d a s d e s c r i b e d i n S e c t i o n 3 . 5 . 3 u s i n g t h e i m p l a n t e d i n f o r m a t i o n  

i n b l o c k s o f   S 

D e n i t i o n 1 0   T h e o p e r a t i o n   F l u s h  

(  j  ) v i r t u a l l y u s h e s o u t t h e   j  b l o c k s o f t h e s e t   F s e t  

(  j  ) o c c u p y i n g i n t e r n a l b l o c k s  

i n  M 

a t t i m e   t  . I n S R M , w e h a v e   j    D  w h e n e v e r   F l u s h  

(  j  ) i s i n v o k e d . T h e u s h i n g o f b l o c k s i s v i r t u a l i n t h e  

s e n s e t h a t t h e b l o c k s   d o n o t a c t u a l l y h a v e t o b e w r i t t e n o u t t o d i s k   , s o t h e r e i s n o I / O i n v o l v e d . F D S i s u p d a t e d a s  

d e s c r i b e d i n S e c t i o n 3 . 5 . 3 t o r e e c t t h e f a c t t h a t t h e u s h e d o u t b l o c k s w i l l h a v e t o b e r e a d b a c k f r o m t h e i r o r i g i n a l  

d i s k s w h e n n e e d e d .  

A n i m p o r t a n t f e a t u r e o f S R M e x p l o i t e d i n S e c t i o n 3 . 6 i s t h a t l e a d i n g b l o c k s o f r u n s a r e n e v e r u s h e d o u t .  

3 7 

Page 51: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 51/203

3 . 5 . 5 I / O S c h e d u l i n g A l g o r i t h m  

I n t h i s s u b s e c t i o n , w e s p e c i f y t h e p a r a l l e l I / O s c h e d u l e o f S R M . A s f a r a s w r i t e s g o , E a c h w r i t e i s e x e c u t e d w i t h f u l l  

w r i t e p a r a l l e l i s m a s s o o n a s t h e n e x t o u t p u t s t r i p e o f   D  f o r m a t t e d b l o c k s a r e r e a d y i n t h e o u t p u t b u e r   M 

. W i t h  

r e s p e c t t o r e a d s , t h e b a s i c i d e a i s t o r e a d i n   D  b l o c k s o f t h e s e t   S 

w h e n e v e r p o s s i b l e ; u s h i n g a f e w o f t h e h i g h e s t  

r a n k e d n o n - l e a d i n g b l o c k s i n   F 

, i f n e c e s s a r y .  

1 . A t t h e b e g i n n i n g , S R M r e a d s t h e r s t b l o c k f r o m e a c h o f t h e   R  r u n s i n t o t h e   R  i n t e r n a l b l o c k s o f   M 

u s i n g  

p a r a l l e l r e a d s .  

2 . U n t i l t h e m e r g e i s c o m p l e t e d , w h e n e v e r t h e I / O s y s t e m i s f r e e a t a t i m e   t  w h e n   D  u n o c c u p i e d b l o c k s a r e  

a v a i l a b l e i n   M 

, S R M d o e s t h e f o l l o w i n g :  

( a ) I f t h e r e a r e   D  u n o c c u p i e d i n t e r n a l b l o c k s i n t h e s e t   M 

a t t i m e   t  , a  P a r R e a d  

o p e r a t i o n i s i n i t i a t e d .  

( b ) E l s e i f t h e n u m b e r o f o c c u p i e d i n t e r n a l b l o c k s i n   M 

a t t i m e   t  i s  R  +  e x t r a   , w h e r e 1     e x t r a     D  , a n d i f  

O u t R a n k  

>  e x t r a   , a  P a r R e a d  

o p e r a t i o n i s i n i t i a t e d .  

( c ) E l s e i f t h e n u m b e r o f o c c u p i e d i n t e r n a l b l o c k s i n   M 

a t t i m e   t  i s  R  +  e x t r a   w h e r e 1     e x t r a     D  , a n d  

i f  O u t R a n k  

  e x t r a   , a  F l u s h  

(  e x t r a     O u t R a n k  

+ 1 ) o p e r a t i o n i s i n v o k e d , f o l l o w e d b y i n i t i a t i o n o f a  

P a r R e a d  

o p e r a t i o n .  

I n S t e p 2 c , t h e u s h e d o u t b l o c k s a r e t h e o n e s t h a t w i l l n o t b e u s e d i n t h e \ n e a r f u t u r e , " a s w e w i l l s e e i n t h e  

n e x t s e c t i o n . L e m m a 1 3 b e l o w e n s u r e s t h a t S R M m e r g i n g r u n s t o c o m p l e t i o n , n e e d i n g o n l y t h e s p e c i e d a m o u n t o f  

m e m o r y .  

L e m m a 1 3   C o n s i d e r a n y P a r R e a d  

o p e r a t i o n i n v o k e d b y S R M a t t i m e   t  . N o b l o c k n o t i n i n t e r n a l m e m o r y w h e n  

P a r R e a d  

h a s c o m p l e t e d b e g i n s p a r t i c i p a t i n g i n t h e m e r g e u n t i l   D  u n o c c u p i e d p h y s i c a l b l o c k s a r e a v a i l a b l e i n t h e  

s e t  M 

o f i n t e r n a l m e m o r y b l o c k s . T h i s e n s u r e s t h a t t h e r e w i l l b e e n o u g h s p a c e f o r t h e n e x t r e a d o p e r a t i o n t o b e g i n  

b e f o r e a n y o u t s i d e b l o c k b e g i n s p a r t i c i p a t i n g .  

P r o o f  : C o n s i d e r s t e p 2 a o f t h e a l g o r i t h m :   D  u n o c c u p i e d i n t e r n a l b l o c k s a r e a v a i l a b l e i n t h e s e t   M 

b e f o r e   P a r R e a d  

g e t s i n i t i a t e d . I n t h i s c a s e , t h e r e q u i r e m e n t o f h a v i n g   D  u n o c c u p i e d b l o c k s i n i n t e r n a l m e m o r y f o r t h e n e x t p a r a l l e l  

r e a d i s t r i v i a l l y m e t b y e x c h a n g e o p e r a t i o n s a s i n p o i n t 3 o f S e c t i o n 3 . 5 . 1 . C o n s i d e r s t e p 2 b o f t h e a l g o r i t h m i n w h i c h  

o n l y   D    e x t r a   u n o c c u p i e d b l o c k s a r e a v a i l a b l e i n   M 

b u t  O u t R a n k  

>  e x t r a    j u s t b e f o r e   P a r R e a d  

g e t s i n i t i a t e d . I n  

t h i s c a s e , b y d e n i t i o n o f   O u t R a n k  

,  e x t r a   b l o c k s t h a t b e l o n g t o t h e s e t   M 

 j u s t b e f o r e   P a r R e a d  

g e t s i n i t i a t e d b e g i n  

p a r t i c i p a t i o n b e f o r e a n y b l o c k n o t y e t i n m e m o r y a f t e r c o m p l e t i o n o f   P a r R e a d  

. T h e s e   e x t r a   b l o c k s b e c o m e   l e a d i n g  

b l o c k s o f t h e i r r e s p e c t i v e r u n s b e f o r e p a r t i c i p a t i n g . T h u s b y e x c h a n g e o p e r a t i o n s a s i n p o i n t 1 o f S e c t i o n 3 . 5 . 1 ,   M 

g e t s   e x t r a   u n o c c u p i e d i n t e r n a l m e m o r y b l o c k s f r o m   M 

. T h i s m e a n s t h a t b y m e a n s o f e x c h a n g e o p e r a t i o n s a s i n  

3 8 

Page 52: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 52/203

p o i n t 3 o f S e c t i o n 3 . 5 . 1 ,   M 

h a s  D    e x t r a   +  e x t r a   =  D  u n o c c u p i e d b l o c k s b e f o r e p a r t i c i p a t i o n o f a n y b l o c k t h a t  

i s s t i l l o n d i s k a f t e r   P a r R e a d  

i s c o m p l e t e d . S i m i l a r l y , i n c a s e o f s t e p 2 c o f t h e a l g o r i t h m ,   O u t R a n k  

  1 i n t e r n a l  

b l o c k s o f   M 

b e c o m e u n o c c u p i e d o w i n g t o p a r t i c i p a t i o n w h i l e   e x t r a     O u t R a n k  

+ 1 b l o c k s o f   M 

a r e u s h e d . T h e s e  

u n o c c u p i e d b l o c k s , a l o n g w i t h t h e   D    e x t r a   u n o c c u p i e d b l o c k s a l r e a d y p r e s e n t i n   M 

e n s u r e t h a t t h e s e t   M 

d o e s  

o b t a i n   D  u n o c c u p i e d b l o c k s b e f o r e a n y o u t s i d e b l o c k b e g i n s p a r t i c i p a t i n g i n t h e m e r g e . T h i s c o m p l e t e s t h e p r o o f o f  

t h e l e m m a .  

L e m m a 1 3 s h o w s t h a t a   P a r R e a d   o p e r a t i o n c a n b e i n i t i a t e d b e f o r e a n y b l o c k b r o u g h t i n b y t h a t o p e r a t i o n b e g i n s  

p a r t i c i p a t i o n . T h u s t h e r e i s g e n u i n e p r e f e t c h i n g a b i l i t y , w h i c h i s u s e f u l i n o v e r l a p p i n g I / O o p e r a t i o n s w i t h i n t e r n a l  

p r o c e s s i n g .  

3 . 6 U s i n g P h a s e s t o C o u n t    P a r R e a d   O p e r a t i o n s    

F o r t h e p u r p o s e o f a n a l y s i s , w e b r e a k t h e p r o c e s s o f m e r g i n g   R  r u n s c o m p r i s i n g a t o t a l o f   N 

r e c o r d s i n t o a s e q u e n c e  

o f  p h a s e s  , a n d w e u p p e r b o u n d t h e e x p e c t e d n u m b e r o f r e a d o p e r a t i o n s r e q u i r e d d u r i n g a p h a s e . T h e o v e r a l l b o u n d  

o n t h e m e r g e p r o c e s s c a n t h e n b e c o m p u t e d u s i n g t h e l i n e a r i t y o f e x p e c t a t i o n s .  

C o n s i d e r t h e s e t o f a l l b l o c k s e x c e p t b l o c k s i n t h e i n i t i a l s e t . E a c h s u c h b l o c k c a n p a r t i c i p a t e i n t h e m e r g e o n l y  

a f t e r i t s p r e c e d i n g b l o c k s h a v e c e a s e d t o p a r t i c i p a t e , s o t h a t i f t h e   i  t h b l o c k o f a r u n i s c u r r e n t l y p a r t i c i p a t i n g , a t  

l e a s t (  i    1 )  B  r e c o r d s f r o m t h a t r u n h a v e a l r e a d y b e e n o u t p u t .  

D e n i t i o n 1 1   C o n s i d e r t h e s e t   R 

o f a l l b l o c k s o f a l l r u n s e x c l u d i n g t h e i n i t i a l b l o c k o f e a c h r u n . T h e   p a r t i c i p a t i o n  

i n d e x   o f a n y b l o c k i n   R 

i s  i  i f i t i s t h e   i  t h b l o c k , i n c h r o n o l o g i c a l o r d e r , t o b e g i n p a r t i c i p a t i n g i n t h e m e r g e , w h e r e  

1    i   

  R B 

. W e d e n o t e b y s e t   P 

, w h e r e 1     j   

  R B 

R B 

, t h e s u b s e t o f   R 

c o n s i s t i n g o f b l o c k s w h o s e  

p a r t i c i p a t i n g i n d i c e s a r e i n t h e r a n g e (  j    1 )  R  + 1  ; j R  ]

U s i n g p a r a l l e l r e a d s , S R M t r i e s t o l l t h e   R  i n t e r n a l b l o c k s o f   M 

u s i n g F D S . E v e r y i n c o m i n g b l o c k p r o v i d e s n e w  

i m p l a n t e d i n f o r m a t i o n . W h e n a b l o c k w i t h s m a l l p a r t i c i p a t i o n i n d e x i s o n d i s k w h i l e m e m o r y i s f u l l , w e b r i n g i t i n ,  

b y u s h i n g b l o c k s t h a t a r e   s u r e l y n o t   a m o n g t h e n e x t   R  b l o c k s t o b e g i n p a r t i c i p a t i n g i n t h e m e r g e , a s L e m m a 1 4  

s h o w s .  

L e m m a 1 4   C o n s i d e r a u s h F l u s h  

a t t i m e   t  . T h e   R  +  O u t R a n k  

  1  s m a l l e s t - r a n k e d b l o c k s o f   F 

( i n  M 

) d o n o t  

g e t u s h e d o u t : t h e y r e m a i n i n   M 

a f t e r t h e u s h c o m p l e t e s .  

P r o o f  : S i n c e   F l u s h  

i s i n v o k e d a t t i m e   t  , i t m e a n s t h a t t h e n u m b e r o f b l o c k s i n   M 

i s  R  +  e x t r a   ( 1    e x t r a     D  ) 

a n d 0   <  O u t R a n k  

  e x t r a   . B y d e n i t i o n o f t h e   F l u s h  

o p e r a t i o n ,   e x t r a     O u t R a n k  

+ 1 b l o c k s c o r r e s p o n d i n g t o t h e  

e x t r a     O u t R a n k  

+ 1 h i g h e s t r a n k e d b l o c k s i n t h e s e t o f a l l b l o c k s o c c u p y i n g i n t e r n a l b l o c k s o f   M 

a r e u s h e d o u t .  

T h i s m e a n s t h a t   R  +  O u t R a n k  

  1 o f t h e l o w e s t r a n k i n g b l o c k s r e m a i n i n i n t e r n a l m e m o r y e v e n a f t e r t h e   F l u s h  

o p e r a t i o n . H e n c e t h e l e m m a i s p r o v e d .  

3 9 

Page 53: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 53/203

T h e m e r g e p r o c e e d s i n a s e q u e n c e o f p h a s e s , e a c h c o n t r i b u t i n g   R  b l o c k s t o t h e o u t p u t r u n .  

D e n i t i o n 1 2   T h e r s t p h a s e b e g i n s a t t h e t i m e    p 

o f t h e l a s t   P a r R e a d  

r e a d o p e r a t i o n i n v o k e d i n S t e p 1 o f S R M .  

T h e  j  t h p h a s e e n d s a t t h e t i m e    p 

o f t h e r e a d   P a r R e a d  

s u c h t h a t a n y b l o c k   b  2 R 

w i t h p a r t i c i p a t i o n i n d e x   i 

w h e r e   i 

  j R  , h a s b e e n r e a d i n t o m e m o r y ( a t l e a s t o n c e ) f r o m d i s k b y s o m e   P a r R e a d  

s u c h t h a t   t     p 

. T h e  

P a r R e a d  

r e a d o p e r a t i o n s s u c h t h a t    p 

j    1 

< t     p 

a r e t h e   r e a d s f o r m i n g t h e   j  t h p h a s e   , a n d t h e s e t   P 

d e n e d a b o v e  

i s t h e   s e t o f b l o c k s f o r m i n g t h e   j  t h p h a s e .  

T h e n e x t s t e p i s t o s h o w t h a t w h e n t h e   j  t h p h a s e i s o v e r , b l o c k s w i t h p a r t i c i p a t i o n i n d i c e s s m a l l e r t h a n   j R  h a v e  

a l r e a d y b e e n \ t a k e n c a r e o f . "  

L e m m a 1 5   A f t e r t h e r e a d P a r R e a d  

a t t i m e    p 

i s c o m p l e t e , t h e f o l l o w i n g i n v a r i a n t s h o l d :  

1 . N o b l o c k s t i l l o n d i s k h a s a p a r t i c i p a t i n g i n d e x l e s s t h a n   j R  + 1 

2 . N o b l o c k   b  w i t h p a r t i c i p a t i n g i n d e x   i 

  (  j  + 1 )  R  c a n b e u s h e d o u t b y a n y F l u s h  

, w h e r e   t > p 

P r o o f  : W e p r o v e t h e c l a i m s b y i n d u c t i o n . F o r t h e b a s e c a s e   j  = 1 , o b s e r v e t h a t b y t i m e    p 

, a l l b l o c k s h a v i n g  

p a r t i c i p a t i o n i n d i c e s a t m o s t   R  a r e r e a d i n a t l e a s t o n c e . B y L e m m a 1 4 , n o n e o f t h e s e b l o c k s c o u l d b e u s h e d o u t a t  

a n y t i m e   t     p 

b e c a u s e t h e y w o u l d b e a m o n g t h e   R  s m a l l e s t r a n k e d b l o c k s o f   M 

, t h u s p r o v i n g t h e c l a i m . W e n o w  

c o n s i d e r t h e s e c o n d c l a i m f o r   j  = 1 . S u p p o s e t h e r e i s a u s h   F l u s h  

a t a n y t i m e   t > p 

. B y t h e p r e v i o u s c l a i m , i f   X 

i s t h e n u m b e r o f b l o c k s i n   M 

t h a t h a v e p a r t i c i p a t i n g i n d i c e s a t m o s t   R  , t h e n   O u t R a n k  

> X  . B y L e m m a 1 4 , t h e  

R  +  O u t R a n k  

  1 s m a l l e s t r a n k e d b l o c k s a t t i m e   t  r e m a i n i n   M 

a f t e r t h e u s h . O f t h e s e , a t m o s t   X    O u t R a n k  

  1 

b l o c k s h a v e r a n k s s m a l l e r t h a n   R  . T h u s i f t h e r e i s a n y b l o c k   b  w i t h r a n k a t m o s t 2  R  a t t i m e   t  , t h e n   b  m u s t b e a m o n g  

t h e  R  +  O u t R a n k  

  1 s m a l l e s t r a n k e d b l o c k s . H e n c e t h e b a s e c a s e i s p r o v e d f o r b o t h c l a i m s .  

S u p p o s e n o w t h a t b o t h c l a i m s a r e t r u e f o r s o m e   j    1 . T h e n b y i n d u c t i v e h y p o t h e s i s f o r C l a i m 1 , w h e n t h e r e a d  

P a r R e a d  

j    1 

a t   p 

j    1 

c o m p l e t e s , t h e s m a l l e s t p a r t i c i p a t i n g i n d e x o f a n y b l o c k s t i l l o n d i s k i s (  j    1 )  R  + 1 . B y t h e  

i n d u c t i v e h y p o t h e s i s f o r C l a i m 2 n o n e o f t h e b l o c k s w i t h p a r t i c i p a t i n g i n d i c e s a t m o s t   j R  c a n g e t u s h e d a t a n y t i m e  

t > p 

j    1 

. B y d e n i t i o n , a l l b l o c k s w i t h i n d i c e s a t m o s t   j R  a r e r e a d i n b y    p 

. S i n c e n o n e o f t h e m c a n g e t u s h e d  

a f t e r    p 

j    1 

, t h e r s t c l a i m i s t r u e f o r   j  . T h e s e c o n d c l a i m f o r   j  f o l l o w s b y a n a r g u m e n t i d e n t i c a l t o t h e a r g u m e n t f o r  

i t s b a s e c a s e .  

W e a r e l e d i m m e d i a t e l y t o t h e f o l l o w i n g l e m m a t h a t g i v e s t h e n u m b e r o f b l o c k s i n t h e o u t p u t r u n o f t h e m e r g e  

a t t h e e n d o f t h e r s t   j  p h a s e s .  

L e m m a 1 6   A t l e a s t   j R B  r e c o r d s f r o m b l o c k s o f t h e s e t   R 

a r e a l r e a d y i n t h e m e r g e d o u t p u t o f S R M   b e f o r e   a n y 

b l o c k s t i l l o n d i s k a f t e r t i m e    p 

b e g i n s p a r t i c i p a t i n g i n t h e m e r g e . T h u s a l l r e a d s P a r R e a d  

s u c h t h a t   t     p 

a n d t h e  

r e a d s   I 

r e q u i r e d i n t h e s t e p 1 o f S R M c a n b e c h a r g e d t o t h e s e   j R B  r e c o r d s i n t h e o u t p u t o f S R M .  

4 0 

Page 54: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 54/203

W e w i s h t o o b t a i n a h a n d l e o n t h e n u m b e r o f r e a d o p e r a t i o n s   P a r R e a d  

w h e r e    p 

j    1 

< t     p 

( t h e r e a d s a s s o c i a t e d  

w i t h t h e   j  t h p h a s e ) . W e w i l l s h o w t h a t t h i s n u m b e r i s t h e l a r g e s t n u m b e r o f b l o c k s i n   P 

t h a t n e e d t o b e r e a d i n  

f r o m a n y p a r t i c u l a r d i s k .  

D e n i t i o n 1 3   C o n s i d e r t h e b l o c k s o f t h e s e t   P 

j  + 1 

 j u s t a f t e r   P a r R e a d  

i s c o m p l e t e d . S u c h a b l o c k   b  i s s a i d t o b e  

o n  l e v e l   0 i f i t i s a l r e a d y i n i n t e r n a l m e m o r y a n d l e v e l   h  i f i t i s t h e   h  t h s m a l l e s t b l o c k o n i t s d i s k a t t h a t t i m e . L e t  

j  + 1 

d e n o t e t h e h i g h e s t l e v e l o f a n y b l o c k o f   P 

j  + 1 

. I n t h e c a s e o f t h e r s t p h a s e , l e t   L 

b e t h e h i g h e s t l e v e l o f a n y  

b l o c k o f   P 

a f t e r S t e p 1 o f t h e a l g o r i t h m i n S e c t i o n 3 . 5 . 5 .  

W e p r o v e t h e f o l l o w i n g c h a r a c t e r i z a t i o n o f t h e n u m b e r o f r e a d s a s s o c i a t e d w i t h t h e (  j  + 1 ) s t p h a s e .  

L e m m a 1 7   T h e  L 

j  + 1 

t h r e a d o f S R M   a f t e r   t i m e    p 

i s d o n e a t t i m e    p 

j  + 1 

P r o o f  : T h e p r o o f f o l l o w s f r o m L e m m a 1 5 . N o b l o c k w i t h p a r t i c i p a t i o n i n d e x a t m o s t   j R  i s s t i l l o n d i s k a f t e r t h e r e a d  

a t   p 

c o m p l e t e s . M o r e o v e r n o b l o c k w i t h p a r t i c i p a t i o n i n d e x a t m o s t (  j  + 1 )  R  c a n b e u s h e d o u t a f t e r    p 

. C l e a r l y  

t h e n , s i n c e a n y   P a r R e a d  

o p e r a t i o n r e a d s i n t h e s m a l l e s t b l o c k f r o m e v e r y d i s k a t t i m e   t  , w e h a v e t h e n i c e p r o p e r t y  

t h a t   a l l b l o c k s o f   P 

j  + 1 

t h a t a r e a t t h e   h  t h l e v e l w i l l g e t r e a d b y t h e   h  t h r e a d a f t e r    p 

, n e v e r t o g e t u s h e d o u t . T h i s  

p r o v e s t h e l e m m a .  

W e c a n n o w r e l a t e p r o g r e s s i n t h e m e r g e t o t h e n u m b e r o f r e a d o p e r a t i o n s i n v o l v e d i n p h a s e s b y m e a n s o f t h e  

f o l l o w i n g l e m m a t h a t f o l l o w s f r o m L e m m a s 1 7 a n d 1 6 .  

L e m m a 1 8   T h e r s t   I 

P  

1    i    j 

r e a d s o f S R M c a n b e c h a r g e d t o a t l e a s t   j R B  r e c o r d s i n t h e o u t p u t o f t h e  

m e r g e , w h e r e   I 

i s t h e n u m b e r o f r e a d s S R M i n c u r s i n S t e p 1 o f t h e a l g o r i t h m i n S e c t i o n 3 . 5 . 5 . T h e t o t a l n u m b e r  

o f I / O r e a d o p e r a t i o n s r e q u i r e d t o c o m p l e t e t h e m e r g e i s g i v e n b y t h e a b o v e s u m w i t h   j  = 

= B    R 

I n t h e n e x t s e c t i o n w e g i v e a b o u n d o n t h e e x p e c t a t i o n o f   L 

w i t h r e s p e c t t o t h e r a n d o m i z a t i o n i n v o l v e d i n t h e  

c h o i c e o f d i s k s f o r t h e i n i t i a l b l o c k s o f t h e r u n s . T h e r e a f t e r , L e m m a 1 8 c a n b e u s e d t o o b t a i n t h e o v e r a l l b o u n d o n  

t h e n u m b e r o f r e a d s i n v o l v e d i n S R M .  

3 . 7 P r o b a b i l i s t i c A n a l y s i s    

C o n s i d e r a n y a r b i t r a r y   R  r u n s i n p u t t o S R M . T h e i n i t i a l b l o c k o f e a c h r u n i s p l a c e d o n a d i s k c h o s e n w i t h a u n i f o r m  

p r o b a b i l i t y o f 1   = D  i n d e p e n d e n t l y o f o t h e r r u n s . S i n c e r u n s a r e c y c l e d a c r o s s d i s k s , t h e p o s i t i o n o f t h e i n i t i a l b l o c k  

o f t h e r u n d e t e r m i n e s t h e p o s i t i o n o f t h e o t h e r b l o c k s o f t h e r u n . A s a r e s u l t , f o r a n y   j  , t h e   j  t h b l o c k o f a r u n i s o n  

a n y o n e o f t h e   D  d i s k s , e a c h w i t h p r o b a b i l i t y 1  = D  , d e p e n d i n g o n l y u p o n t h e d i s k c o n t a i n i n g t h a t r u n ' s i n i t i a l b l o c k .  

4 1 

Page 55: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 55/203

L e m m a 1 9   C o n s i d e r t h e   i  t h p h a s e a n d t h e r e l a t e d s e t   P 

o f b l o c k s s u c h t h a t   1    i   

  R B 

R B 

. L e t   n 

d e n o t e t h e n u m -  

b e r o f b l o c k s f r o m t h e   j  t h r u n i n   P 

, s o t h a t  

P  

0    j    R    1 

=  R  . L e t   C 

d e n o t e t h e o r d e r e d l i s t   h  b 

j ;  0 

; b 

j ;  1 

; : : : ; b  

j ; n 

  1 

o f t h e   n 

b l o c k s o f r u n   j  i n  P 

, w h e r e t h e o r d e r i s t h e c h r o n o l o g i c a l o r d e r o f p a r t i c i p a t i o n . L e t   D 

d e n o t e t h e d i s k  

f r o m w h i c h t h e b l o c k   b 

j ;  0 

o r i g i n a t e s , f o r e a c h r u n   j  ,  0    j    R    1  . T h e n t h e d i s k s   D 

a r e i n d e p e n d e n t l y d i s t r i b u t e d ,  

e a c h w i t h u n i f o r m p r o b a b i l i t y o v e r t h e s e t   f  0  ;  1  ; : : : ; D     1  g  o f  D  d i s k s .  

D e n i t i o n 1 4   W e c a l l e a c h   C 

a  c h a i n   o f l e n g t h   n 

o f c o n t i g u o u s b l o c k s o f r u n   j  . T h e d i s k c o r r e s p o n d i n g t o a n y  

g i v e n b l o c k o f   C 

i s d e t e r m i n e d b y t h e d i s k o f t h e l e a d b l o c k   b 

j ;  0 

o f  C 

W e r e c a l l t h a t t h e n u m b e r o f r e a d s   L 

i n t h e   i  t h p h a s e i s t h e m a x i m u m l e v e l o f a n y b l o c k o n a n y d i s k a t t i m e  

 p 

i    1 

D e n i t i o n 1 5   C o n s i d e r t h e s e t   P 

. L e t   L 

b e t h e m a x i m u m l e v e l o f a n y b l o c k o f  P 

o n d i s k , c o n s i d e r i n g a l l o f   P 

' s 

b l o c k s o n t h e i r r e s p e c t i v e o r i g i n a l d i s k s .  

I n t h e f o l l o w i n g s u b s e c t i o n s , w e w i l l b e a b l e t o b o u n d   E  (  L 

) . T h e f o l l o w i n g l e m m a s h o w s t h a t   L 

i s a n o v e r e s t i m a t e  

o f  L 

, s o w e g e t a b o u n d o n   L 

t o o .  

L e m m a 2 0   W i t h   L 

a n d  L 

d e n e d a s a b o v e , w e h a v e   L 

  L 

a n d E   (  L 

)    E  (  L 

3 . 7 . 1 T h e D e p e n d e n t O c c u p a n c y P r o b l e m  

I n t h i s s e c t i o n , w e d e n e t h e   d e p e n d e n t o c c u p a n c y   p r o b l e m , w h i c h a l o n g w i t h t h e w e l l - s t u d i e d   c l a s s i c a l o c c u p a n c y  

p r o b l e m ( a s p e c i a l c a s e o f t h e f o r m e r ) , i s d i r e c t l y r e l a t e d t o t h e I / O p e r f o r m a n c e o f S R M .  

I n t h e   c l a s s i c a l o c c u p a n c y   p r o b l e m o f p a r a m e t e r s   f  N 

; D  g  ,  N 

b a l l s a r e t h r o w n i n t o   D  b i n s i n d e p e n -  

d e n t l y e a c h w i t h u n i f o r m p r o b a b i l i t y o f 1  = D  o f f a l l i n g i n t o a n y b i n . W e d e n o t e t h e a s y m p t o t i c a l l y t i g h t  

e x p r e s s i o n f o r t h e e x p e c t a t i o n o f t h e m a x i m u m n u m b e r o f b a l l s i n a n y b i n V F 9 0 , K S C 7 8 ] b y   C  (  N 

; D  )

I n t h e   d e p e n d e n t o c c u p a n c y   p r o b l e m , w e c o n s i d e r   D  b i n s b u t i n s t e a d o f b a l l s , w e c o n s i d e r   C  c h a i n s o f  

b a l l s , s u c h t h a t t h e t o t a l n u m b e r o f b a l l s s u m m e d o v e r t h e   C  c h a i n s , i s   N 

. A c h a i n o f l e n g t h    ̀ c o n s i s t s  

o f   ̀ b a l l s l i n k e d t o g e t h e r i n a c h a i n . A c h a i n o f l e n g t h    ̀ i s s a i d t o f a l l o r g e t t h r o w n i n t o a b i n   s  , w h e r e  

0    s    D    1 , i f t h e l e a d i n g b a l l o f t h e c h a i n f a l l s i n t o b i n   s  a n d t h e r e m a i n i n g    ̀   1 b a l l s o f t h a t c h a i n  

a r e d e p o s i t e d c y c l i c a l l y i n t o b i n s ; t h a t i s t h e   i  - t h b a l l ( w i t h 0     i     ̀   1 ) o f t h a t c h a i n f a l l s i n b i n  

(  s  +  i  ) m o d   D  . S i n c e t h e s u m o f t h e n u m b e r o f b a l l s f r o m a l l t h e c h a i n s i s e x a c t l y   N 

, t h e m a x i m u m  

l e n g t h o f a c h a i n i s   N 

. D e n o t i n g a s   n 

, t h e n u m b e r o f c h a i n s o f l e n g t h   j  , w e h a v e  

P  

1    j    N 

=  C  a n d 

P  

1    j    N 

j n 

=  N 

. W e a r e i n t e r e s t e d i n t h e e x p e c t a t i o n o f t h e m a x i m u m o c c u p a n c y o f a n y b i n w h e n  

e a c h o f t h e   C  c h a i n s g e t s i n d e p e n d e n t l y a n d i d e n t i c a l l y r a n d o m l y t h r o w n , s u c h t h a t t h e p r o b a b i l i t y o f  

e a c h c h a i n f a l l i n g i n t o a n y o f t h e   D  b i n s i s 1  = D 

4 2 

Page 56: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 56/203

(b) Classical Occupancy(a) Dependent Occupancy

F i g u r e 3 . 2  : ( a ) D e p e n d e n t o c c u p a n c y i n s t a n c e w i t h   N 

= 1 2 ,  C  = 5 ,  D  = 4 . A r r o w s i n d i c a t e t h e c y c l i c a l o r d e r  

o f b l o c k s i n t h e s a m e c h a i n . T h e m a x i m u m o c c u p a n c y i s 4 , a s r e a l i z e d i n t h e s e c o n d b i n . ( b ) C l a s s i c a l o c c u p a n c y  

i n s t a n c e w i t h   N 

= 1 2 ,  D  = 4 . B l o c k s f a l l i n d e p e n d e n t l y o f e a c h o t h e r . T h e m a x i m u m o c c u p a n c y i s 5 , a s r e a l i z e d i n  

t h e s e c o n d b i n .  

T h e c l a s s i c a l o c c u p a n c y p r o b l e m i s t h e s p e c i a l c a s e o f t h e d e p e n d e n c y o c c u p a n c y p r o b l e m w h e n   C  =  N 

a n d 

=  N 

w i t h   n 

= 0 f o r 1   < j    N 

. F i g u r e 2 a b o v e s h o w s o n e i n s t a n c e o f b o t h t y p e s o f p r o b l e m s f o r   N 

= 1 2 ,  

D  = 4 , a n d w i t h   C  = 5 f o r t h e d e p e n d e n t o c c u p a n c y p r o b l e m . T h e g u r e u s e s s q u a r e b l o c k s i n s t e a d o f b a l l s a n d  

u s e s a r r o w s t o c o n n e c t t o g e t h e r b l o c k s f r o m t h e s a m e c h a i n .  

3 . 7 . 2 A s y m p t o t i c E x p a n s i o n s o f t h e M a x i m u m O c c u p a n c y  

O u r g o a l h e r e i s t o o b t a i n a b o u n d o n t h e e x p e c t e d m a x i m u m o c c u p a n c y i n d e p e n d e n t o c c u p a n c y p r o b l e m s . A s  

m e n t i o n e d e a r l i e r , t h e l e a d i n g t e r m s i n o u r u p p e r b o u n d s f o r t h i s q u a n t i t y a r e t h e s a m e a s t h o s e i n t h e w e l l - k n o w n  

b o u n d s f o r   C  (  N 

; D  ) i n t h e c l a s s i c a l o c c u p a n c y p r o b l e m K S C 7 8 ] . W e c o n j e c t u r e t h a t t h e e x p e c t e d m a x i m u m c l a s s i c a l  

o c c u p a n c y   C  (  N 

; D  ) i s a n   u p p e r b o u n d   f o r t h e m a x i m u m d e p e n d e n t o c c u p a n c i e s .  

C o n s i d e r t h e f o l l o w i n g i n t u i t i o n : i n d e p e n d e n t o c c u p a n c y , a c h a i n o f l e n g t h    ̀ r e s u l t s i n a   m a x i m u m o c c u p a n c y  

o f  d  ` = D  e  b e c a u s e o f t h e c o n s t r a i n t t h a t b a l l s o f t h e c h a i n a r e c y c l i c a l l y d i s t r i b u t e d a m o n g t h e   D  b i n s . T h e c y c l i c  

d i s t r i b u t i o n t e n d s t o r e d u c e t h e v a r i a n c e o f t h e i n d i v i d u a l o c c u p a n c i e s , t h u s l o w e r i n g t h e m a x i m u m o c c u p a n c y . I n  

c l a s s i c a l o c c u p a n c y , t h e   a v e r a g e o c c u p a n c y   o f a n y b i n w h e n    ̀ b a l l s a r e i n d e p e n d e n t l y a n d u n i f o r m l y r a n d o m l y t h r o w n  

i s  ` = D  b u t m o r e t h a n   ` = D  o f t h e m c a n e a s i l y f a l l i n t o t h e s a m e b i n .  

F o r i n s t a n c e , i n F i g u r e 2 , i t c a n b e s e e n t h a t p a i r s o f b l o c k s f r o m t h e s a m e c h a i n t h a t a r e f o r c e d t o o c c u p y d i e r e n t  

b i n s i n t h e d e p e n d e n t o c c u p a n c y p r o b l e m m a y o c c u p y t h e s a m e b i n i n t h e c l a s s i c a l v e r s i o n o f t h e o c c u p a n c y p r o b l e m .  

I n t u i t i v e l y , i n d e p e n d e n c e i n c r e a s e s t h e e x p e c t e d m a x i m u m o c c u p a n c y .  

4 3 

Page 57: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 57/203

I n B G V 9 7 ] , o u r a p p r o a c h w a s t o u s e t h e w e l l k n o w n b o u n d s f o r t h e c l a s s i c a l m a x i m u m o c c u p a n c y t o b o u n d  

d e p e n d e n t m a x i m u m o c c u p a n c i e s ; h o w e v e r , t h e p r o o f o f t h e b o u n d w e g a v e w a s e r r o n e o u s . W e d o b e l i e v e , h o w e v e r ,  

t h a t t h e b o u n d i s c o r r e c t , a s w e c o n j e c t u r e a b o v e . I n t h i s c h a p t e r , w e i n s t e a d d e r i v e a d i r e c t b o u n d o n t h e e x p e c t a t i o n  

o f t h e m a x i m u m d e p e n d e n t o c c u p a n c y v i a i n t e r e s t i n g a n a l y t i c a l a n d a s y m p t o t i c t e c h n i q u e s , a n d a s a r e s u l t o u r p r o o f  

i s i n d e p e n d e n t o f t h e c l a s s i c a l o c c u p a n c y b o u n d s o f K S C 7 8 ] .  

A s a r s t s t e p t o w a r d o b t a i n i n g a n u p p e r b o u n d o n t h e m a x i m u m d e p e n d e n t o c c u p a n c y , w e r s t s t a t e a n d p r o v e a  

s i m p l e l e m m a t h a t s h o w s t h a t i t w i l l s u c e f o r u s t o f o c u s o n d e p e n d e n t p r o b l e m s h a v i n g n o c h a i n s o f l e n g t h g r e a t e r  

t h a n   D  : 

L e m m a 2 1   C o n s i d e r a n y d e p e n d e n t o c c u p a n c y p r o b l e m   X  i n v o l v i n g   C  c h a i n s ,   D  b i n s a n d a t o t a l o f   N 

b a l l s s u c h  

t h a t o n e o r m o r e c h a i n s i n   X  a r e o f l e n g t h g r e a t e r t h a n   D  . L e t   X 

m a x 

d e n o t e t h e m a x i m u m o c c u p a n c y r a n d o m  

v a r i a b l e o f   X  . T h e n t h e r e i s a d e p e n d e n t o c c u p a n c y p r o b l e m   X 

 

i n v o l v i n g a t o t a l o f   N 

b a l l s a n d   D  b i n s s u c h  

t h a t n o c h a i n i n v o l v e d i n   X 

 

h a s l e n g t h g r e a t e r t h a n   D  a n d E     X 

m a x 

] =  E    X 

 

m a x 

]  , w h e r e   X 

 

m a x 

i s t h e m a x i m u m  

o c c u p a n c y r a n d o m v a r i a b l e f o r   X 

 

P r o o f   : C o n s i d e r t h e d e p e n d e n t o c c u p a n c y p r o b l e m   X 

o b t a i n e d b y r e p l a c i n g a c h a i n   C 

o f  X  o f l e n g t h   a D  +  b  , w h e r e  

a    1 a n d 0     b < D  , w i t h , i n s t e a d ,   a  c h a i n s o f l e n g t h   D  a n d o n e c h a i n o f l e n g t h   b  . L e t   X 

m a x 

d e n o t e t h e m a x i m u m  

o c c u p a n c y r a n d o m v a r i a b l e o f   X 

. W e c l a i m t h a t t h e o c c u p a n c y d i s t r i b u t i o n o f   N 

b a l l s a m o n g t h e   D  b i n s i n t h e  

p r o b l e m   X  i s e x a c t l y t h e s a m e a s t h a t o f t h e p r o b l e m   X 

T o s e e t h i s , r s t c o n s i d e r t h e o c c u p a n c y d i s t r i b u t i o n o f b a l l s o f c h a i n   C 

a m o n g t h e b i n s w h e n i t i s r a n d o m l y  

t h r o w n i n t o t h e b i n s . L e t u s s u p p o s e t h a t 1     b < D  . W h e n t h e c h a i n   C 

g e t s t h r o w n ,   b  c o n t i g u o u s l y p l a c e d b i n s  

n u m b e r e d , s a y   s ;  (  s  + 1 ) m o d   D ; : : : ;  (  s  +  b    1 ) m o d   D  w i t h 0     s    D    1 , e a c h g e t   a  + 1 b a l l s . T h e o t h e r   D    b 

b i n s e a c h g e t e x a c t l y   a  b a l l s . T h e r e a r e   D  d i s t i n c t s e t s   S 

; S 

; : : : ; S  

D    1 

, e a c h s e t c o n s i s t i n g o f   b  c o n t i g u o u s l y p l a c e d  

b i n s . L e t u s d e n o t e b y   S 

t h e s e t o f b i n s o t h e r t h a n t h o s e i n   S 

. T h e n f o r 0     i    D    1 , t h e p r o b a b i l i t y t h a t s e t   S 

' s 

b  b i n s e a c h r e c e i v e   a  + 1 b a l l s o f   C 

w h e r e a s b i n s i n t h e s e t   S 

e a c h r e c e i v e   a  b a l l s i s e x a c t l y 1   = D 

W e n o w c o n s i d e r t h e o c c u p a n c y d i s t r i b u t i o n o f b a l l s w h e n   a  c h a i n s e a c h o f l e n g t h   D  a n d o n e c h a i n o f l e n g t h   b 

g e t r a n d o m l y t h r o w n i n t o t h e b i n s . I t i s n o t h a r d t o s e e t h a t t h e o c c u p a n c y d i s t r i b u t i o n o f b a l l s t h a t r e s u l t s f r o m  

t h r o w i n g i n t h e s e   a  + 1 c h a i n s i n d e p e n d e n t l y a n d u n i f o r m l y r a n d o m l y a m o n g t h e b i n s i s p r e c i s e l y t h e o c c u p a n c y  

d i s t r i b u t i o n o f b a l l s t h a t r e s u l t s f r o m t h r o w i n g c h a i n   C 

, d e s c r i b e d i n t h e p r e v i o u s p a r a g r a p h . E v e n i n t h e c a s e w h e n  

b  = 0 , t h e o c c u p a n c y d i s t r i b u t i o n o f b a l l s t h a t r e s u l t s f r o m t h r o w i n g i n c h a i n   C 

i s t h e s a m e a s t h a t o b t a i n e d f r o m  

t h r o w i n g i n   a  c h a i n s o f l e n g t h   D  e a c h .  

M o r e o v e r , t h e t w o o c c u p a n c y d i s t r i b u t i o n s t h a t r e s u l t f r o m t h e o t h e r b a l l s a r e o b v i o u s l y i d e n t i c a l s i n c e t h e s a m e  

C    1 c h a i n s a r e i n v o l v e d i n b o t h t h e d i s t r i b u t i o n s . B y i n d e p e n d e n c e a n d t h e c l a i m i n t h e p r e v i o u s p a r a g r a p h s , t h e  

o c c u p a n c y d i s t r i b u t i o n o f b a l l s i n p r o b l e m   X  i s t h e s a m e a s t h e o n e i n p r o b l e m   X 

4 4 

Page 58: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 58/203

S i n c e w e c a n r e p l a c e o n e c h a i n (  C 

) o f p r o b l e m   X  w i t h a m u l t i p l e n u m b e r o f c h a i n s o f l e n g t h a t m o s t   D  t o o b t a i n  

a p r o b l e m   X 

w i t h t h e s a m e o c c u p a n c y d i s t r i b u t i o n o f b a l l s , w e c a n r e p e a t t h i s p r o c e s s o n   X 

t o r e p l a c e o n e m o r e  

c h a i n o f l e n g t h g r e a t e r t h a n   D  t o o b t a i n a n o t h e r p r o b l e m   X 

, a n d s o o n , r e t a i n i n g t h e s a m e o c c u p a n c y d i s t r i b u t i o n  

o f b a l l s a s i n t h e o r i g i n a l p r o b l e m   X  . W e c o n t i n u e t h i s p r o c e s s u n t i l w e h a v e a d e p e n d e n c y p r o b l e m w i t h n o c h a i n o f  

l e n g t h g r e a t e r t h a n   D  a n d d e n o t e t h i s p r o b l e m a s   X 

 

. S i n c e t h e o c c u p a n c y d i s t r i b u t i o n s o f   X  a n d  X 

 

a r e i d e n t i c a l ,  

s o a r e t h e i r e x p e c t e d m a x i m u m o c c u p a n c i e s . T h i s p r o v e s t h e l e m m a .  

W e n o w u s e t h e a b o v e l e m m a i n p r o v i n g a n u p p e r b o u n d o n t h e e x p e c t e d m a x i m u m o c c u p a n c y o f d e p e n d e n t  

o c c u p a n c y p r o b l e m s i n v o l v i n g a t o t a l o f   N 

b a l l s a n d   D  b i n s .  

T h e o r e m 7   C o n s i d e r a n y d e p e n d e n t o c c u p a n c y p r o b l e m   X 

t h a t i n v o l v e s   C 

c h a i n s ,   D  b i n s a n d a t o t a l o f   N 

b a l l s  

f r o m t h e   C 

c h a i n s . L e t   X 

m a x 

d e n o t e t h e m a x i m u m o c c u p a n c y r a n d o m v a r i a b l e f o r   X 

. L e t   N 

=  k D  , f o r   k >  0 

T h e n  

1 . I f   k  i s a c o n s t a n t a s   D  ! 1  , 

E    X 

m a x 

]   

l n  D 

l n l n   D 

  

1 + 

l n l n l n   D 

l n l n   D 

1 + l n   k 

l n l n   D 

+  O 

  

( l o g l o g l o g   D  ) 

( l o g l o g   D  ) 

 

2 . I n t h e c a s e w h e r e   k  =  r  l n  D  a n d  r  = ( 1 )  , w e h a v e  

E    X 

m a x 

]   

  

1 + 

r  

l n  r 

2  r  l n  D 

+  O 

  

l o g  r 

r  l o g  D 

 

N o t e t h a t t h e r i g h t h a n d s i d e i s o f t h e f o r m  

( 1 +  o  ( 1 ) )   w h e n   r  ! 1  . I n t h e c a s e w h e n   r  = ( 1 )  , w e h a v e  

E    X 

m a x 

]    c N 

= D  f o r s o m e c o n s t a n t   c >  0 

S i n c e t h e c l a s s i c a l o c c u p a n c y p r o b l e m i s a s p e c i a l c a s e o f t h e d e p e n d e n t o c c u p a n c y p r o b l e m , a n i m m e d i a t e  

i m p l i c a t i o n i s t h e f o l l o w i n g c o r o l l a r y .  

C o r o l l a r y 1   C o n s i d e r a c l a s s i c a l o c c u p a n c y p r o b l e m i n w h i c h   N 

b a l l s a r e i n d e p e n d e n t l y , u n i f o r m l y r a n d o m l y  

t h r o w n i n t o   D  b i n s . T h e e x p e c t e d m a x i m u m o c c u p a n c y   C  (  N 

; D  )  o f t h i s p r o b l e m i s b o u n d e d f r o m a b o v e b y t h e  

s a m e u p p e r b o u n d s t h a t w e p r o v e d i n T h e o r e m 7 f o r t h e e x p e c t a t i o n E     X 

m a x 

]  o f t h e m a x i m u m o c c u p a n c y o f a n y  

d e p e n d e n t o c c u p a n c y p r o b l e m i n v o l v i n g a t o t a l o f   N 

b a l l s a n d   D  b i n s .  

T h e u p p e r b o u n d s w e p r o v e f o r t h e e x p e c t a t i o n o f m a x i m u m o c c u p a n c y i n t h e d e p e n d e n t o c c u p a n c y p r o b l e m a r e  

p r e c i s e l y t h e   a s y m p t o t i c a l l y t i g h t b o u n d s   f o r t h e c l a s s i c a l m a x i m u m o c c u p a n c y p r o b l e m d e r i v e d i n K S C 7 8 ] . I n f a c t ,  

4 5 

Page 59: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 59/203

o u r p r o o f f o r t h e u p p e r b o u n d o n d e p e n d e n t e x p e c t e d m a x i m u m o c c u p a n c y c o n s t i t u t e s a n a l t e r n a t e a p p r o a c h t o  

o b t a i n i n g t h e s a m e a s y m p t o t i c a l l y l e a d i n g t e r m s a s t h o s e i n K S C 7 8 ] f o r t h e c l a s s i c a l e x p e c t e d m a x i m u m o c c u p a n c y .  

( T h e p r o o f i n K S C 7 8 ] a l s o s e r v e s a s a l o w e r b o u n d o n c l a s s i c a l e x p e c t e d m a x i m u m o c c u p a n c y b u t o u r t e c h n i q u e s  

c a n b e m o d i e d t o d o t h e s a m e . )  

P r o o f o f T h e o r e m 7  : T h e g i v e n d e p e n d e n c y p r o b l e m   X 

m i g h t i n v o l v e s o m e c h a i n s t h a t a r e l o n g e r t h a n   D  i n l e n g t h .  

L e m m a 2 1 e n s u r e s u s t h a t t h e r e a l w a y s e x i s t s a d e p e n d e n c y p r o b l e m   X  s u c h t h a t   E    X 

m a x 

] =  E    X 

m a x 

] w h e r e   X 

m a x 

i s t h e m a x i m u m o c c u p a n c y r a n d o m v a r i a b l e o f   X  , a n d   X  i n v o l v e s n o c h a i n o f l e n g t h g r e a t e r t h a n   D  . W e w i l l t h u s  

f o c u s o u r a t t e n t i o n o n t h i s p r o b l e m   X 

L e t  C  d e n o t e t h e n u m b e r o f c h a i n s i n   X  , a n d f o r 1     j    N 

, l e t   n 

d e n o t e t h e n u m b e r o f c h a i n s o f l e n g t h   j 

T h u s w e h a v e  

X   

1    j    D 

=  C ;  ( 3 . 1 )  

a n d 

X   

1    j    D 

j n 

=  N 

( 3 . 2 )  

L e t  T  d e n o t e a n y p o s i t i v e i n t e g e r . O n e w a y o f c o m p u t i n g   E    X 

m a x 

] i s 

E    X 

m a x 

] = 

X   

m    0 

P r  f  X 

m a x 

> m  g  ( 3 . 3 )  

  T  + 

X   

m    T 

P r  f  X 

m a x 

> m  g  ( 3 . 4 )  

  T  + 

X   

m    T 

D    P r  f  X > m  g  ( 3 . 5 )  

w h e r e   X  i s t h e r a n d o m v a r i a b l e c o r r e s p o n d i n g t o t h e   o c c u p a n c y o f o n e p a r t i c u l a r b i n   , s a y b i n   b 

, t h e b i n n u m b e r e d  

0 . W e w i l l d e r i v e a n a p p r o p i a t e b o u n d o n t h e q u a n t i t y  

P  

m    T 

P r  f  X > m  g  a n d t h e n a p p l y i t i n i n e q u a l i t y ( 3 . 5 )  

a b o v e t o b o u n d   E    X 

m a x 

]

I f a l l t h e c h a i n s i n v o l v e d a r e o f l e n g t h 1 , c o m p u t i n g P r  f  X > m  g  i s r e l a t i v e l y s t r a i g h t f o r w a r d . T h e f a c t t h a t t h e r e  

c a n b e u p t o   C  =  N 

c h a i n s w h o s e l e n g t h s m a y v a r y f r o m 1 t h r o u g h   D  i n t r o d u c e s d e p e n d e n c i e s t h a t c o m p l i c a t e t h e  

t a s k o f o b t a i n i n g a b o u n d f o r P r  f  X > m  g  . T o o b t a i n a b o u n d o n P r  f  X > m  g  , w e w i l l u s e a g e n e r a t i n g f u n c t i o n  

a p p r o a c h .  

4 6 

Page 60: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 60/203

D e n i t i o n 1 6   C o n s i d e r a r a n d o m v a r i a b l e   W  t h a t t a k e s i n t e g r a l v a l u e s . T h e   p r o b a b i l i t y g e n e r a t i n g f u n c t i o n   ( P G F )  

o f  W  , d e n o t e d   G 

(  z  ) , i s d e n e d t o b e t h e f u n c t i o n  

(  z  ) = 

X   

P r  f  W  =  t  g  z 

T h u s t h e c o e c i e n t o f  z 

i n  G 

(  z  ) i s P r  f  W  =  t  g 

I n t h e s i m p l e c a s e w h e n d e p e n d e n c y p r o b l e m   X  h a s o n l y o n e c h a i n , a n d t h e c h a i n h a s l e n g t h    ̀ , t h e P G F   G 

(  z  ) 

i s 

(  z  ) = 

  

1   

 ̀

 

 ̀

= 1   

 ̀

 ̀

z

I n t h e g e n e r a l c a s e w h e n d e p e n d e n c y p r o b l e m   X  h a s  C  i n d e p e n d e n t c h a i n s , t h e P G F i s t h e p r o d u c t o f t h e P G F s  

c o r r e s p o n d i n g t o e a c h i n d i v i d u a l c h a i n , w h i c h g i v e s u s  

(  z  ) = 

Y  

1    j    D 

  

1   

j z 

 

( 3 . 6 )  

S u p p o s e t h a t   P    1 i s a n u m b e r t o b e d e t e r m i n e d l a t e r . B y d e n i t i o n , w e h a v e   G 

(  P  ) =  E    P 

] . T h u s , s i n c e  

X  i s a p o s i t i v e i n t e g r a l r a n d o m v a r i a b l e , w e h a v e  

(  P  ) = 

X   

t    1 

P r  f  X  =  t  g   P 

P r  f  X    m  g  ;  ( 3 . 7 )  

f o r a n y p o s i t i v e i n t e g e r   m  . B y ( 3 . 6 ) a n d ( 3 . 7 ) , w e g e t  

P r  f  X    m  g  

(  P  ) 

( 3 . 8 )  

Y  

1    j    D 

  

1 + 

(  P    1 )  j 

 

( 3 . 9 )  

 

Y  

1    j    D 

  

1 + 

P    1 

 

j n 

( 3 . 1 0 )  

  

1 + 

P    1 

 

( 3 . 1 1 )  

S t e p ( 3 . 1 0 ) f o l l o w s f r o m t h e i n e q u a l i t y ( 1 + (  P    1 )  j = D  )    ( 1 + (  P    1 )  = D  ) 

w h e n   j    0 a n d   P    1 . S t e p ( 3 . 1 1 )  

f o l l o w s f r o m ( 3 . 2 ) . N o t e t h a t i f t h e p r o b a b i l i t y g e n e r a t i n g f u n c t i o n f o r t h e m a x i m u m o c c u p a n c y r a n d o m v a r i a b l e o f  

c l a s s i c a l o c c u p a n c y w i t h   N 

b a l l s a n d   D  b i n s i s d e n o t e d   G 

(  z  ) , t h e n   G 

(  P  ) i s p r e c i s e l y t h e e x p r e s s i o n ( 1 + (  P   

1 )  = D  ) 

4 7 

Page 61: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 61/203

W e n e e d t o s e l e c t a n a p p r o p r i a t e v a l u e o f   P  i n t h e b o u n d ( 3 . 1 1 ) f o r P r  f  X    m  g  . T h e i d e a i s t o o p t i m i z e t h e  

v a l u e o f   P  s o t h a t t h e r i g h t h a n d s i d e o f ( 3 . 5 ) i s m i n i m a l . I n w h a t f o l l o w s , w e w i l l d e n o t e   P  a s 1 +     , w h e r e     i s a 

p o s i t i v e q u a n t i t y t o b e d e t e r m i n e d l a t e r . I t i s u n d e r s t o o d t h a t   P  ( a n d t h u s     ) m a y b e a f u n c t i o n o f   D 

S u b s t i t u t i n g   P  = 1 +    i n t o ( 3 . 1 1 ) , w e h a v e  

P r  f  X    m  g  

( 1 +    ) 

 

1 + 

 

 

( 3 . 1 2 )  

W e k n o w t h a t   E    X 

m a x 

]    N 

= D  t r i v i a l l y . I n o r d e r t o c o n v e n i e n t l y m a n i p u l a t e t h e r i g h t h a n d s i d e o f ( 3 . 5 ) , w h i c h  

w i l l b e a f u n c t i o n o f   T  a n d    , w e p a r a m e t e r i z e   T  a s  T  = 1 +  N 

= D  , w h e r e   >  1 i s c h o s e n s o t h a t   N 

= D  i s a n  

i n t e g e r . P l u g g i n g i n t h i s p a r a m e t e r i z a t i o n a n d s i m p l i f y i n g ( 3 . 5 ) u s i n g ( 3 . 1 2 ) , w e h a v e  

E    X 

m a x 

]   

  

+ 1 

 

X   

m > N  

= D 

D    P r  f  X > m  g  ( 3 . 1 3 )  

 

  

+ 1 

 

+  D 

X   

m > N  

= D 

 

1 + 

 

 

( 1 +    ) 

( 3 . 1 4 )  

 

  

+ 1 

 

+  D 

 

1 + 

 

 

( 1 +    ) 

= D 

X   

m >  0 

( 1 +    ) 

( 3 . 1 5 )  

  

+ 1 

 

+  D 

 

1 + 

 

 

  ( 1 +    ) 

= D 

( 3 . 1 6 )  

I f t h e v a l u e o f     i s l a r g e e n o u g h , t h e s e c o n d t e r m o f ( 3 . 1 6 ) w i l l b e n e g l i g i b l e . W e n o w d e r i v e t h e s m a l l e s t v a l u e    

c a n t a k e t h a t s t i l l e n s u r e s t h a t t h e s e c o n d t e r m i n ( 3 . 1 6 ) i s a t m o s t 1 :  

 

1 + 

 

 

  ( 1 +    ) 

= D 

  1 

T a k i n g n a t u r a l l o g a r i t h m s o n b o t h s i d e s , w e h a v e  

l n  D  +  N 

l n 

 

1 + 

 

 

   

l n ( 1 +     )    l n      0 

R e a r r a n g i n g t e r m s , w e g e t  

 

l n ( 1 +     )    N 

l n 

 

1 + 

 

 

+ l n  D    l n    ( 3 . 1 7 )  

   

D  l n 

 

1 + 

 

 

l n ( 1 +     ) 

D  l n  D 

l n ( 1 +     ) 

 

D  l n   

l n ( 1 +     ) 

( 3 . 1 8 )  

4 8 

Page 62: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 62/203

W e t a k e    

 

t o b e t h e s m a l l e s t r e a l n u m b e r s a t i s f y i n g ( 3 . 1 8 ) s u c h t h a t    

 

= D  i s i n t e g r a l . R e p l a c i n g     b y   

 

i n 

( 3 . 1 6 ) a n d e x p l o i t i n g t h e f a c t t h a t t h e s e c o n d t e r m i n ( 3 . 1 6 ) i s a t m o s t 1 , w e g e t  

E    X 

m a x 

]   

  

 

 

+ 1 

 

+ 1 ( 3 . 1 9 )  

 

 

 

+ 2  ( 3 . 2 0 )  

W e a r e n o w r e a d y t o c o n s i d e r t h e d i e r e n t c a s e s r e g a r d i n g t h e r e l a t i o n s h i p b e t w e e n   N 

a n d  D  . T h e b a s i c i d e a i s  

t o c h o o s e d i e r e n t v a l u e s o f     f o r t h e d i e r e n t c a s e s s o a s t o o p t i m i z e t h e b o u n d s o b t a i n e d u s i n g ( 3 . 2 0 ) . T h r o u g h o u t  

t h i s d e r i v a t i o n w e w i l l m a k e u s e o f t h e b o u n d l n ( 1 +   x  ) =  x    x 

=  2 +  O  (  x 

) f o r b o u n d e d p o s i t i v e   x 

C a s e 1 :   N 

=  k D  f o r c o n s t a n t   k >  0 . I n t h i s c a s e , w e c h o o s e  

  = 

1  = r 

l n ( 1   = r  ) 

( l n  D  )  = k 

l n l n   D    l n  k 

S u b s t i t u t i n g a n d s i m p l i f y i n g , t h e r s t t e r m i n e x p r e s s i o n ( 3 . 1 8 ) c a n b e w r i t t e n a s  

l n  D 

k  ( l n l n   D  ) 

  

1 +  O 

  

l o g l o g l o g   D 

l o g l o g   D 

 

a n d t h e s e c o n d t e r m i n e x p r e s s i o n ( 3 . 1 8 ) c a n b e w r i t t e n a s  

l n  D 

k  l n l n   D 

  

1 + 

l n l n l n   D 

l n l n   D 

l n  k 

l n l n   D 

+  O 

  

( l o g l o g l o g   D  ) 

( l o g l o g   D  ) 

 

T h e t h i r d t e r m o f e x p r e s s i o n ( 3 . 1 8 ) i s   O  ( 1 ) . H e n c e t h e b o u n d o n    

 

c a n b e w r i t t e n a s  

 

 

l n  D 

k  l n l n   D 

  

1 + 

l n l n l n   D 

l n l n   D 

1 + l n   k 

l n l n   D 

+  O 

  

( l o g l o g l o g   D  ) 

( l o g l o g   D  ) 

 

( 3 . 2 1 )  

U s i n g i n e q u a l i t y ( 3 . 2 1 ) i n i n e q u a l i t y ( 3 . 2 0 ) a n d s i m p l i f y i n g , w e g e t  

E    X 

m a x 

]   

l n  D 

l n l n   D 

  

1 + 

l n l n l n   D 

l n l n   D 

1 + l n   k 

l n l n   D 

+  O 

  

( l o g l o g l o g   D  ) 

( l o g l o g   D  ) 

 

( 3 . 2 2 )  

T h i s c o m p l e t e s t h e p r o o f o f C a s e 1 o f T h e o r e m 7 .  

C a s e 2 :   N 

=  r D  l n  D  w i t h   r  = ( 1 ) . I n t h i s c a s e , w e c h o o s e     = 

p  

2  = r  . S i n c e   = D  = 

p  

2  = r = D   !  0 a s y m p t o t i c a l l y  

a s  D  ! 1  , i t f o l l o w s t h a t   D  l n ( 1 +   = D  ) = 

p  

2  = r  ( 1 +  O  ( 

p  

2  = r = D   ) )

4 9 

Page 63: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 63/203

L e t u s r s t c o n s i d e r t h e m o r e i n t e r e s t i n g s u b c a s e w h e n   r  ! 1  ;   !  0 . I n t h i s t h e r s t t e r m o n t h e r i g h t h a n d  

s i d e o f i n e q u a l i t y ( 3 . 1 8 ) e q u a l s  

D  l n 

 

1 + 

 

 

l n ( 1 +     ) 

p  

2  = r 

  

1 +  O 

  

2  = r 

 

p  

2  = r    1  = r  +  O  ( 1  = r 

r  ) 

= 1 + 

r  

2  r 

+  O 

  

 

( 3 . 2 3 )  

T h e s e c o n d t e r m o n t h e r i g h t h a n d s i d e o f ( 3 . 1 8 ) e q u a l s  

D  l n  D 

l n ( 1 +     ) 

1  = r 

p  

2  = r    1  = r  +  O  ( 1  = r 

r  ) 

2  r 

+  O 

  

 

( 3 . 2 4 )  

T h e t h i r d t e r m o f ( 3 . 1 8 ) i s  

  D  l n   

l n ( 1 +     ) 

  l n   

(  r  l n  D  )    ( 1 +  O  (    ) ) 

( 3 . 2 5 )  

l n  r    l n 2 

2  r  ( l n  D  ) 

p  

2  = r  ( 1 +  O  ( 1  = 

r  ) ) 

( 3 . 2 6 )  

l n  r 

2  r  ( l n  D  ) ( 1 +   O  ( 1  = 

r  ) ) 

( 3 . 2 7 )  

l n  r 

2  r  l n  D 

+  O 

  

l o g  r 

r  l o g  D 

 

( 3 . 2 8 )  

B y ( 3 . 2 3 ) , ( 3 . 2 4 ) , a n d ( 3 . 2 8 ) , w e c a n c h o o s e    

 

t o b e  

 

 

= 1 + 

r  

l n  r 

2  r  l n  D 

+  O 

  

l o g  r 

r  l o g  D 

 

( 3 . 2 9 )  

F o r t h e b o u n d o n t h e e x p e c t e d m a x i m u m o c c u p a n c y , a p p l y i n g ( 3 . 2 9 ) i n i n e q u a l i t y ( 3 . 2 0 ) a n d s i m p l i c a t i o n y i e l d s  

E    X 

m a x 

]   

  

1 + 

r  

l n  r 

2  r  l n  D 

+  O 

  

l o g  r 

r  l o g  D 

 

+ 2 

 

  

1 + 

r  

l n  r 

2  r  l n  D 

+  O 

  

l o g  r 

r  l o g  D 

 

I n t h e s u b c a s e w h e n   r  =  k  = ( 1 ) f o r s o m e   k >  0 , i t i s e a s i l y s e e n t h a t t h e r i g h t h a n d s i d e o f ( 3 . 1 8 ) d e p e n d s u p o n  

r  b u t i t i s   O  ( 1 ) , a n d t h u s    

 

=  O  ( 1 ) . U s i n g    

 

  c 

, w h e r e   c 

i s a p o s i t i v e c o n s t a n t , i n i n e q u a l i t y ( 3 . 2 0 ) , w e h a v e  

E    X 

m a x 

]    c 

+ 2  ( 3 . 3 0 )  

T h i s c o m p l e t e s t h e p r o o f o f C a s e 2 o f T h e o r e m 7 .  

5 0 

Page 64: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 64/203

3 . 7 . 3 P r o o f o f T h e o r e m 6  

A n i n t u i t i v e w a y t o l o o k a t t h e a n a l y s i s o f S R M i s t h a t t h e n u m b e r o f I / O r e a d o p e r a t i o n s c o r r e s p o n d i n g t o a p h a s e  

i s t h e e x p e c t e d m a x i m u m o c c u p a n c y o f a d e p e n d e n t o c c u p a n c y p r o b l e m i n v o l v i n g   N 

=  R  b a l l s a n d   D  b i n s . T h u s  

t o c o m p u t e t h e n u m b e r o f r e a d s f o r t h e e n t i r e m e r g e s o r t , w e h a v e t o m u l t i p l y t h e e x p e c t e d m a x i m u m o c c u p a n c y b y  

t h e t o t a l n u m b e r o f p h a s e s i n t h e m e r g e s o r t , w h i c h i s t h e p r o d u c t o f t h e n u m b e r l n (  N = M  )  =  l n  R  o f p a s s e s o v e r t h e  

l e o t h e r t h a n t h e i n i t i a l r u n f o r m a t i o n p a s s a n d t h e n u m b e r   N = R B   o f p h a s e s i n a m e r g e p a s s .  

U s i n g L e m m a s 1 8 a n d 2 0 , w i t h t h e r a n d o m v a r i a b l e s   I 

a n d  L 

d e n e d a s i n t h o s e l e m m a s , t h e r a n d o m v a r i a b l e  

t h a t b o u n d s t h e n u m b e r o f I / O r e a d o p e r a t i o n s d u r i n g a m e r g e o f  N 

r e c o r d s d u r i n g S R M i s   I 

P  

1    i    J 

, w h e r e  

J  = 

= B    R 

. T h e e x p e c t e d n u m b e r o f r e a d o p e r a t i o n s i n a m e r g e i s t h u s  

E    I 

] + 

X   

1    i    J 

E    L 

]  ( 3 . 3 1 )  

T h e r a n d o m v a r i a b l e   I 

i s t h e m a x i m u m o c c u p a n c y o f a c l a s s i c a l o c c u p a n c y p r o b l e m i n v o l v i n g   R  b a l l s a n d   D  b i n s  

a n d e a c h   L 

i s t h e m a x i m u m o c c u p a n c y o f a d e p e n d e n t o c c u p a n c y p r o b l e m i n v o l v i n g   R  b a l l s a n d   D  b i n s .  

L e t u s c o n s i d e r C a s e 1 o f T h e o r e m 6 , i n w h i c h w e h a v e   R  =  k D  f o r c o n s t a n t   k >  0 . I n t e r m s o f o c c u p a n c i e s , t h i s  

c o r r e s p o n d s t o C a s e 1 o f T h e o r e m 7 , i n w h i c h a t o t a l o f  N 

=  R  =  k D  b a l l s a r e t h r o w n i n t o   D  b i n s . F r o m t h e b o u n d s  

f o r C a s e 1 o f T h e o r e m 7 a n d C o r o l l a r y 1 , t h e e x p e c t a t i o n s   E    I 

] a n d   E    L 

] a r e a l l b o u n d e d b y t h e r i g h t h a n d s i d e  

o f ( 3 . 2 2 ) . S u b s t i t u t i n g ( 3 . 2 2 ) i n t o ( 3 . 3 1 ) a n d s i m p l i f y i n g , w e n d t h a t t h e n u m b e r o f r e a d s i n a m e r g e o f   N 

r e c o r d s  

d u r i n g S R M i s g i v e n b y  

(  J  + 1 ) 

  

l n  D 

l n l n   D 

  

1 + 

l n l n l n   D 

l n l n   D 

1 + l n   k 

l n l n   D 

+  O 

  

( l o g l o g l o g   D  ) 

( l o g l o g   D  ) 

 

k D B 

 

l n  D 

l n l n   D 

  

1 + 

l n l n l n   D 

l n l n   D 

1 + l n   k 

l n l n   D 

+  O 

  

( l o g l o g l o g   D  ) 

( l o g l o g   D  ) 

 

( 3 . 3 2 )  

I n e a c h p a s s o v e r t h e l e , t h e s u m o f t h e s i z e s o f a l l t h e r u n s t h a t a r e m e r g e d i s  

P  

=  N  . T h e r e f o r e b y ( 3 . 3 2 ) , t h e  

e x p e c t e d n u m b e r o f r e a d s d o n e b y S R M i n e a c h p a s s o n t h e l e i s  

k D B 

 

l n  D 

l n l n   D 

  

1 + 

l n l n l n   D 

l n l n   D 

1 + l n   k 

l n l n   D 

+  O 

  

( l o g l o g l o g   D  ) 

( l o g l o g   D  ) 

 

( 3 . 3 3 )  

T h e r e a r e ( l n (  N = M  ) )  =  ( l n (  k D  ) ) m e r g e p a s s e s o t h e r t h a n t h e i n i t i a l r u n f o r m a t i o n p a s s , w h i c h c o s t s   N = D B   r e a d  

o p e r a t i o n s . T h u s , t h e e x p e c t e d n u m b e r o f r e a d o p e r a t i o n s r e q u i r e d t o s o r t   N  u s i n g S R M i n C a s e 1 o f T h e o r e m 6 i s  

D B 

l n (  N = M  ) 

l n (  k D  ) 

D B 

l n  D 

k  l n l n   D 

  

1 + 

l n l n l n   D 

l n l n   D 

1 + l n   k 

l n l n   D 

+  O 

  

( l o g l o g l o g   D  ) 

( l o g l o g   D  ) 

 

S i m i l a r l y , w e c a n a p p l y o c c u p a n c y b o u n d s f r o m o t h e r c a s e s o f T h e o r e m 7 a n d C o r o l l a r y 1 t o b o u n d t h e e x p e c t a t i o n s  

E    I 

] a n d   E    L 

] , w h e r e 1     i    J  , i n C a s e s 2 a n d 3 o f T h e o r e m 6 , a n d w e g e t t h e d e s i r e d e x p r e s s i o n s s h o w n i n t h e  

s t a t e m e n t o f T h e o r e m 6 . T h i s c o m p l e t e s t h e p r o o f o f T h e o r e m 6 .  

5 1 

Page 65: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 65/203

3 . 8 A D e t e r m i n i s t i c V a r i a n t    

A s m e n t i o n e d e a r l i e r i n S e c t i o n 3 . 3 , w h e n t h e i n p u t d a t a r e c o r d s o f t h e r u n s a r e r a n d o m l y a n d u n i f o r m l y d i s t r i b u t e d ,  

w e e x p e c t a v e r s i o n o f o u r a l g o r i t h m t h a t u s e s a d e t e r m i n i s t i c s t a g g e r e d d i s t r i b u t i o n o f s t a r t i n g b l o c k s o f r u n s o n  

d i s k s t o g i v e a n a v e r a g e p e r f o r m a n c e c o m p a r a b l e t o t h e b o u n d s w e s h o w e d i n T h e o r e m 6 . I n t u i t i v e l y , t h i s e e c t  

o c c u r s b e c a u s e w i t h l o n g , r a n d o m i n p u t r u n s , t h e   R  l e a d i n g b l o c k s o f t h e   R  i n p u t r u n s a t a n y t i m e d u r i n g t h e m e r g e  

t e n d t o b e s p r e a d n o w o r s e t h a n r a n d o m l y a m o n g t h e   D  d i s k s .  

W h e n t h e   R  i n p u t r u n s a r e s t a g g e r e d o n t h e   D  d i s k s , t h e r s t r u n h a s i t s r s t b l o c k o n d i s k 0 w i t h s u b s e q u e n t  

b l o c k s c y c l i c a l l y s t o r e d o n t h e d i s k s , t h e n e x t r u n h a s i t s r s t b l o c k s t o r e d o n d i s k 1 , a n d s o o n . I f t h e r u n s a r e \ s h o r t  

e n o u g h , " w e c a n e x p e c t t h e r u n s t o m a i n t a i n t h e i r s t a g g e r o n t h e d i s k s   t h r o u g h o u t   t h e d u r a t i o n o f t h e m e r g e o n t h e  

a v e r a g e , e n s u r i n g v e r y e c i e n t I / O . O n t h e o t h e r h a n d , a s o b s e r v e d i n t h e p r e v i o u s p a r a g r a p h , e v e n w h e n r u n s a r e  

\ l o n g , " w e c a n e x p e c t I / O t o b e r e a s o n a b l y e c i e n t . H e n c e , i f a n a n a l y s i s o f h a v i n g r u n s s t a g g e r e d d e t e r m i n i s t i c a l l y  

d u r i n g i n i t i a l m e r g e s t a g e s ( w h e n r u n s a r e \ s h o r t " ) i s c o m b i n e d w i t h a n a n a l y s i s t h a t e x p l o i t s t h e r a n d o m n e s s i n  

m a x i m u m o c c u p a n c y s i t u a t i o n s d u r i n g l a t e r m e r g e s t a g e s ( w h e n r u n s a r e \ l o n g " ) , w e m i g h t b e a b l e t o o b t a i n a n  

i m p r o v e m e n t i n o v e r a l l I / O p e r f o r m a n c e o f t h e m e r g e s o r t . W e m i g h t t h u s b e a b l e t o p r o v e t h e o r e t i c a l o p t i m a l i t y  

( w i t h i n a c o n s t a n t f a c t o r ) f o r a n i n c r e a s e d r a n g e o f v a l u e s o f   M  ,  B  a n d  D  f o r o u r m e r g e s o r t , c o m p a r e d w i t h t h e  

r a n g e i n T h e o r e m 1 .  

3 . 9 C o m p a r i s o n s b e t w e e n S R M a n d D S M i n P r a c -    

t i c e      

I n D S M , t h e p o p u l a r l y - u s e d m e r g i n g t e c h n i q u e w i t h d i s k s t r i p i n g , t h e r e a r e   O  (  M = D B   ) r u n s m e r g e d i n e a c h m e r g e  

s t e p w i t h p e r f e c t r e a d p a r a l l e l i s m . T h e p r i c e t h a t D S M p a y s f o r n o t u s i n g t h e d i s k s i n d e p e n d e n t l y i s t h a t i t c a n  

m e r g e o n l y (  M = D B   ) r a t h e r t h a n (  M = B  ) r u n s a t a t i m e . H o w e v e r , D S M i s o f t e n m o r e e c i e n t i n p r a c t i c e t h a n  

t h e p r e v i o u s l y d e v e l o p e d a s y m p t o t i c a l l y o p t i m a l s o r t i n g a l g o r i t h m s , s i n c e t h e l a t t e r a l g o r i t h m s h a v e l a r g e r o v e r h e a d s  

V V 9 6 b ] .  

W h e n t h e a m o u n t   M  o f i n t e r n a l m e m o r y i s s m a l l o r t h e n u m b e r   D  o f d i s k s i s l a r g e , o u r S R M m e t h o d i s c l e a r l y  

s u p e r i o r t o D S M . F o r e x a m p l e , i f   M  = (  D B  ) , D S M i s s u b o p t i m a l b y a f a c t o r o f ( l o g   D  ) w h e r e a s S R M i s s u b o p t i m a l  

b y a f a c t o r o f ( l o g   D =  l o g l o g   D  ) . T h e i m p r o v e m e n t o f S R M o v e r D S M s h o w s u p i n p r a c t i c e e v e n w h e n   M  i s 

s u b s t a n t i a l l y l a r g e r o r t h e n u m b e r o f d i s k s   D  i s s m a l l , w h i c h i s w h e n D S M h a s b e t t e r I / O p e r f o r m a n c e t h a n p r e v i o u s l y  

d e v e l o p e d e x t e r n a l s o r t i n g a l g o r i t h m s .  

I n t h i s s e c t i o n , w e c o m p a r e t h e p e r f o r m a n c e o f t h e D S M a n d S R M m e r g e s o r t s o n e x i s t i n g p a r a l l e l d i s k s y s t e m s . I n  

S u b s e c t i o n 3 . 9 . 2 w e m a k e a c o m p a r i s o n b a s e d u p o n   a n e s t i m a t e o f t h e u p p e r b o u n d o n t h e e x p e c t e d w o r s t - c a s e   n u m b e r  

o f I / O o p e r a t i o n s o f a n S R M m e r g e s o r t w i t h t h e e x a c t n u m b e r o f I / O o p e r a t i o n s f o r t h e s t a n d a r d D S M m e r g e s o r t  

w i t h d i s k s t r i p i n g , u s i n g p a r a m e t e r s o f p r e s e n t l y e x i s t i n g o r f e a s i b l e p a r a l l e l d i s k s y s t e m s . I n S u b s e c t i o n 3 . 9 . 3 w e  

5 2 

Page 66: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 66/203

m a k e a s i m i l a r c o m p a r i s o n b a s e d u p o n a c t u a l s i m u l a t i o n s o f S R M t o e s t i m a t e i t s a v e r a g e - c a s e I / O p e r f o r m a n c e o n  

r a n d o m i n p u t s . B o t h t h e c o m p a r i s o n s s h o w t h a t S R M ' s I / O p e r f o r m a n c e i s a l w a y s b e t t e r t h a n D S M ' s . M o r e o v e r ,  

s i m u l a t i o n s i n d i c a t e t h a t S R M ' s a c t u a l I / O p e r f o r m a n c e i s m u c h b e t t e r t h a n t h a t i m p l i e d b y t h e e s t i m a t e o f t h e  

a n a l y t i c a l b o u n d i n S u b s e c t i o n 3 . 9 . 2 .  

3 . 9 . 1 E x p r e s s i o n s f o r t h e n u m b e r o f I / O o p e r a t i o n s  

I n t h i s s u b s e c t i o n a n d t h e f o l l o w i n g o n e s , w e a s s u m e t h a t S R M i s a b l e t o m e r g e   R  =  k D  r u n s a t a t i m e , f o r i n t e r e s t i n g  

v a l u e s o f   k  a n d  D  . W e c o n s i d e r D S M u s i n g t h e s a m e a m o u n t o f m e m o r y a n d e s t i m a t e t h e r e l a t i v e p e r f o r m a n c e s o f  

S R M a n d D S M .  

W e w i l l r s t c o n s i d e r S R M , w h i c h m e r g e s   R  =  k D  r u n s a t a t i m e . T h e a m o u n t o f i n t e r n a l m e m o r y n e e d e d t o  

s u p p o r t t h e m e r g i n g i s   M  = ( 2  k D  + 4  D  )  B  +  k D 

. T h e t o t a l n u m b e r o f w r i t e s S R M r e q u i r e s i s  

D B 

( 1 + 

l n (  N = M  ) 

l n (  k D  ) 

s i n c e i t h a s p e r f e c t w r i t e p a r a l l e l i s m . I n t e r m s o f r e a d s , S R M r e q u i r e s   N = D B   r e a d s c o r r e s p o n d i n g t o t h e i n i t i a l r u n  

f o r m a t i o n p a s s . I t s u b s e q u e n t l y r e q u i r e s  

l n (  N = M  ) 

l n (  k D  ) 

p a s s e s t o p e r f o r m t h e m e r g i n g , e a c h i n c u r r i n g   v 

D B 

r e a d s , w h e r e  

v  =  v  (  k ; D  ) i s t h e   o v e r h e a d f a c t o r   t h a t r e p r e s e n t s a m u l t i p l i c a t i v e o v e r h e a d o v e r a n d a b o v e t h e m i n i m u m n u m b e r  

D B 

o f r e a d s f o r a s i n g l e p a s s . T h e t o t a l n u m b e r o f I / O o p e r a t i o n s S R M t a k e s t o s o r t   N  r e c o r d s i s t h u s  

D B 

  

2 + 

l n (  N = M  ) 

l n (  k D  ) 

( 1 +  v  ) 

 

D B 

  

2 +  C 

S R M 

l n 

 

w h e r e  

S R M 

1 +  v 

l n (  k D  ) 

( 3 . 3 4 )  

W e n o w c o m p u t e i n a s i m i l a r w a y t h e n u m b e r o f I / O o p e r a t i o n s n e e d e d b y D S M t o s o r t   N  r e c o r d s u s i n g t h e s a m e  

a m o u n t o f m e m o r y a s S R M a b o v e . W e a s s u m e t h a t D S M u s e s 2  D  b l o c k s p e r r u n f o r I / O r e a d b u e r s a n d 2  D  b l o c k s  

f o r I / O w r i t e b u e r s . D S M m e r g e s (  M = B    2  D  )  =  2  D  =  k  + 1 +  k D =  2  B  r u n s a t a t i m e . I t c a n b e v e r i e d t h a t t h e  

n u m b e r o f I / O o p e r a t i o n s r e q u i r e d b y D S M t o s o r t   N  r e c o r d s i s  

D B 

  

2 + 2 

l n (  N = M  ) 

l n (  k  + 1 +  k D =  2  B  ) 

 

D B 

  

2 +  C 

D S M 

l n 

 

w h e r e  

D S M 

l n (  k  + 1 +  k D =  2  B  ) 

( 3 . 3 5 )  

5 3 

Page 67: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 67/203

3 . 9 . 2 C o m p a r i s o n b a s e d u p o n e x p e c t e d w o r s t - c a s e p e r f o r -  

m a n c e o f S R M  

O u r g o a l i n t h i s s u b s e c t i o n i s t o c o m p a r e S R M a n d D S M b a s e d u p o n t h e   e x p e c t e d w o r s t - c a s e p e r f o r m a n c e   o f S R M .  

O u r c o m p a r i s o n u s e s   k  a n d  D  v a l u e s c o r r e s p o n d i n g t o r e a l i s t i c s y s t e m s . T o m a k e t h e c o m p a r i s o n p o s s i b l e , w e n e e d  

t o o b t a i n a n e s t i m a t e o f t h e o v e r h e a d f a c t o r   v  (  k ; D  ) d e n e d i n t h e p r e v i o u s s u b s e c t i o n c o r r e s p o n d i n g t o t h e s e v a l u e s  

o f  k  a n d  D 

N o t e t h a t f o r a p a i r o f g i v e n n i t e v a l u e s o f   k  a n d  D  , t h e e s t i m a t e o f t h e e x p e c t e d w o r s t - c a s e v a l u e o f   v  u s i n g  

T h e o r e m 6 i s l a x b e c a u s e o f c o n t r i b u t i o n s f r o m l o w e r - o r d e r t e r m s . A s e x p l a i n e d i n S e c t i o n 3 . 7 . 3 , t h e e x p e c t e d n u m b e r  

o f r e a d s d o n e b y S R M i s b o u n d e d b y a n e x p r e s s i o n i n v o l v i n g e x p e c t e d m a x i m u m o c c u p a n c i e s o f t h e c l a s s i c a l a n d  

d e p e n d e n t c a s e s . W e g e t m o r e u s e f u l c o m p a r i s o n s b e t w e e n S R M a n d D S M b y r e p l a c i n g t h e m a x i m u m d e p e n d e n t  

o c c u p a n c y b y t h e m a x i m u m c l a s s i c a l o c c u p a n c y i n t h e b o u n d f o r t h e e x p e c t e d n u m b e r o f r e a d s r e q u i r e d b y S R M .  

T h i s a p p r o a c h c a n b e j u s t i e d o n t w o c o u n t s . F i r s t , t h e u p p e r b o u n d i n T h e o r e m 7 t h a t w e p r o v e d f o r t h e e x p e c t e d  

m a x i m u m d e p e n d e n t o c c u p a n c y i s t h e s a m e a s t h e e x p r e s s i o n f o r t h e e x p e c t e d m a x i m u m o f t h e c l a s s i c a l o c c u p a n c y  

p r o b l e m . M o r e o v e r , w e c o n j e c t u r e t h a t e x p e c t e d c l a s s i c a l m a x i m u m o c c u p a n c y i s n e v e r l e s s t h a n t h e e x p e c t e d  

m a x i m u m o c c u p a n c y o f d e p e n d e n t o c c u p a n c y p r o b l e m s i n v o l v i n g t h e s a m e n u m b e r o f b a l l s a n d b i n s , a s e x p l a i n e d i n  

S e c t i o n 3 . 7 . 2 .  

F o r g i v e n v a l u e s o f   k  a n d  D  , w e s i m u l a t e t h r o w i n g   k D  b a l l s i n t o   D  b i n s r e p e a t e d l y t o e s t i m a t e   C  (  k D ; D   ) . T h u s  

t h e e x p e c t e d w o r s t - c a s e o v e r h e a d   v  (  k ; D  ) i s e s t i m a t e d b y r e p e a t e d b a l l - t h r o w i n g e x p e r i m e n t s t o e s t i m a t e  

C  (  k D ; D   ) 

T a b l e 3 . 1 s h o w s t h e v a l u e s o f   v  b a s e d u p o n s u c h e x p e r i m e n t s .  

F o r e v e r y   k  ,  D  p a i r c o n s i d e r e d , w e u s e ( 3 . 3 4 ) t o e s t i m a t e a n e x p e c t e d w o r s t - c a s e v a l u e f o r   C 

S R M 

u s i n g t h e  

a b o v e m e n t i o n e d e s t i m a t e s f o r   v  . I n T a b l e 3 . 2 w e p r e s e n t t h e   C 

S R M 

= C 

D S M 

r a t i o f o r s e v e r a l v a l u e s o f   k  a n d  D  . T h e  

r a t i o   C 

S R M 

= C 

D S M 

r e p r e s e n t s t h e r e l a t i v e I / O a d v a n t a g e o f S R M o v e r D S M , n e g l e c t i n g t h e 2  N = D B   I / O s t h a t b o t h  

m e t h o d s r e q u i r e d u r i n g t h e i n i t i a l r u n f o r m a t i o n . W e u s e d b l o c k s i z e   B  = 1 0 0 0 r e c o r d s f o r a l l   k ; D  p a i r s . ( T h e c h o i c e  

o f  B  i s n o t s i g n i c a n t s o l o n g a s i t i s r e a s o n a b l e . ) I n o u r r e p r e s e n t a t i o n , 2  k  i s r o u g h l y t h e n u m b e r o f i n t e r n a l m e m o r y  

b l o c k s a v a i l a b l e p e r d i s k .  

T a b l e 3 . 2 s h o w s t h a t t h e S R M u s e s s i g n i c a n t l y f e w e r I / O s t h a n d o e s D S M . F o r e x a m p l e , f o r   D  = 5 0 ,  k  = 1 0 0 ,  

w h i c h t r a n s l a t e s i n t o   M  = 1 0  5 m i l l i o n r e c o r d s o f i n t e r n a l m e m o r y , S R M u s e s 0   6 0 t i m e s a s m a n y I / O s a s d o e s t h e  

s l o w e r D S M , n o t c o u n t i n g t h e i n i t i a l r u n f o r m a t i o n p a s s t h a t t h e y s h a r e i n c o m m o n . W h e n   D  i s s m a l l , a s   k  i n c r e a s e s  

r e l a t i v e t o   D  , t h e   C 

S R M 

= C 

D S M 

r a t i o g r a d u a l l y i n c r e a s e s t o w a r d 1 , w h i c h i n d i c a t e s a l e s s e n i n g a d v a n t a g e o f S R M o v e r  

D S M w h e n t h e r e a r e f e w d i s k s a n d a h u g e a m o u n t o f i n t e r n a l m e m o r y . A s w e s h o w i n t h e n e x t s u b s e c t i o n , s i n c e w e  

o v e r e s t i m a t e t h e n u m b e r o f r e a d s r e q u i r e d b y S R M i n o u r a n a l y s i s , S R M a c t u a l l y e x h i b i t s e v e n b e t t e r p e r f o r m a n c e  

t h a n i n d i c a t e d i n T a b l e s 3 . 1 a n d 3 . 2 .  

5 4 

Page 68: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 68/203

D  = 5  D  = 1 0  D  = 5 0  D  = 1 0 0   D  = 1 0 0 0  

k  = 5 1  6 1  7 2  2 2  3 2  7 

k  = 1 0 1  4 1  5 1  8 1  9 2  2 

k  = 2 0 1  3 1  4 1  5 1  6 1  8 

k  = 5 0 1  2 1  2 1  3 1  4 1  5 

k  = 1 0 0 1  1 1 1  1 6 1  2 2 1  2 6 1  3 

k  = 1 0 0 0 1  0 4 1  0 5 1  0 8 1  0 8 1  1 

T a b l e 3 . 1   : T h e o v e r h e a d   v  (  k ; D  ) , c o m p u t e d b y e s t i m a t i n g   C  (  k D ; D   )  = k  u s i n g c o m p u t e r s i m u l a t i o n s .  

D  = 5  D  = 1 0  D  = 5 0  D  = 1 0 0   D  = 1 0 0 0  

k  = 5 0  7 1 0  6 2 0  5 1 0  4 8 0  4 6 

k  = 1 0 0  7 2 0  6 6 0  5 4 0  5 0 0  4 8 

k  = 2 0 0  7 5 0  6 8 0  5 6 0  5 3 0  4 9 

k  = 5 0 0  7 7 0  7 1 0  5 9 0  5 5 0  5 0 

k  = 1 0 0 0  7 8 0  7 2 0  6 1 0  5 7 0  5 1 

k  = 1 0 0 0 0  8 3 0  7 7 0  6 7 0  6 3 0  5 6 

T a b l e 3 . 2  : T h e p e r f o r m a n c e r a t i o   C 

S R M 

= C 

D S M 

f o r m e m o r y s i z e   M  = ( 2  k  + 4 )  D B  +  k D 

, w i t h b l o c k s i z e   B  = 1 0 0 0 .  

( B o t h   M  a n d  B  a r e e x p r e s s e d i n u n i t s o f r e c o r d s . ) T h e o v e r h e a d f a c t o r   v  i n  C 

S R M 

i s b a s e d u p o n c o m p u t e r s i m u l a t i o n s  

o f  C  (  k d ; D   )  = k 

3 . 9 . 3 U s i n g s i m u l a t i o n s t o c o u n t S R M ' s I / O o p e r a t i o n s  

I n t h e p r e v i o u s s u b s e c t i o n w e s h o w e d b y u s i n g c l a s s i c a l m a x i m u m o c c u p a n c y t o e s t i m a t e t h e o v e r h e a d t e r m   v  t h a t  

S R M p e r f o r m s w e l l c o m p a r e d t o D S M o n a r b i t r a r y i n p u t s . I n t h i s s e c t i o n w e u s e   s i m u l a t i o n s o f t h e a l g o r i t h m i t s e l f  

t o e s t i m a t e   v  o n  a v e r a g e - c a s e i n p u t s   a n d m a k e a s i m i l a r c o m p a r i s o n .  

O u r e x p e r i m e n t s c o n s i s t o f s i m u l a t i n g S R M w h i l e m e r g i n g   R  =  k D  s o r t e d r u n s , a n d e a c h o f l e n g t h   L  , f o r a l a r g e  

r a n g e o f   k  a n d  D  v a l u e s . T h e r u n s i n p u t t o t h e m e r g e w e r e g e n e r a t e d s u c h t h a t   e a c h s e t o f i n p u t r u n s w a s e q u a l l y  

l i k e l y   . S R M ' s a c t i o n s w h i l e m e r g i n g d e p e n d o n l y u p o n t h e r e l a t i v e o r d e r o f t h e i n p u t k e y s . T h u s , t h e r e i s a n o b v i o u s  

o n e - t o - o n e c o r r e s p o n d e n c e b e t w e e n t h e s e t o f a l l p o s s i b l e i n p u t r u n s t o t h e m e r g e a n d t h e s e t o f p a r t i t i o n s o f t h e  

s e t  I  =  f  1  ;  2  ; : : : ; L k D   g  , e a c h p a r t i t i o n s p l i t t i n g   I  i n t o   k D  d i s j o i n t s u b s e t s o f s i z e   L  . W e g e n e r a t e a v e r a g e - c a s e i n p u t s  

t o t h e m e r g e b y g e n e r a t i n g p a r t i t i o n s o f t h e s e t   I  , w i t h e a c h p a r t i t i o n b e i n g e q u a l l y l i k e l y .  

O u r s i m u l a t i o n s i n d i c a t e t h a t S R M ' s I / O o v e r h e a d i s n o t i c e a b l e o n l y w h e n   k  i s s m a l l c o m p a r e d w i t h t h e n u m b e r  

o f d i s k s   D  . W e r a n o u r s i m u l a t i o n s f o r s e v e r a l d i e r e n t s e t s o f p a r a m e t e r s . N o t o n l y d i d w e v a r y   k  a n d  D  , b u t f o r  

e a c h   k  ,  D  p a i r w e a l s o v a r i e d   B  a n d  L  ( w h e r e   L  i s a s d e n e d a b o v e ) . W e p r e s e n t h e r e a n i l l u s t r a t i v e s a m p l e o f t y p i c a l  

s i m u l a t i o n o u t c o m e s , w i t h o u r m a i n f o c u s o n t h e p a r a m e t e r s   k  a n d  D  . T a b l e 3 . 3 s h o w s t h e m u l t i p l i c a t i v e o v e r h e a d   v 

c o r r e s p o n d i n g t o s i m u l a t i o n s f o r i n t e r e s t i n g   k ; D  p a i r s . I t c a n b e s e e n t h a t t h e e s t i m a t e s o f   v  b a s e d u p o n a v e r a g e - c a s e  

i n p u t s a r e s m a l l e r t h a n t h e c o r r e s p o n d i n g e s t i m a t e s o f t h e e x p e c t a t i o n o f w o r s t - c a s e v a l u e s o f   v  i n T a b l e 3 . 1 . ( F o r  

v a l u e s o f   k  l a r g e r t h a n t h e o n e s s h o w n h e r e , t h e s i m u l a t i o n s g a v e v a l u e s   v  t h a t w e r e p r a c t i c a l l y e q u a l t o 1 . ) T h e  

s i m u l a t i o n s s h o w i n t h e a v e r a g e - c a s e t h a t S R M h a s l i t t l e o r n o o v e r h e a d w h e n   k  i s r e a s o n a b l y l a r g e a n d t h a t t h e  

n u m b e r o f I / O r e a d o p e r a t i o n s r e q u i r e d t o c a r r y o u t t h e m e r g e i s p r a c t i c a l l y   N 

= D B  , w h e r e   N 

=  L k D  i s t h e n u m b e r  

o f r e c o r d s i n t h e m e r g e d o u t p u t . I n o u r s i m u l a t i o n s ,   N 

w a s a l w a y s 1 0 0 0 t i m e s b i g g e r t h a n   k D B  . L o n g e r s i m u l a t i o n s  

t e n d t o b e t i m e c o n s u m i n g .  

T h e a v e r a g e - c a s e s i m u l a t i o n s i n d i c a t e w h e n   k  i s r e a s o n a b l y l a r g e t h a t t h e r e i s l i t t l e o r n o u s h i n g o f b l o c k s b y  

5 5 

Page 69: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 69/203

D  = 5  D  = 1 0  D  = 5 0 

k  = 5 1  0 1  0 1  2 

k  = 1 0 1  0 0 1  0 1  1 

k  = 5 0 1  0 0 1  0 0 1  0 0 

T a b l e 3 . 3   : T h e o v e r h e a d f a c t o r   v  (  k ; D  ) f o r m e m o r y s i z e   M  = ( 2  k  + 4 )  D B  +  k D 

o b t a i n e d f r o m s i m u l a t i o n s .  

D  = 5  D  = 1 0  D  = 5 0 

k  = 5 0  5 6 0  4 7 0  3 7 

k  = 1 0 0  6 1 0  5 2 0  4 0 

k  = 5 0 0  7 1 0  6 3 0  5 1 

T a b l e 3 . 4  : T h e p e r f o r m a n c e r a t i o   C 

S R M 

= C 

D S M 

f o r m e m o r y s i z e   M  = ( 2  k  + 4 )  D B  +  k D 

w h e r e   C 

S R M 

i s c o m p u t e d  

u s i n g t h e o v e r h e a d v a l u e   v  (  k ; D  ) o b t a i n e d f r o m s i m u l a t i o n s .  

S R M . I n t u i t i v e l y , t h e r a t e o f c o n s u m p t i o n ( o n a c c o u n t o f m e r g i n g ) o f t h e b l o c k s i n i n t e r n a l m e m o r y i s s u c h t h a t t h e r e  

i s a l m o s t a l w a y s s p a c e t o r e a d i n t h e n e x t \ s m a l l e s t "   D  b l o c k s w i t h o u t t h e n e e d t o u s h .  

I n o r d e r t o m a k e a s i m i l a r c o m p a r i s o n a s t h e p r e v i o u s s u b s e c t i o n , b u t b a s e d u p o n r e s u l t s o f s i m u l a t i o n s o f t h e  

a l g o r i t h m i t s e l f , w e c o m p u t e d t h e t e r m   C 

S R M 

a n a l o g o u s l y t o   C 

S R M 

u s i n g ( 3 . 3 4 ) , b y u s i n g t h e a v e r a g e - c a s e v a l u e s  

f o r  v  o b t a i n e d f r o m s i m u l a t i o n s o f t h e a l g o r i t h m .  

T a b l e 3 . 4 b e l o w s h o w s t h e   C 

S R M 

= C 

D S M 

r a t i o s s o o b t a i n e d , f o r v a r i o u s   k ; D  p a i r s . W e n o t e t h a t t h e e n t r i e s i n  

T a b l e 3 . 4 a r e s m a l l e r t h a n t h e c o r r e s p o n d i n g e n t r i e s i n T a b l e 3 . 2 , i n d i c a t i n g t h a t S R M ' s p e r f o r m a n c e i s i n d e e d b e t t e r  

t h a n t h a t i m p l i e d b y t h e m o r e p e s s i m i s t i c u p p e r b o u n d . M o r e o v e r , S R M ' s l o w o v e r h e a d i n t h e a v e r a g e - c a s e i n d i c a t e s  

t h a t f o r a l l p r a c t i c a l p u r p o s e s i t i s a n o p t i m a l e x t e r n a l s o r t i n g a l g o r i t h m .  

3 . 1 0 R e a l i s t i c V a l u e s f o r P a r a m e t e r s    k 

,  D  , a n d      B 

W e h a v e s h o w n i n t h e p r e v i o u s s e c t i o n f o r a w i d e r a n g e o f   k  ,  D  , a n d   B  v a l u e s t h a t S R M p e r f o r m s v e r y e c i e n t l y .  

S i n c e n o t e v e r y   k  ,  D  ,  B  t r i p l e t c o r r e s p o n d s t o t h a t o f a r e a l i s t i c m a c h i n e , w e t r y i n t h i s s e c t i o n t o o b t a i n a c r u d e  

a p p r o x i m a t i o n o f t h e r e l a t i v e m a g n i t u d e s o f   k  ,  D  , a n d   B  i n t y p i c a l c o m p u t e r s . W e a r g u e t h a t   k  i s g e n e r a l l y m u c h  

l a r g e r t h a n   D  i n r e a l i s t i c m a c h i n e s , w h i c h i m p l i e s t h a t S R M i s t h e m e t h o d o f c h o i c e o n s u c h m a c h i n e s , s t i l l n o t i c e a b l y  

f a s t e r t h a n D S M .  

I n o u r t e r m i n o l o g y , w h e r e t h e i n t e r n a l m e m o r y s i z e i s   M  = ( 2  k D  + 4  D  )  B  +  k D 

a n d t h e m e r g e o r d e r i s   R  =  k D  , 

t h e e x p r e s s i o n 2  k D  i s r o u g h l y e q u a l t o   M = B  , t h e n u m b e r o f b l o c k s t h a t t i n m a i n m e m o r y , u n d e r t h e r e a l i s t i c  

a s s u m p t i o n t h a t   D  =  O  (  B  ) . L e t u s c o n s i d e r a f a s t , u n i p r o c e s s o r w o r k s t a t i o n a t t a c h e d t o , s a y ,   D  = 5 i n d e p e n d e n t  

d i s k s f o r p a r a l l e l I / O . W e a r e l i k e l y t o n d i n t e r n a l m e m o r i e s o f t h e o r d e r o f 1 0 0 m e g a b y t e s o n s u c h m a c h i n e s a n d d i s k  

b l o c k o r t r a c k s i z e s o f t h e o r d e r o f 1 0 { 5 0 k i l o b y t e s . T h i s w o u l d m e a n t h a t   k  m a y b e o n t h e o r d e r o f 2 0 0 { 1 0 0 0 w h e n  

D  = 5 o n s u c h w o r k s t a t i o n s . I f t h e s a m e a m o u n t o f m a i n m e m o r y i s u s e d w i t h i n s t e a d 1 0 d i s k s a n d 5 0 - k i l o b y t e d i s k  

b l o c k s ,   k  w o u l d b e o n t h e o r d e r o f 1 0 0 . O n t h e o t h e r h a n d w h e n t h e n u m b e r o f d i s k s i s r e l a t i v e l y h i g h a s i n l a r g e - s c a l e  

m u l t i p r o c e s s o r c o m p u t i n g s y s t e m s , w e w o u l d s t i l l e x p e c t   k  t o b e l a r g e , e v e n a f t e r f a c t o r i n g i n t h e i n c r e a s e d b l o c k  

s i z e s t h a t s u c h m a c h i n e s h a v e . T h i s i s p r i m a r i l y b e c a u s e l a r g e - s c a l e c o m p u t i n g s y s t e m s t e n d t o h a v e h u g e i n t e r n a l  

5 6 

Page 70: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 70/203

m e m o r i e s . F o r i n s t a n c e , i n a s y s t e m w i t h 1 0 0 p a r a l l e l d i s k s a n d 1 0 0 - k i l o b y t e d i s k b l o c k s , o n e w o u l d e x p e c t o n t h e  

o r d e r o f a t l e a s t 5 { 1 0 g i g a b y t e s o r m o r e o f a g g r e g a t e i n t e r n a l m e m o r y . T h i s w o u l d c o r r e s p o n d t o   k  b e i n g o n t h e o r d e r  

o f 5 0 0 { 1 0 0 0 o r m o r e . T h e r e l a t i v e m a g n i t u d e s o f   k  ,  D  , a n d   B  c i t e d h e r e a r e m e a n t t o r e p r e s e n t l i k e l y s c e n a r i o s ; i t i s  

c o n c e i v a b l e t h a t t h e r e a r e s y s t e m s w i t h d i e r e n t r e l a t i o n s h i p s a m o n g t h e v a l u e s o f   k  ,  D  , a n d   B 

F o r m o s t v a l u e s o f o f   k  ,  D  , a n d   B  , t h e p r e v i o u s s e c t i o n s h o w s t h a t S R M i s e x t r e m e l y e c i e n t . L o o k i n g b a c k a t  

t h e o c c u p a n c y a n a l y s i s , t h e r e a s o n f o r S R M ' s e c i e n c y i s t h a t t h r o w i n g a l a r g e n u m b e r ( s a y ,   k D  ) o f b a l l s u n i f o r m l y  

a n d i n d e p e n d e n t l y i n t o a s m a l l n u m b e r o f b i n s ( s a y ,   D  ) d o e s r e s u l t i n a m o r e o r l e s s b a l a n c e d d i s t r i b u t i o n . E v e n  

D S M w i l l p e r f o r m w e l l w h e n   D  i s s m a l l a n d   k  i s l a r g e , s i n c e i t w i l l m e r g e   k  r u n s a t a t i m e , w h i c h i s n o t m u c h w o r s e  

t h a n m e r g i n g t h e o p t i m a l   k D  r u n s a t a t i m e . H o w e v e r , S R M ' s e x t r e m e l y l o w o v e r h e a d s t i l l g i v e s i t a n a d v a n t a g e  

o v e r D S M .  

3 . 1 1 C o n c l u s i o n s a n d R e l a t e d N o t e s    

I n t h i s c h a p t e r , w e h a v e p r e s e n t e d a s i m p l e , e c i e n t m e r g e s o r t a l g o r i t h m f o r p a r a l l e l d i s k s t h a t m a k e s a l i m i t e d  

u s e o f r a n d o m i z a t i o n . T h e a n a l y s i s o f t h e I / O p e r f o r m a n c e i n v o l v e d a r e d u c t i o n t o c e r t a i n m a x i m u m o c c u p a n c y  

p r o b l e m s . W e d e m o n s t r a t e d t h e p r a c t i c a l m e r i t o f t h e a l g o r i t h m b y s h o w i n g t h a t i t i n c u r s f e w e r I / O o p e r a t i o n s t h a n  

t h e c o m m o n l y u s e d d i s k - s t r i p e d m e r g e s o r t , e v e n o n r e a l i s t i c p a r a l l e l d i s k s y s t e m s w i t h a s m a l l n u m b e r o f d i s k s . W e  

d i d s o a n a l y t i c a l l y b y e s t i m a t i n g t h e m a x i m u m b u c k e t o c c u p a n c y v a l u e s f o r s e v e r a l   k  ,  D  p a i r s a n d e m p i r i c a l l y b y  

u s i n g s i m u l a t i o n s t o c o u n t t h e n u m b e r o f I / O o p e r a t i o n s n e e d e d b y S R M i n t h e a v e r a g e c a s e . W e a r g u e d t h a t S R M  

m a y b e c o n s i d e r e d a n o p t i m a l e x t e r n a l s o r t i n g a l g o r i t h m i n p r a c t i c e . T h e t e c h n i q u e o f s t a g g e r i n g r u n s m i g h t y i e l d  

f u r t h e r g a i n s i n p r a c t i c e i f c o m b i n e d w i t h o u r g e n e r a l a p p r o a c h .  

A n i n t e r e s t i n g p o i n t t o n o t e i s t h a t t h e e c i e n t p a r a l l e l d i s k m e r g i n g p r o c e d u r e w e p r e s e n t h e r e , w h e r e i n (  M = B  ) 

s o r t e d r u n s a r e m e r g e d t o g e t h e r c a n b e \ r e v e r s e d " t o o b t a i n a n e c i e n t   p a r a l l e l d i s k d i s t r i b u t i o n   p r o c e d u r e , w h e r e i n  

r e c o r d s c a n b e e c i e n t l y d i s t r i b u t e d i n t o (  M = B  ) d i s t i n c t b u c k e t s , e a c h o n e s t r i p e d a c r o s s t h e   D  d i s k s . O n s i m p l e  

e x a m i n a t i o n w e o b s e r v e t h a t t h e b o u n d s i n t h e p r o o f o f T h e o r e m 6 t h a t h o l d f o r t h e   n u m b e r o f r e a d s i n c u r r e d w h i l e  

e x t e r n a l l y m e r g i n g   R  s t r i p e d r u n s e a c h o f l e n g t h   N = R  r e c o r d s a l s o h o l d f o r t h e   n u m b e r o f w r i t e s w h i l e d i s t r i b u t i n g  

a t o t a l o f   N  r e c o r d s i n t o   R  s t r i p e d b u c k e t s .  

A n o t h e r i n t e r e s t i n g n o t e i s t h a t t h e f o r e c a s t a n d u s h a p p r o a c h c a n b e u s e d f r u i t f u l l y i n a f r a m e w o r k f o r c o m p e t -  

i t i v e p r e f e t c h i n g o n p a r a l l e l d i s k s w i t h a n o t i o n o f   l o c a l l o o k a h e a d   , f o r   r e a d - o n c e   s e q u e n c e s B K V V 9 7 ] . I n B K V V 9 7 ]  

w e p r o v e l o w e r b o u n d s o n o n l i n e p a r a l l e l p r e f e t c h i n g f o r r e a d - o n c e s e q u e n c e s a n d p r e s e n t a s i m p l e , o p t i m a l ( u p t o  

c o n s t a n t f a c t o r s ) p r e f e t c h i n g a l g o r i t h m f o r p a r a l l e l d i s k s .  

5 7 

Page 71: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 71/203

C h a p t e r 4      

D e s i g n a n d I m p l e m e n t a t i o n o f S R M i n      

T P I E        

S u m m a r y      

E x t e r n a l s o r t i n g i s a f u n d a m e n t a l t o d a t a b a s e s y s t e m s n o t o n l y f o r p r o d u c i n g s o r t e d o u t p u t b u t a l s o a s a c o r e  

s u b r o u t i n e i n m a n y d a t a b a s e o p e r a t i o n s G r a 9 3 , I B M 9 0 ] . T e c h n o l o g y t r e n d s i n d i c a t e t h a t d e v e l o p i n g t e c h n i q u e s  

t h a t e e c t i v e l y u s e m u l t i p l e d i s k s i n p a r a l l e l i n o r d e r t o s p e e d u p t h e p e r f o r m a n c e o f e x t e r n a l s o r t i n g i s o f p r i m e  

i m p o r t a n c e . T h e   s i m p l e r a n d o m i z e d m e r g i n g   (  S R M  ) m e r g e s o r t a l g o r i t h m p r o p o s e d i n C h a p t e r 3 i s t h e r s t p a r a l l e l  

d i s k s o r t i n g a l g o r i t h m t h a t r e q u i r e s a p r o v a b l y o p t i m a l n u m b e r o f p a s s e s a n d t h a t i s f a s t i n p r a c t i c e . K n u t h K n u 9 8 ,  

S e c t i o n 5 . 4 . 9 ] r e c e n t l y i d e n t i e d S R M ( w h i c h h e c a l l s \ r a n d o m i z e d s t r i p i n g " ) a s t h e m e t h o d o f c h o i c e f o r s o r t i n g w i t h  

p a r a l l e l d i s k s .  

I n t h i s c h a p t e r , w e p r e s e n t a n e c i e n t i m p l e m e n t a t i o n o f S R M , b a s e d u p o n n o v e l a n d e l e g a n t d a t a s t r u c t u r e s .  

W e g i v e a n e w i m p l e m e n t a t i o n f o r S R M ' s   l o o k a h e a d f o r e c a s t i n g   t e c h n i q u e f o r p a r a l l e l p r e f e t c h i n g a n d i t s   f o r e c a s t a n d  

u s h   t e c h n i q u e f o r b u e r m a n a g e m e n t . O u r t e c h n i q u e s a m o u n t t o a s i g n i c a n t i m p r o v e m e n t i n t h e w a y S R M c a r r i e s  

o u t t h e   p a r a l l e l , i n d e p e n d e n t   d i s k a c c e s s e s n e c e s s a r y t o e c i e n t l y r e a d b l o c k s o f i n p u t r u n s d u r i n g e x t e r n a l m e r g i n g .  

W e p r e s e n t t h e p e r f o r m a n c e o f S R M o v e r a w i d e r a n g e o f i n p u t s i z e s a n d c o m p a r e i t s p e r f o r m a n c e w i t h t h a t o f  

d i s k - s t r i p e d m e r g e s o r t ( D S M )  , t h e c o m m o n l y u s e d t e c h n i q u e t o i m p l e m e n t e x t e r n a l m e r g e s o r t o n   D  p a r a l l e l d i s k s .  

D S M c o n s i s t s o f u s i n g a s t a n d a r d m e r g e s o r t a l g o r i t h m i n c o n j u n c t i o n w i t h s t r i p e d I / O f o r p a r a l l e l d i s k a c c e s s . S R M  

m e r g e s t o g e t h e r s i g n i c a n t l y m o r e r u n s a t a t i m e c o m p a r e d w i t h D S M , a n d t h u s i t r e q u i r e s f e w e r m e r g e p a s s e s . W e  

d e m o n s t r a t e i n p r a c t i c a l s c e n a r i o s t h a t e v e n t h o u g h t h e s t r e a m i n g s p e e d s f o r m e r g i n g w i t h D S M a r e a l i t t l e h i g h e r  

t h a n t h o s e f o r S R M ( s i n c e D S M m e r g e s f e w e r r u n s a t a t i m e ) , s o r t i n g u s i n g S R M i s s i g n i c a n t l y f a s t e r t h a n w i t h  

D S M , s i n c e S R M r e q u i r e s f e w e r p a s s e s .  

T h e t e c h n i q u e s i n t h i s c h a p t e r c a n b e g e n e r a l i z e d t o m e e t t h e l o a d - b a l a n c i n g r e q u i r e m e n t s o f o t h e r a p p l i c a t i o n s  

u s i n g p a r a l l e l d i s k s , i n c l u d i n g d i s t r i b u t i o n s o r t a n d m u l t i w a y p a r t i t i o n i n g o f a l e i n t o s e v e r a l o t h e r l e s . S i n c e  

b o t h p a r a l l e l d i s k m e r g i n g a n d m u l t i m e d i a p r o c e s s i n g d e a l w i t h s t r e a m s t h a t g e t \ c o n s u m e d " a t n o n u n i f o r m a n d  

p a r t i a l l y p r e d i c t a b l e r a t e s , o u r t e c h n i q u e s f o r l o o k a h e a d b a s e d u p o n f o r e c a s t i n g d a t a m a y h a v e r e l e v a n c e i n v i d e o  

s e r v e r a p p l i c a t i o n s .  

5 8 

Page 72: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 72/203

4 . 1 I n t r o d u c t i o n a n d M o t i v a t i o n      

E x t e r n a l s o r t i n g i s a f u n d a m e n t a l o p e r a t i o n u s e d w i d e l y i n d a t a b a s e s y s t e m s . I t i s u s e d n o t o n l y f o r p r o d u c i n g s o r t e d  

o u t p u t b u t a l s o a s a c o r e s u b r o u t i n e i n m a n y o t h e r d a t a b a s e o p e r a t i o n s G r a 9 3 , I B M 9 0 ] . M o d e r n t e c h n o l o g y t r e n d s  

i n d i c a t e t h a t p r o c e s s o r s p e e d s a r e i n c r e a s i n g a t a f a s t e r r a t e t h a n d i s k d r i v e p e r f o r m a n c e D a h 9 6 , G V W 9 6 ] , a n d s o  

t h e d e v e l o p m e n t o f e x t e r n a l s o r t i n g t e c h n i q u e s c a p a b l e o f u t i l i z i n g m u l t i p l e d i s k s i n p a r a l l e l i s o f p r i m e i m p o r t a n c e  

f o r d a t a b a s e s y s t e m s .  

E x t e r n a l m e r g e s o r t i s t h e m o s t c o m m o n l y u s e d t e c h n i q u e t o p e r f o r m l a r g e - s c a l e s o r t i n g Z L 9 8 ] . I n t h i s c h a p t e r ,  

w e a d d r e s s p r o b l e m s a r i s i n g i n t h e d e v e l o p m e n t o f a s i m p l e a n d e c i e n t p a r a l l e l d i s k m e r g e s o r t . E x t e r n a l m e r g e s o r t  

c o n s i s t s o f a r u n f o r m a t i o n p h a s e , w h i c h p r o d u c e s s o r t e d r u n s , a n d a m e r g e p h a s e , w h i c h m e r g e s s o r t e d r u n s t o  

p r o d u c e t h e s o r t e d o u t p u t . W h i l e i t i s s i m p l e t o m o d i f y r u n f o r m a t i o n t e c h n i q u e s d e v e l o p e d f o r s i n g l e d i s k s y s t e m s  

t o w o r k e c i e n t l y o n p a r a l l e l d i s k s y s t e m s , f u n d a m e n t a l d i c u l t i e s  

n e e d t o b e o v e r c o m e i n o r d e r t o m e r g e t o g e t h e r  

s e v e r a l r u n s , e a c h o n e s t r i p e d a c r o s s t h e d i s k s , i n a m a n n e r t h a t e c i e n t l y u t i l i z e s a l l t h e d i s k s i n p a r a l l e l .  

I n t h i s c h a p t e r , w e p r e s e n t t h e d e s i g n , i m p l e m e n t a t i o n , a n d p e r f o r m a n c e o f a n e x t r e m e l y s i m p l e a n d e c i e n t  

p a r a l l e l d i s k m e r g i n g t e c h n i q u e . T h e m o s t s i g n i c a n t a s p e c t s o f o u r p a r a l l e l d i s k m e r g i n g t e c h n i q u e a r e i t s e l e g a n t  

a n d n o v e l d a t a s t r u c t u r e s a n d t h e p r e f e t c h i n g a n d b u e r m a n a g e m e n t t e c h n i q u e t h a t t o g e t h e r c o n s t i t u t e a p r a c t i c a l  

i m p l e m e n t a t i o n o f t h e e x t e r n a l m e r g e s o r t a l g o r i t h m S R M , w h i c h w a s s h o w n t o h a v e p r o v a b l y e c i e n t p a r a l l e l I / O  

p e r f o r m a n c e g u a r a n t e e s f o r t h e p a r a l l e l d i s k m o d e l o f V i t t e r a n d S h r i v e r V S 9 4 ] . S R M w a s r e c e n t l y i d e n t i e d b y  

K n u t h K n u 9 8 ]  

i n t h e n e w e d i t i o n o f h i s s e m i n a l w o r k a s t h e m e t h o d o f c h o i c e f o r o p t i m a l s o r t i n g o n p a r a l l e l d i s k s .  

A n o t h e r i n t e r e s t i n g a s p e c t o f o u r i m p l e m e n t a t i o n t e c h n i q u e i s t h a t i t c a n e a s i l y b e m o d i e d t o s u i t t h e l o a d b a l a n c i n g  

n e e d s o f o t h e r a p p l i c a t i o n s i n a p a r a l l e l d i s k c o n t e x t , i n c l u d i n g e x t e r n a l d i s t r i b u t i o n s o r t a n d a m u l t i w a y p a r t i t i o n i n g  

o f a l e i n t o o t h e r l e s . T h e t e c h n i q u e w e d e v e l o p t o i m p l e m e n t a l o o k a h e a d m e c h a n i s m v i a f o r e c a s t i n g a l s o h a s  

p o t e n t i a l a p p l i c a t i o n s d u r i n g p a r a l l e l p r e f e t c h i n g i n v i d e o s e r v e r s i n w h i c h m a n y s t r i p e d l e s m a y n e e d t o b e s t r e a m e d  

a t n o n u n i f o r m r a t e s w i t h r e a l t i m e c o n s t r a i n t s .  

A l t h o u g h a t r e m e n d o u s a m o u n t o f r e s e a r c h h a s b e e n c o n d u c t e d o n e x t e r n a l s o r t i n g E C W 9 4 , Z L 9 8 , S a l 8 9 , Z L 9 6 ] ,  

t h e f o c u s h a s l a r g e l y f o c u s s e d o n s i n g l e d i s k s y s t e m s a n d o n g o a l s s u c h a s e c i e n t l a y o u t o f d i s k b l o c k s , e c i e n t  

s c h e d u l i n g o f I / O a t d i s k s , a n d t e c h n i q u e s t o i m p l e m e n t r e a d - a h e a d s i n c o u r s e o f e x t e r n a l s o r t i n g . I n t h i s c h a p t e r ,  

w e f o c u s o n t h e o r t h o g o n a l a p p r o a c h o f m i n i m i z i n g e l a p s e d t i m e b y d e v e l o p i n g t e c h n i q u e s t o e x p l o i t I / O p a r a l l e l i s m  

a n d m i n i m i z e   p a r a l l e l I / O o p e r a t i o n s   i n a s y s t e m c o n t a i n i n g s e v e r a l d i s k s . W h i l e s o m e o f t h e t e c h n i q u e s d e v e l o p e d  

i n E C W 9 4 , Z L 9 8 , S a l 8 9 , Z L 9 6 ] c a n p o t e n t i a l l y b e u s e d i n c o n j u n c t i o n w i t h t h e o n e s w e d e v e l o p h e r e , e x p l o r i n g t h a t  

a v e n u e i s b e y o n d t h e s c o p e o f t h i s c h a p t e r . T h e p a r a l l e l d i s k m o d e l ( P D M ) V S 9 4 ] i s m e a n t f o r d e s i g n i n g a l g o r i t h m s  

I t i s e a s y t o c a r r y o u t a n e c i e n t p a r a l l e l d i s k m e r g e o f s e v e r a l r u n s w h e n e a c h r u n r e s i d e s e n t i r e l y  

o n a s i n g l e d i s k P V 9 2 ] , p r o v i d e d t h e o u t p u t c a n b e s t r i p e d a c r o s s a l l t h e d i s k s . H o w e v e r s u c h a  

m e r g i n g s c h e m e i s f u n d a m e n t a l l y i n e c i e n t f o r a p a r a l l e l d i s k m e r g e s o r t , s i n c e e x t r a t r a n s p o s i t i o n  

p a s s e s w o u l d b e n e e d e d .  

K n u t h r e f e r s t o t h e S R M a l g o r i t h m a s \ r a n d o m i z e d s t r i p i n g " .  

5 9 

Page 73: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 73/203

c a p a b l e o f e x p l o i t i n g I / O p a r a l l e l i s m . I n t h e P D M , a n i n p u t l e c o n t a i n i n g   N  i t e m s  

i s s t r i p e d i n b l o c k s c o n t a i n i n g  

B  i t e m s a c r o s s   D  d i s k d r i v e s a l l o f w h i c h m a y b e u s e d i n p a r a l l e l a s f o l l o w s : I n e a c h I / O o p e r a t i o n , a n a p p l i c a t i o n  

c a n t r a n s f e r a t m o s t o n e b l o c k o f   B  i t e m s b e t w e e n i n t e r n a l m e m o r y a n d e a c h d i s k d r i v e ; s o u p t o   D  b l o c k s c a n b e  

t r a n s f e r r e d i n a s i n g l e I / O o p e r a t i o n . W i t h r e s p e c t t o t h e p r o b l e m o f e x t e r n a l s o r t i n g , r e s u l t s i n V S 9 4 ] a n d e a r l i e r  

w o r k A V 8 8 ] s h o w t h a t g i v e n a n i n t e r n a l m e m o r y c a p a b l e o f h o l d i n g u p t o   M  i t e m s , s o r t i n g a l e o f   N  i t e m s r e q u i r e s  

 

 

D B 

l o g 

M = B 

(  N = B  ) 

 

I / O o p e r a t i o n s . S o r t i n g r e q u i r e s  

 

l o g 

M = B 

(  N = B  ) 

 

p a s s e s   o v e r t h e d a t a ; e a c h p a s s c a n b e d o n e  

i n a l i n e a r n u m b e r o f I / O o p e r a t i o n s (  N = D B   r e a d s a n d   N = D B   w r i t e s ) . T h e m a i n d i c u l t y i n p a r a l l e l d i s k s o r t i n g i s  

l a y i n g o u t i n t e r m e d i a t e d a t a b l o c k s a n d a c c e s s i n g b l o c k s i n s u c h a m a n n e r t h a t \ u s e f u l c o m p u t a t i o n " i s p e r f o r m e d i n  

m e m o r y w h i l e e n s u r i n g t h a t o n a v e r a g e e a c h I / O o p e r a t i o n t r a n s f e r s (  D  ) b l o c k s . S e v e r a l i n t e r e s t i n g p a r a l l e l d i s k  

s o r t i n g a l g o r i t h m s V S 9 4 , N V 9 5 , A P 9 4 ] p e r f o r m i n g a n o p t i m a l n u m b e r  

 

D B 

l o g 

M = B 

(  N = B  ) 

 

o f I / O o p e r a t i o n s h a v e  

b e e n p r o p o s e d , b u t t h e y a r e s o m e w h a t c o m p l i c a t e d a n d d i c u l t t o i m p l e m e n t i n p r a c t i c e .  

A s a c o n s e q u e n c e , a n a t t r a c t i v e a l t e r n a t i v e t o i m p l e m e n t s o r t i n g a l g o r i t h m s f o r p a r a l l e l d i s k s i s t o u s e t h e t e c h n i q u e  

o f  d i s k s t r i p i n g   ( o r  s t r i p e d I / O   ) i n c o n j u n c t i o n w i t h w e l l k n o w n s i n g l e d i s k s o r t i n g t e c h n i q u e s a s f o l l o w s : I n e a c h  

s t r i p e d - I / O o p e r a t i o n , t h e l o g i c a l l o c a t i o n s o f t h e b l o c k s a c c e s s e d a t e a c h o n e o f t h e   D  d i s k s a r e t h e s a m e . L o g i c a l l y ,  

t h e e e c t o f s t r i p e d I / O i s t o r e d u c e t h e n u m b e r o f d i s k s t o 1 a n d i n c r e a s e t h e b l o c k s i z e t o   D B  f r o m t h e a p p l i c a t i o n ' s  

p o i n t o f v i e w . A s a r e s u l t , s i n g l e d i s k a l g o r i t h m s s u c h a s e x t e r n a l m e r g e s o r t a n d e x t e r n a l r a d i x s o r t w i t h b l o c k s i z e  

c o n g u r e d t o   D B  c a n b e i m p l e m e n t e d t o u t i l i z e   D  d i s k s o n a p a r a l l e l d i s k s y s t e m . S i n c e d o u b l e - b u e r e d m e r g e s o r t  

h a s b e e n s h o w n t o b e v e r y e c i e n t S a l 8 9 ] , i t s d i s k - s t r i p e d v e r s i o n , c a l l e d d i s k - s t r i p e d m e r g e s o r t ( D S M ) V e n 9 4 ] , i s  

c o n s i d e r e d p a r t i c u l a r l y a t t r a c t i v e . S o r t i n g a l g o r i t h m s s u c h a s D S M a n d d i s k - s t r i p e d r a d i x s o r t C H 9 6 ] b a s e d u p o n  

s t r i p e d I / O a r e s i m p l e a n d a l l t h e i r I / O o p e r a t i o n s c a n a c h i e v e f u l l   D  - d i s k p a r a l l e l i s m . H o w e v e r , b e c a u s e t h e l o g i c a l  

b l o c k s i z e b l o w s u p f r o m   B  t o  D B  , t h e n u m b e r o f r u n s p a r t i c i p a t i n g i n e a c h m e r g e o f D S M g o e s d o w n b y a f a c t o r  

o f  D  , a n d h e n c e D S M ( a n d f o r s i m i l a r r e a s o n s , a l l o t h e r s t r i p e d - I / O s o r t i n g a l g o r i t h m s ) r e q u i r e a n o n - o p t i m a l n u m b e r  

 

l o g 

M = D B  

(  N = D B   ) 

 

o f p a s s e s o v e r t h e d a t a ; t h e d e g r e e o f n o n - o p t i m a l i t y i n c r e a s e s w i t h   D  a n d m o s t i m p o r t a n t l y ,  

t h e n o n - o p t i m a l i t y s h o w s u p i n p r a c t i c e e v e n f o r a m o d e r a t e l y s m a l l n u m b e r   D  o f d i s k s .  

T h e S R M a l g o r i t h m p r o p o s e d i n C h a p t e r 3 i s t h e r s t p a r a l l e l d i s k s o r t i n g a l g o r i t h m t h a t r e q u i r e s a p r o v a b l y  

o p t i m a l n u m b e r    

 

l o g 

M = B 

(  N = B  ) 

 

o f p a s s e s o v e r t h e d a t a a n d i s s i m p l e e n o u g h t o b e c o n s i d e r e d a c a n d i d a t e f o r  

i m p l e m e n t a t i o n . F o r p r a c t i c a l r a n g e s o f t h e p a r a m e t e r s   B  a n d  D  , e a c h p a s s t a k e s a l i n e a r o p t i m a l n u m b e r   O  (  N = D B   ) 

o f I / O s . W h i l e m e r g i n g , S R M u s e s a g e n e r a l i z a t i o n o f K n u t h ' s   f o r e c a s t i n g   t e c h n i q u e K n u 9 8 ] a n d a n e w b u e r  

m a n a g e m e n t t e c h n i q u e c a l l e d   f o r e c a s t a n d u s h   i n o r d e r t o e c i e n t l y a c c e s s t h e   D  d i s k s i n a   p a r a l l e l , i n d e p e n d e n t  

m a n n e r f u n d a m e n t a l l y d i e r e n t f r o m s t r i p e d I / O . T h e b a s i c p r e f e t c h i n g t e c h n i q u e i n S R M i s t o u s e f o r e c a s t i n g  

i n f o r m a t i o n t o r e a d i n t h e \ s m a l l e s t " b l o c k f r o m e a c h o n e o f t h e   D  d i s k s i n e v e r y I / O o p e r a t i o n ; i f t h e r e i s n o t  

B y i t e m s , w e r e f e r t o r e c o r d s o r t u p l e s . W h i l e d i s c u s s i n g I / O c o m p l e x i t y b o u n d s , i t i s c o n v e n i e n t  

t o s t a t e b l o c k s i z e s a n d l e s i z e s i n t e r m s o f i t e m s i n s t e a d o f b y t e s .  

6 0 

Page 74: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 74/203

e n o u g h s p a c e i n i n t e r n a l m e m o r y t o r e a d   D  b l o c k s , S R M s i m p l y   u s h e s   ( w i t h o u t a n y I / O ) a s u c i e n t n u m b e r o f  

\ l a r g e s t " b l o c k s f r o m m e m o r y .  

4 . 1 . 1 O u r C o n t r i b u t i o n s  

I n t h i s c h a p t e r , w e p r e s e n t n o v e l a n d e l e g a n t d a t a s t r u c t u r e s a n d t e c h n i q u e s t o i m p l e m e n t t h e f o r e c a s t a n d u s h b u e r  

m a n a g e m e n t s c h e m e o f S R M . T h e l a t t e r s c h e m e , a s p r o p o s e d i n C h a p t e r 3 , r e q u i r e s t h e u s e o f   D  s e p a r a t e p r i o r i t y  

q u e u e s C L R 9 0 ] , e a c h c o r r e s p o n d i n g t o a u n i q u e d i s k a n d e a c h i n v o l v i n g   R  f o r e c a s t i n g k e y s a t a n y t i m e , w h e r e   R  i s 

t h e m e r g e o r d e r . F u r t h e r m o r e , t h e s c h e m e i n C h a p t e r 3 d i d n o t c o v e r d e t a i l s o f i n t e r n a l m e m o r y m a n a g e m e n t a n d  

h o w t o e c i e n t l y t r a c k d o w n t h e \ l a r g e s t " b l o c k s i n m e m o r y a t t h e t i m e o f t h e u s h o p e r a t i o n s . I n t h i s c h a p t e r , w e  

p r e s e n t a n i m p l e m e n t a t i o n o f t h e f o r e c a s t i n g a n d u s h s c h e m e t h a t r e q u i r e s o n l y a s i n g l e p r i o r i t y q u e u e c o m p r i s i n g  

R  f o r e c a s t i n g k e y s , t o b e u s e d i n c o n j u n c t i o n w i t h   D  o r d i n a r y q u e u e s i m p l e m e n t e d a s s i m p l e a r r a y s . T h e n o v e l t y l i e s  

i n t h e w a y w e s t o r e , u s e , a n d m a n a g e f o r e c a s t i n g d a t a d u r i n g t h e m e r g i n g p r o c e s s . W e a l s o s h o w h o w t o i m p l e m e n t  

m e m o r y m a n a g e m e n t a n d h o w t o p e r f o r m u s h o p e r a t i o n s . O u r d e s i g n s i g n i c a n t l y s i m p l i e s t h e i m p l e m e n t a t i o n o f  

S R M .  

T h e s e c o n d i n t e r e s t i n g c o n t r i b u t i o n o f o u r c h a p t e r i s t h e p r a c t i c a l c o m p a r i s o n o f t h e m e r g i n g p h a s e i m p l e m e n t a t i o n  

o f D S M a n d S R M , o n a s t a t e - o f - t h e - a r t c o m p u t e r s y s t e m c o n s i s t i n g o f s i x d i s k s t h a t c a n b e u s e d i n d e p e n d e n t l y a n d  

i n p a r a l l e l . I n e a c h m e r g e o p e r a t i o n , D S M m e r g e s t o g e t h e r a p p r o x i m a t e l y   M =  2  D B  r u n s , w h e r e a s S R M m e r g e s  

t o g e t h e r a s i g n i c a n t l y l a r g e r n u m b e r o f r u n s ( w h i c h c a n g o u p t o a p p r o x i m a t e l y   M =  2  B  ) . D S M w i l l t h u s t e n d t o  

h a v e h i g h e r d i s k l o c a l i t y i n e a c h m e r g i n g o p e r a t i o n , c o m p a r e d t o S R M . A s a r e s u l t , e a c h m e r g e p a s s o f S R M i n c u r s  

s o m e o v e r h e a d r e l a t i v e t o e a c h m e r g e o f D S M , o n a c c o u n t o f h i g h e r d i s k l a t e n c i e s ( s i n c e a l a r g e r n u m b e r o f s t r e a m s  

i s i n v o l v e d ) a s w e l l a s b e c a u s e e a c h m e r g e p a s s m a y r e q u i r e   m o r e   t h a n   N = D B   r e a d I / O o p e r a t i o n s , a s w e n o t e d i n  

C h a p t e r 3 . H e n c e , e v e n i f S R M r e q u i r e s a s m a l l e r n u m b e r o f m e r g e p a s s e s o n a g i v e n i n p u t , c o m p a r i n g t h e p r a c t i c a l  

p e r f o r m a n c e o f S R M a n d D S M ' s m e r g i n g p h a s e s r e m a i n s a n i n t e r e s t i n g e x e r c i s e . O u r i n t u i t i o n i s b o r n e o u t i n p r a c t i c e  

w h e n w e n d t h a t t h e d a t a s t r e a m i n g s p e e d a t t a i n e d b y D S M w h i l e m e r g i n g i s n o t i c e a b l y b e t t e r t h a n t h a t o f S R M .  

H o w e v e r , t h e o v e r h e a d i n o u r i m p l e m e n t a t i o n o f S R M r e l a t i v e t o D S M i s s m a l l e n o u g h t h a t S R M ' s m e r g i n g p h a s e  

e a s i l y o u t p e r f o r m s D S M ' s m e r g i n g p h a s e b y a s i g n i c a n t m a r g i n .  

I n S e c t i o n 4 . 2 b e l o w , w e g o t h r o u g h s o m e p r e l i m i n a r i e s f o r e x t e r n a l m e r g e s o r t , d i s c u s s r e l e v a n t p r e v i o u s w o r k  

a n d d e s c r i b e D S M . I n S e c t i o n 4 . 3 , w e p r e s e n t t h e S R M m e r g i n g a l g o r i t h m a n d s k e t c h p r e v i o u s r e s u l t s f o r S R M .  

I n S e c t i o n 4 . 4 , w e p r e s e n t o u r i m p l e m e n t a t i o n o f t h e S R M m e r g i n g a l g o r i t h m , i n c l u d i n g s o m e p s e u d o - c o d e . I n  

S e c t i o n 4 . 5 , w e p r e s e n t v a r i o u s a s p e c t s o f t h e p e r f o r m a n c e c o m p a r i s o n o f t h e m e r g i n g p h a s e s o f S R M a n d D S M . I n  

S e c t i o n 4 . 6 , w e p r e s e n t v a r i o u s a p p l i c a t i o n s o f g e n e r a l i z a t i o n s o f t h e i m p l e m e n t a t i o n t e c h n i q u e s w e d e v e l o p e d h e r e  

a n d n a l l y , i n S e c t i o n 4 . 7 , w e m a k e s o m e c o n c l u d i n g r e m a r k s i n c l u d i n g a v e n u e s f o r r e l a t e d f u t u r e w o r k .  

6 1 

Page 75: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 75/203

Page 76: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 76/203

I n g e n e r a l t h e l e a d i n g b l o c k o f e v e r y i n p u t r u n n e e d s t o b e i n i n t e r n a l m e m o r y f o r a m e r g e c o m p u t a t i o n t o p r o c e e d ,  

u n l e s s t h e i n p u t r u n h a s b e e n c o m p l e t e l y d e p l e t e d b y t h e m e r g e . A s a r e s u l t , t h e o r d e r i n w h i c h i n p u t b l o c k s a r e  

r e a d i n t o m e m o r y t e n d s t o a p p r o x i m a t e l y f o l l o w t h e p a r t i c i p a t i o n o r d e r o f i n p u t b l o c k s .  

4 . 2 . 3 P r e v i o u s W o r k o n E x t e r n a l M e r g i n g  

I t i s b e y o n d t h e s c o p e o f t h i s c h a p t e r t o c a r r y o u t a c o m p r e h e n s i v e s u r v e y o f t h e v a s t b o d y o f r e s e a r c h o n e x t e r n a l  

m e r g i n g . S a l z b e r g S a l 8 9 ] s h o w e d t h a t d o u b l e b u e r i n g K n u 9 8 ] w i t h r e a s o n a b l y l a r g e s i z e d b u e r s i s a n e c i e n t  

a p p r o a c h t o i m p l e m e n t e x t e r n a l m e r g i n g i n g e n e r a l . Z h e n g a n d L a r s o n Z L 9 6 ] s u g g e s t e d u s i n g s i x t o t e n o a t i n g  

b u e r s p e r i n p u t r u n o n a v e r a g e a n d p r o p o s e d a p l a n n i n g s t r a t e g y t h a t u t i l i z e s t h e e x t r a b u e r s p a c e t o r e a d  

d i s k b l o c k s i n a n o r d e r d i e r e n t f r o m p a r t i c i p a t i o n o r d e r w i t h a v i e w t o o p t i m i z i n g s e e k t i m e . E s t i v i l l - C a s t r o  

a n d W o o d E C W 9 4 ] e x t e n d e d t h i s w o r k , i n p a r t , t o e x p l o i t p r e - e x i s t i n g o r d e r i n i n p u t d a t a . R e c e n t l y , Z h a n g a n d  

L a r s o n Z L 9 8 ] s u g g e s t e d f u r t h e r i m p r o v e m e n t s t o t h e p l a n n i n g s t r a t e g y v i a e x t e n d e d f o r e c a s t i n g a n d b l o c k c l u s t e r i n g .  

T h e a b o v e m e n t i o n e d a p p r o a c h e s t r y t o m a x i m i z e o v e r l a p p i n g o f I / O a n d c o m p u t a t i o n a n d m i n i m i z e d e l a y s o n  

a c c o u n t o f d i s k l a t e n c y d u r i n g e x t e r n a l m e r g i n g . W h i l e Z h e n g a n d L a r s o n d o a p p l y t h e i r p l a n n i n g s t r a t e g y i n  

a m u l t i p l e d i s k s i t u a t i o n , t h e s e s t u d i e s a r e p r i m a r i l y o r i e n t e d t o w a r d s s i n g l e d i s k s y s t e m s . O u r i n t e r e s t l i e s i n  

s p e e d i n g u p e x t e r n a l m e r g i n g u s i n g t h e o r t h o g o n a l a p p r o a c h o f m a x i m i z i n g I / O p a r a l l e l i s m . A l t h o u g h s o m e o f t h e  

a b o v e m e n t i o n e d a p p r o a c h e s c a n b e u s e d i n c o n j u n c t i o n w i t h p a r a l l e l I / O , w e d o n o t p u r s u e t h a t l i n e o f w o r k i n  

t h i s c h a p t e r . I n t h i s c h a p t e r , a s i n t h e N O W S o r t A D A D C  

9 7 ] i m p l e m e n t a t i o n , w e a s s u m e t h a t e c i e n t l e s y s t e m  

p e r f o r m a n c e c a n b e o b t a i n e d s o l o n g a s t h e l o g i c a l b l o c k s i z e   B  i s r e a s o n a b l y l a r g e ( o f t h e o r d e r o f 2 5 6 K B ) a n d   B  i s 

a l s o t h e s i z e o f a n i n p u t o r o u t p u t b u e r i n i n t e r n a l m e m o r y . S i n c e a l l t h e m e r g i n g a p p r o a c h e s m e n t i o n e d i n t h e a b o v e  

p a r a g r a p h u s e , o n a v e r a g e , a c o n s t a n t n u m b e r o f i n p u t b u e r s f o r e a c h i n p u t r u n , t h e m e r g e o r d e r i s   R  =  O  (  M = B  ) 

a n d t h e n u m b e r o f m e r g e p a s s e s r e q u i r e d i s r o u g h l y l o g  

M = B 

(  N = M  ) , w h i c h i s o p t i m a l f o r t h e c a s e w h e n   D  = 1

4 . 2 . 4 P a r a l l e l D i s k M e r g i n g i n D S M  

D S M i s a d o u b l e - b u e r e d m e r g e s o r t t h a t c a n b e e a s i l y i m p l e m e n t e d w i t h s t r i p e d I / O . T h e N O W S o r t A D A D C  

9 7 ] 

i m p l e m e n t a t i o n u s e s a d i s k - s t r i p e d m e r g e s o r t t o l o c a l l y p e r f o r m a n e x t e r n a l s o r t a t e a c h i n d i v i d u a l w o r k s t a t i o n . B y  

t h e n a t u r e o f s t r i p e d I / O , t h e s i z e o f e a c h i n p u t b u e r i n D S M i s   D B  a n d t h e o r d e r   R  o f e x t e r n a l m e r g i n g i n D S M i s  

R    M =  2  D B  . E a c h r u n i s s t r i p e d b l o c k w i s e a c r o s s a l l t h e   D  d i s k s i n a r o u n d - r o b i n m a n n e r . I n i t i a l l y t h e t w o b u e r s  

o f e a c h i n p u t r u n a r e r e a d i n t o i n t e r n a l m e m o r y . D u r i n g t h e m e r g e , w h e n e v e r a r u n ' s l e a d i n g b u e r g e t s d e p l e t e d a  

p a r a l l e l r e a d o p e r a t i o n t o l o a d t h e n e x t   D B  i t e m s i n t o t h e f r e e i n p u t b u e r i s i s s u e d , w h i l e t h e m e r g e p r o c e e d s u s i n g  

t h e o t h e r i n p u t b u e r o f t h e r u n . T h e o u t p u t o f t h e m e r g e i s w r i t t e n i n u n i t s o f   D B  i t e m s a n d i s d o u b l y b u e r e d a s  

w e l l . C l e a r l y , D S M h a s t h e a d v a n t a g e o f b e i n g s i m p l e , e n j o y i n g f u l l   D  - d i s k p a r a l l e l i s m , a n d a n o v e r l a p o f c o m p u t a t i o n  

a n d I / O a c t i v i t y . H o w e v e r , t h e n u m b e r o f m e r g e p a s s e s r e q u i r e d i n D S M i s a p p r o x i m a t e l y  

 

l o g 

M = D B  

(  N = M  ) 

 

, w h i c h  

6 3 

Page 77: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 77/203

c a n b e l a r g e r t h a n t h e o p t i m a l n u m b e r  

 

l o g 

M = B 

(  N = M  ) 

 

o f p a s s e s b y a f a c t o r a p p r o a c h i n g l o g   D  . M o r e i m p o r t a n t l y ,  

f r o m a p r a c t i c a l p o i n t o f v i e w , t h e i n c r e a s e i n t h e n u m b e r o f m e r g e p a s s e s s h o w s u p e v e n w h e n t h e n u m b e r   D  o f d i s k s  

i s o n l y m o d e r a t e l y h i g h , t h u s h i n d e r i n g t h e p e r f o r m a n c e o f D S M i n p r a c t i c e .  

4 . 2 . 5 D i c u l t y o f M e r g i n g O p t i m a l l y w i t h P a r a l l e l I n d e p e n -  

d e n t D i s k s  

O p t i m a l s o r t i n g o n p a r a l l e l d i s k s r e q u i r e s t h e a b i l i t y t o a c c e s s   D  d i s k s i n a   p a r a l l e l , i n d e p e n d e n t   m a n n e r i n w h i c h  

d i e r e n t l o g i c a l b l o c k s m a y b e a c c e s s e d o n e a c h d i s k ; t h i s a c c e s s m o d e i s t h e r e f o r e f u n d a m e n t a l l y d i e r e n t f r o m  

s t r i p e d I / O . I n o r d e r t o o p t i m a l l y s o r t u s i n g p a r a l l e l d i s k s , a m e r g e s o r t n e e d s t o o p t i m a l l y m e r g e a l a r g e n u m b e r  

R  = (  M = B  ) o f r u n s s t r i p e d a c r o s s   D  d i s k s i n e a c h m e r g e o p e r a t i o n .  

F u n d a m e n t a l d i c u l t i e s a r i s e f r o m t h e f a c t t h a t v e r y o f t e n d u r i n g t h e m e r g e t h e r e a r e t i m e s w h e n t h e s e t o f t h e  

R  n e x t p a r t i c i p a t i n g b l o c k s a l l r e s i d e o n a s m a l l s u b s e t o f t h e   D  d i s k s , t h e r e b y c a u s i n g \ h o t s p o t s " . S u c h h o t s p o t s  

a r e c a u s e d b y t h e u n p r e d i c t a b l e , n o n u n i f o r m r a t e s a t w h i c h r u n s g e t c o n s u m e d b y t h e m e r g e . W h e n t h e r e a r e  

h o t s p o t s , r e a d i n g t h e s e t o f t h e n e x t   R  p a r t i c i p a t i n g b l o c k s c a n t a k e m a n y m o r e p a r a l l e l I / O s t h a n t h e o p t i m a l  

n u m b e r   d  R = D  e  p a r a l l e l I / O s . W e r e f e r t h e r e a d e r t o V S 9 4 ] f o r m o r e i n t u i t i o n r e g a r d i n g t h e d i c u l t y m e r g i n g w i t h  

p a r a l l e l i n d e p e n d e n t d i s k s . N o d i n e a n d V i t t e r N V 9 5 ] o v e r c a m e t h i s d i c u l t y b y p e r f o r m i n g e x t e r n a l m e r g i n g b y  

r s t   a p p r o x i m a t e l y   m e r g i n g t h e r u n s f o l l o w e d b y a d d i t i o n a l p a s s e s t o r e n e t h e m e r g e . A g g a r w a l a n d P l a x t o n ' s  

S h a r e s o r t A P 9 4 ] t e c h n i q u e d o e s r e p e a t e d m e r g i n g a n d h a s a c c o m p a n y i n g o v e r h e a d s . E a c h o f t h e s e a p p r o a c h e s  

i n v o l v e s e x t r a o v e r h e a d s a n d a r e n o t i d e a l f o r p r a c t i c a l i m p l e m e n t a t i o n .  

4 . 3 S R M A l g o r i t h m          

T h e S R M a l g o r i t h m o v e r c o m e s t h e d i c u l t i e s i n v o l v e d i n p a r a l l e l d i s k m e r g i n g b y u s i n g a g e n e r a l i z a t i o n o f t h e  

f o r e c a s t i n g t e c h n i q u e i n a n e l e g a n t p r e f e t c h i n g a n d b u e r m a n a g e m e n t s c h e m e . I n s i n g l e d i s k s y s t e m s , f o r e c a s t i n g  

r e f e r s t o t h e t e c h n i q u e o f u s i n g t h e l a s t k e y o f a n i n - m e m o r y b l o c k o f a r u n t o p r e d i c t w h e n t h e n e x t b l o c k o f t h a t r u n  

w i l l b e g i n p a r t i c i p a t i n g i n t h e m e r g e . I n S R M , w h e n e v e r i n t e r m e d i a t e r u n s a r e w r i t t e n t o d i s k ( d u r i n g r u n f o r m a t i o n  

o r a s t h e o u t p u t o f a m e r g e o p e r a t i o n ) , t h e y a r e s t r i p e d b l o c k w i s e i n a r o u n d - r o b i n m a n n e r a c r o s s t h e   D  d i s k s . W h i l e  

w r i t i n g t h e b l o c k s o f t h e   r  t h r u n t o d i s k , S R M i m p l a n t s t h e f o l l o w i n g f o r e c a s t i n g i n f o r m a t i o n i n e a c h b l o c k o f t h a t  

I n t h e N O W S o r t p a r a m e t e r s f o r t h e M i n u t e s o r t r e c o r d , t h e s i z e o f t h e l o c a l i n t e r n a l m e m o r y a n d  

t h e s i z e o f t h e l e t h a t n e e d s t o b e s o r t e d l o c a l l y a t e a c h w o r k s t a t i o n i s s u c h t h a t t h e n u m b e r o f  

r u n s m e r g e d d u r i n g t h e m e r g i n g p h a s e i s v e r y s m a l l , s o t h e i r a p p l i c a t i o n o f d i s k - s t r i p e d m e r g e s o r t  

i n v o l v e s o n l y a s i n g l e m e r g e p a s s .  

I t i s e n o u g h t o m e r g e   R  =  

 

(  M = B  ) 

 

r u n s , f o r a n y c o n s t a n t 0   < c    1 , i n e a c h m e r g e o p e r a t i o n  

i n o r d e r t o a t t a i n o p t i m a l i t y ( w i t h i n c o n s t a n t f a c t o r s ) i n t h e n u m b e r o f p a s s e s .  

6 4 

Page 78: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 78/203

r u n : I n t h e   i  t h b l o c k o f t h e   r  t h r u n , i t s t o r e s t h e   k e y v a l u e   o f t h e l a s t i t e m i n t h e (  i  +  D    1 ) s t b l o c k  

o f t h a t r u n .  

S R M u s e s t h e f o r e c a s t i n g i n f o r m a t i o n i n t h e   i  t h b l o c k o f a r u n t o p r e d i c t t h e t i m e a t w h i c h t h e   (  i  +  D  )  t h b l o c k o f  

t h a t r u n b e g i n s p a r t i c i p a t i n g i n t h e m e r g e .   I f t h e   i  t h b l o c k o f a r u n i s f r o m d i s k   d  , t h e n t h e (  i  +  D  ) t h b l o c k o f t h a t  

r u n i s t h e   n e x t b l o c k o f t h a t r u n o n d i s k   d 

T h e r o u n d - r o b i n b l o c k w i s e s t r i p i n g e m p l o y e d b y S R M w h i l e w r i t i n g o u t r u n s t o d i s k d i e r s f r o m t h e u s u a l s t r i p i n g  

t e c h n i q u e i n t h e f o l l o w i n g s e n s e : T h e r s t b l o c k o f a r u n i s w r i t t e n o n a d i s k   d 

c h o s e n u n i f o r m l y a t r a n d o m f r o m  

a m o n g t h e   D  d i s k s ; t h e r e a f t e r , b l o c k s o f t h e r u n a r e p l a c e d i n t h e u s u a l r o u n d - r o b i n f a s h i o n o n d i s k s (  d 

+ 1 ) m o d   D  , 

(  d 

+ 2 ) m o d   D  ,  a n d s o o n . T h i s i s t h e o n l y a p p l i c a t i o n o f r a n d o m i z a t i o n i n S R M . T h e r a n d o m i z a t i o n h e l p s S R M  

a v o i d p o o r m e r g i n g p e r f o r m a n c e f o r a n y p a r t i c u l a r o r d e r i n g o f i t e m s i n t h e i n p u t l e . T h e p r o b a b i l i s t i c a n a l y s i s i n  

C h a p t e r 3 o f S R M ' s I / O p e r f o r m a n c e i s w i t h r e s p e c t t o t h e r a n d o m i z a t i o n m e n t i o n e d h e r e ; t h e r e a r e n o a s s u m p t i o n s  

w h a t s o e v e r r e g a r d i n g t h e i n p u t l e t o b e s o r t e d .  

4 . 3 . 1 T h e F o r e c a s t a n d F l u s h S c h e m e  

W e n o w p r e s e n t t h e s i m p l e p r e f e t c h i n g a n d b u e r m a n a g e m e n t s c h e m e e m p l o y e d b y S R M . T h e t o t a l n u m b e r o f  

i n t e r n a l m e m o r y b l o c k s u s e d b y S R M a s p r e s e n t e d i n C h a p t e r 3 i s   D  b l o c k s f o r b l o c k s a c t i v e l y b e i n g r e a d i n t o  

m e m o r y ,  R  b l o c k s t o h o l d t h e   R  l e a d i n g b l o c k s o f t h e   R  r u n s ,   R  b l o c k s f o r h o l d i n g p r e f e t c h e d d a t a , a n d a n a d d i t i o n a l  

2  D  b l o c k s f o r o u t p u t r u n d a t a .  

T h e  o a t i n g b u e r s   t e c h n i q u e i s u s e d t o i m p l e m e n t i n t e r n a l m e m o r y m a n a g e m e n t .  

T h e i n t e r n a l m e r g e p r o c e s s w o r k s o n t h e   R  l e a d i n g b l o c k s c o r r e s p o n d i n g t o t h e   R  i n p u t r u n s t o p r o d u c e b l o c k s o f  

t h e o u t p u t r u n . A s s o o n a s a n i n - m e m o r y b l o c k b e c o m e s a l e a d i n g b l o c k , i t i s p i n n e d i n i n t e r n a l m e m o r y u n t i l i t  

g e t s d e p l e t e d . T h e s a m e h o l d s f o r a b l o c k t h a t b e c o m e s a l e a d i n g b l o c k w h i l e s t i l l o n d i s k , a s s o o n a s i t i s r e a d i n t o  

i n t e r n a l m e m o r y . W h e n e v e r e a c h o n e o f a s e t o f   D  b l o c k s o f t h e o u t p u t r u n h a s i t s f o r e c a s t i n g i n f o r m a t i o n , t h a t  

s e t o f b l o c k s i s w r i t t e n o u t w i t h f u l l   D  - d i s k p a r a l l e l i s m . T h e f o r e c a s t a n d u s h s c h e m e f o r p r e f e t c h i n g a n d b u e r  

m a n a g e m e n t i n o r d e r t o \ f e e d " t h e i n t e r n a l c o m p u t a t i o n w o r k s a s f o l l o w s :  

1 . U n t i l t h e r e a r e n o m o r e i n p u t b l o c k s t o b e r e a d i n t o i n t e r n a l m e m o r y :  

( a ) F i n d o u t , f o r e a c h d i s k , t h e s m a l l e s t b l o c k ( w i t h r e s p e c t t o p a r t i c i p a t i o n o r d e r ) a m o n g a l l b l o c k s o n t h a t  

d i s k . S u p p o s e t h a t o f t h e s e   D  s m a l l e s t b l o c k s ( o n e p e r d i s k ) ,    ̀ o f t h e m a r e l e a d i n g b l o c k s o f t h e i r r e s p e c t i v e  

r u n s , w h e r e 0      ̀   D 

( b ) I f t h e n u m b e r o f f r e e b l o c k s a v a i l a b l e t o h o l d p r e f e t c h e d d a t a i s   D     ̀   f  , f o r s o m e   f >  0 , t h e n   u s h  

o u t  f  o f t h e l a r g e s t b l o c k s ( w i t h r e s p e c t t o p a r t i c i p a t i o n o r d e r ) a m o n g a l l t h e p r e f e t c h e d b l o c k s . T h i s  

I n t h e o r i g i n a l p r e s e n t a t i o n o f S R M , t h e f o r e c a s t i n g i n f o r m a t i o n i n t h e   i  t h b l o c k o f a r u n i s t h e  

k e y v a l u e o f t h e r s t i t e m i n t h e (  i  +  D  ) t h b l o c k o f t h a t r u n . H o w e v e r , t h e a p p r o a c h h e r e , t a k e n  

f r o m K n u 9 8 ] , i s a l i t t l e s i m p l e r .  

K n u t h K n u 9 8 ] p o i n t s o u t t h a t S R M c a n b e c o n g u r e d t o w o r k w i t h a n y n u m b e r   R  +  m 

o f b l o c k s  

f o r p r e f e t c h e d d a t a a s l o n g a s   m 

  D    1 ; s o t h e r e i s s o m e e x i b i l i t y h e r e .  

6 5 

Page 79: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 79/203

m e r e l y i n v o l v e s t r a c k i n g d o w n t h e   f  l a r g e s t b l o c k s a m o n g t h e p r e f e t c h e d b l o c k s i n i n t e r n a l m e m o r y a n d  

t h e n s i m p l y m a r k i n g t h e m a s f r e e b l o c k s ; s o t h e r e i s n o I / O i n v o l v e d i n u s h i n g . I f a t l e a s t o n e b l o c k i s  

u s h e d , u p d a t e t h e i n f o r m a t i o n a b o u t t h e s m a l l e s t b l o c k s o n t h e   D  d i s k s ( s i n c e w e n o w p r e t e n d a s t h o u g h  

t h e u s h e d b l o c k s a r e o n d i s k . )  

( c ) I n p a r a l l e l , r e a d i n t h e s m a l l e s t b l o c k f r o m e a c h o n e o f t h e   D  d i s k s .  

4 . 3 . 2 P r o v a b l e P e r f o r m a n c e G u a r a n t e e s  

A s s t a t e d a b o v e , S R M m e r g e s a p p r o x i m a t e l y   M =  2  B  r u n s i n e a c h m e r g e o p e r a t i o n a n d s o t h e n u m b e r o f m e r g e p a s s e s  

i t r e q u i r e s i s    

 

l o g 

M = B 

(  N = M  ) 

 

, w h i c h i s o p t i m a l . W r i t e o p e r a t i o n s d u r i n g S R M p r o c e e d a t f u l l d i s k p a r a l l e l i s m a s  

i n d i c a t e d a b o v e . A r i g o r o u s a n a l y s i s o f t h e e x p e c t e d n u m b e r o f p a r a l l e l r e a d s ( S t e p 1 c ) r e q u i r e d i n S R M i s p r e s e n t e d  

i n C h a p t e r 3 ; h e r e , t h e e x p e c t a t i o n i s w i t h r e s p e c t t o t h e r a n d o m i z a t i o n u s e d b y S R M t o c h o o s e t h e s t a r t i n g d i s k f o r  

e a c h i n t e r m e d i a t e o u t p u t r u n , a n d t h e a n a l y s i s i s w o r s t - c a s e a n d s o h o l d s f o r a n y a r b i t r a r y i n p u t s .  

T h e u s h i n g o f b l o c k s i n S t e p 1 b a b o v e m a y l e a d t o e x t r a p a r a l l e l r e a d o p e r a t i o n s ; s o t h e e x p e c t e d n u m b e r o f  

p a r a l l e l r e a d o p e r a t i o n s r e q u i r e d i n a n S R M m e r g i n g p a s s c a n , i n g e n e r a l , e x c e e d   N = D B   . T h i s b r i n g s u s t o t h e  

f o l l o w i n g d e n i t i o n .  

D e n i t i o n 1 8   T h e p a r a l l e l I / O o v e r h e a d     o f a n S R M m e r g i n g p a s s i s d e n e d a s t h e r a t i o b e t w e e n t h e n u m b e r o f  

p a r a l l e l r e a d o p e r a t i o n s i n c u r r e d d u r i n g t h a t m e r g i n g p a s s a n d t h e o p t i m a l q u a n t i t y   N = D B  

T h e a n a l y s i s o f S R M i n C h a p t e r 3 i m p l i e s t h a t f o r m o s t v a l u e s o f   M  ,  D  , a n d   B  w h i c h t o g e t h e r d e t e r m i n e i n  

S R M , t h e e x p e c t e d v a l u e o f     i s 1 o r a s m a l l c o n s t a n t g r e a t e r t h a n 1 . A l t h o u g h t h e u p p e r b o u n d a n a l y s i s i n d i c a t e s  

t h a t t h e r e a r e s o m e   R ; D  p a i r s f o r w h i c h t h e e x p e c t e d n u m b e r o f p a r a l l e l r e a d o p e r a t i o n s i n a n S R M m e r g i n g p a s s i s  

n o n - o p t i m a l b y s m a l l f a c t o r s , s i m u l a t i o n s ( s e e C h a p t e r 3 ) s u g g e s t t h a t t h e u p p e r b o u n d a n a l y s i s i s p e s s i m i s t i c , a n d  

S R M ' s p e r f o r m a n c e i n p r a c t i c e i s o p t i m a l , w i t h     c l o s e t o 1 . K n u t h K n u 9 8 ] r e c e n t l y i d e n t i e d S R M a s t h e m e t h o d  

o f c h o i c e f o r s o r t i n g o n p a r a l l e l d i s k s .  

4 . 3 . 3 D a t a S t r u c t u r e s R e q u i r e d i n t h e S t r a i g h t f o r w a r d I m -  

p l e m e n t a t i o n  

I n a d i r e c t i m p l e m e n t a t i o n o f S R M a s s t a t e d i n C h a p t e r 3 , o n e   f o r e c a s t i n g h e a p   w o u l d b e r e q u i r e d f o r e a c h o n e  

o f t h e   D  d i s k s i n o r d e r t o k e e p t r a c k o f t h e s m a l l e s t b l o c k ( w . r . t . p a r t i c i p a t i o n o r d e r ) o n e a c h d i s k a t a n y t i m e .  

E a c h f o r e c a s t i n g h e a p i s b a s i c a l l y a p r i o r i t y q u e u e C L R 9 0 ] . I n g e n e r a l , a t a n y t i m e , t h e f o r e c a s t i n g h e a p f o r d i s k   d 

w o u l d c o n t a i n   R  e l e m e n t s , e a c h o n e c o r r e s p o n d i n g t o t h e s m a l l e s t b l o c k o f a u n i q u e i n p u t r u n o n d i s k   d  a t t h a t  

t i m e . W h e n e v e r a p a r a l l e l r e a d o p e r a t i o n i s c o m p l e t e d , a l l t h e   D  f o r e c a s t i n g h e a p s w o u l d h a v e t o b e u p d a t e d . F l u s h  

o p e r a t i o n s a l s o r e q u i r e u p d a t i n g o n e o r m o r e f o r e c a s t i n g h e a p s .  

6 6 

Page 80: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 80/203

A d d i t i o n a l l y , S R M n e e d s t o m a i n t a i n o r d e r a m o n g t h e p r e f e t c h e d b l o c k s , s i n c e f r o m t i m e t o t i m e , t h e a l g o r i t h m  

m a y n e e d t o u s h o u t o f i n t e r n a l m e m o r y u p t o   D    1 o f t h e l a r g e s t p r e f e t c h e d b l o c k s . T h e r e i s a l s o a n e e d t o e n s u r e  

t h a t I / O a n d c o m p u t a t i o n a r e o v e r l a p p e d a s f a r a s p o s s i b l e .  

4 . 4 I m p l e m e n t a t i o n T e c h n i q u e s a n d D a t a S t r u c -    

t u r e s f o r S R M          

I n t h i s s e c t i o n , w e p r e s e n t a n i m p l e m e n t a t i o n o f t h e f o r e c a s t a n d u s h s c h e m e u s i n g n o v e l d a t a s t r u c t u r e s a n d  

t e c h n i q u e s . O u r a p p r o a c h g r e a t l y s i m p l i e s t h e t a s k o f i m p l e m e n t i n g S R M . W e r e q u i r e o n l y o n e p r i o r i t y q u e u e  

i n c o n j u n c t i o n w i t h   D  o r d i n a r y q u e u e s , a s o p p o s e d t o t h e   D  p r i o r i t y q u e u e s r e q u i r e d b y a n a i v e i m p l e m e n t a t i o n .  

M a i n t e n a n c e o f o r d e r a m o n g p r e f e t c h e d b l o c k s f a l l s o u t a s a n a t u r a l c o n s e q u e n c e o f o u r t e c h n i q u e . W e a l s o p r o p o s e  

a s i m p l e t e c h n i q u e t o o v e r l a p I / O a n d c o m p u t a t i o n .  

F o r t h e m o m e n t , w e a s s u m e t h a t w e h a v e a c c e s s t o a n a p p r o p r i a t e h i g h - l e v e l i n t e r f a c e t o s p e c i f y I / O . I n t h e n e x t  

s e c t i o n , w e s h o w h o w s u c h a n i n t e r f a c e w a s i m p l e m e n t e d i n t h e T P I E V e n 9 5 ] p r o g r a m m i n g e n v i r o n m e n t f o r e x t e r n a l  

m e m o r y p r o g r a m m i n g . B e l o w , w e d e s c r i b e a n o v e l a p p r o a c h t o p r o c e s s f o r e c a s t i n g d a t a i n c o u r s e o f a n S R M m e r g e  

o p e r a t i o n , w h i c h f o r m s t h e b a s i s o f t h e S R M m e r g e i m p l e m e n t a t i o n . T h e n w e d e s c r i b e t h e b a s i c d a t a s t r u c t u r e s  

i n v o l v e d i n o u r i m p l e m e n t a t i o n . W e e n d t h i s s e c t i o n w i t h a n a l g o r i t h m i c d e s c r i p t i o n o f o u r i m p l e m e n t a t i o n .  

4 . 4 . 1 M a n a g i n g F o r e c a s t i n g D a t a  

I n s i n g l e d i s k m e r g i n g , t h e k e y o f t h e l a s t i t e m o f a b l o c k a r u n i s t h e f o r e c a s t e r f o r t h e n e x t b l o c k o f t h a t r u n , s o t h e r e  

i s n o i n h e r e n t n e e d t o e x p l i c i t l y s t o r e f o r e c a s t i n g i n f o r m a t i o n i n b l o c k s . H o w e v e r , i n S R M , g i v e n   i  t h b l o c k o f a r u n ,  

w e n e e d t o b e a b l e t o f o r e c a s t w h e n t h e (  i  +  D  ) t h b l o c k o f t h a t r u n w i l l b e g i n p a r t i c i p a t i n g , s o f o r e c a s t i n g i n f o r m a t i o n  

h a s t o b e s t o r e d e x p l i c i t l y . W h i l e t h e o r i g i n a l i m p l e m e n t a t i o n o f S R M p r o p o s e d i m p l a n t i n g o n e f o r e c a s t i n g k e y ( t h e  

k e y o f t h e l a s t i t e m i n t h e b l o c k   D    1 b l o c k s f a r t h e r i n t h e r u n ) i n e a c h b l o c k o f a r u n , h e r e w e p r o p o s e t h a t  

f o r e c a s t i n g i n f o r m a t i o n b e m a n a g e d a l t o g e t h e r s e p a r a t e l y .  

O u r p r o p o s a l i s m o t i v a t e d b y t h e o b s e r v a t i o n t h a t i n m o s t a p p l i c a t i o n s i n p r a c t i c e ( a n d i n p a r t i c u l a r , i n d a t a b a s e  

a p p l i c a t i o n s ) , t h e s i z e o f t h e f o r e c a s t i n g d a t a i n v o l v e d i n a m e r g e o p e r a t i o n i s   m u c h s m a l l e r   t h a n t h e s i z e o f t h e  

r u n s p a r t i c i p a t i n g i n t h e m e r g e . I f t h e s i z e o f a n i t e m i s   I  b y t e s a n d t h e s i z e o f i t s k e y i s   K  b y t e s , t h e n w h i l e t h e  

s i z e ( i n b y t e s ) o f t h e r u n s i n p u t t o a m e r g i n g p a s s i s   N    I  b y t e s , t h e s i z e o f t h e c o r r e s p o n d i n g f o r e c a s t i n g d a t a i s  

o n l y   N K = B   b y t e s , s o t h e f o r e c a s t i n g d a t a i s s m a l l e r b y a f a c t o r o f   B I = K   , w h i c h i s l a r g e i n p r a c t i c e . F o r i n s t a n c e ,  

d a t a b a s e b e n c h m a r k s t y p i c a l l y h a v e   I  = 1 0 0 b y t e s a n d   K  = 1 0 b y t e s . I f   B  = 1 0 0 0 i t e m s  

, t h e n t h e f o r e c a s t i n g d a t a  

i s 1 0 0 0 0 t i m e s s m a l l e r t h a n t h e l e s b e i n g m e r g e d . T h u s w h i l e m e r g i n g l e s t o t a l l y i n v o l v i n g 1 G B o f d a t a , t h e t o t a l  

a m o u n t o f f o r e c a s t i n g d a t a i s o n l y     1 0 0 K B .  

I n o u r i m p l e m e n t a t i o n a n d i n A D A D C  

9 7 ] ,   B  i s e v e n l a r g e r .  

6 7 

Page 81: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 81/203

G i v e n t h e i m p o r t a n c e o f t h e r o l e o f f o r e c a s t i n g i n S R M a n d t h e s i z e o f i n t e r n a l m e m o r y l i k e l y t o b e u s e d ,   i n m o s t  

s i t u a t i o n s a l l t h e f o r e c a s t i n g d a t a r e l e v a n t t o a m e r g e o p e r a t i o n c a n b e k e p t r e s i d e n t i n i n t e r n a l m e m o r y .   O n e w a y  

t o i m p l e m e n t t h i s w o u l d b e t o r s t r e a d i n t h e s m a l l l e ( s ) c o n t a i n i n g a l l t h e f o r e c a s t i n g d a t a r e l a t e d t o t h e i n p u t  

r u n s a t t h e b e g i n n i n g o f t h e m e r g e o p e r a t i o n . T h e f o r e c a s t i n g d a t a c o r r e s p o n d i n g t o t h e o u t p u t r u n c a n e i t h e r b e  

w r i t t e n o u t a l l a t o n c e a t t h e e n d o f t h e m e r g e o p e r a t i o n o r w r i t t e n o u t i n a b l o c k e d m a n n e r f r o m t i m e t o t i m e  

d u r i n g t h e m e r g e . T h e f o r e c a s t i n g d a t a c o r r e s p o n d i n g t o t h e i n p u t r u n s c a n b e d i s p o s e d o f a f t e r t h e m e r g e o p e r a t i o n .  

U s i n g t h i s a p p r o a c h t h e n u m b e r o f p a r a l l e l I / O o p e r a t i o n s f o r r e a d i n g a n d w r i t i n g f o r e c a s t i n g d a t a o v e r a m e r g i n g  

p a s s w o u l d b e   d  2  N K = D B  

I  e  , w h i c h i s a s m a l l f r a c t i o n o f t h e m i n i m u m n u m b e r   d  2  N = D B   e  o f p a r a l l e l I / O o p e r a t i o n s  

r e q u i r e d f o r t r a n s f e r r i n g t h e r u n d a t a b l o c k s d u r i n g t h e m e r g i n g p a s s . A n a l t e r n a t i v e i m p l e m e n t a t i o n t h a t i s m u c h  

e a s i e r a n d l i k e l y t o b e f e a s i b l e m o s t o f t h e t i m e , i s t o n e v e r h a v e f o r e c a s t i n g d a t a g o t o d i s k a t a n y t i m e t h r o u g h o u t  

t h e e n t i r e m e r g e s o r t . F o r e c a s t i n g d a t a i s i n t e r m e d i a t e d a t a g e n e r a t e d d u r i n g S R M , s o t h e r e i s n o f e a r o f i t b e i n g  

l o s t o n a c c o u n t o f s y s t e m f a i l u r e s . I n i n t e r n a l m e m o r y , t w o f o r e c a s t i n g b u e r s c a n b e u s e d o v e r a l l m e r g i n g p a s s e s ;  

t h e t w o b u e r s i p - o p i n t h e i r r o l e a s b u e r s f o r i n p u t r u n f o r e c a s t i n g d a t a a n d o u t p u t r u n f o r e c a s t i n g d a t a f r o m  

e a c h m e r g e p a s s t o t h e n e x t .  

T h e r e m a y , h o w e v e r , b e e x c e p t i o n a l s i t u a t i o n s i n w h i c h h a v i n g t h e f o r e c a s t i n g d a t a r e s i d e n t i n i n t e r n a l m e m o r y  

m a y n o t r e a s o n a b l e . F o r i n s t a n c e , t h i s c a n h a p p e n w h i l e m e r g i n g t e r a b y t e s o f d a t a ; i n s u c h c a s e s , f o r e c a s t i n g d a t a  

m a y c o n s u m e e i t h e r a s i g n i c a n t f r a c t i o n o f a v a i l a b l e i n t e r n a l m e m o r y o r ( i n r e a l l y e x t r e m e s i t u a t i o n s ) m a y e v e n  

e x c e e d i n t e r n a l m e m o r y . F o r s u c h c a s e s , w e p r o p o s e y e t a n o t h e r t e c h n i q u e t o p r o c e s s f o r e c a s t i n g d a t a t h a t w i l l  

c o n s u m e o n l y a s m a l l f r a c t i o n o f i n t e r n a l m e m o r y ( o n l y a s m a l l p o r t i o n o f t h e f o r e c a s t i n g d a t a c o r r e s p o n d i n g t o a  

m e r g e o p e r a t i o n w i l l b e i n m e m o r y a t a t i m e ) a n d w i l l i n c u r o n l y a s m a l l I / O o v e r h e a d r e l a t i v e t o t h e I / O r e q u i r e d  

f o r t r a n s f e r r i n g t h e r u n d a t a b l o c k s .  

I n t h e r e m a i n d e r o f t h i s s e c t i o n w e d e s c r i b e t h e t h e p r e c i s e o p e r a t i o n s o n f o r e c a s t i n g d a t a i n o u r i m p l e m e n t a t i o n ,  

f o l l o w e d b y a d i s c u s s i o n o f t h e h o w t o h a n d l e t h e f o r e c a s t i n g d a t a w h e n i t c a n n o t b e k e p t i n i n t e r n a l m e m o r y .  

T h e F o r e c a s t i n g H e a p  

C o n s i d e r a n S R M m e r g e o p e r a t i o n i n v o l v i n g   R  i n p u t r u n s . S i n c e w e p r o p o s e t o m a n a g e t h e f o r e c a s t i n g d a t a s e p a r a t e l y  

f r o m t h e r u n s t h e m s e l v e s , f o r e a c h r u n t h e r e i s a   f o r e c a s t i n g d a t a r u n   c o n t a i n s t h e f o r e c a s t i n g k e y s o f t h a t r u n i n  

s o r t e d o r d e r . I n a l l s i t u a t i o n s o t h e r t h a n t h e e x c e p t i o n a l s i t u a t i o n d i s c u s s e d i n S e c t i o n 4 . 4 . 1 , t h e   R  f o r e c a s t i n g  

d a t a r u n s r e m a i n r e s i d e n t i n i n t e r n a l m e m o r y d u r i n g t h e c o u r s e o f t h e m e r g e . T h e o n l y o p e r a t i o n t h a t n e e d s t o b e  

s u p p o r t e d o n t h e f o r e c a s t i n g d a t a r u n s i n o r d e r t o f a c i l i t a t e o u r i m p l e m e n t a t i o n o f S R M ' s f o r e c a s t a n d u s h s c h e m e i s  

a n i n c r e m e n t a l m e r g e o f t h e   R  f o r e c a s t i n g d a t a r u n s t h a t o u t p u t s o n e f o r e c a s t i n g k e y a t a t i m e .   S u c h a n i n c r e m e n t a l  

m e r g e c a n b e i m p l e m e n t e d b y h a v i n g a p r i o r i t y q u e u e t h a t c o n t a i n s , a t a n y t i m e , t h e l e a d i n g f o r e c a s t i n g k e y o f e a c h  

o f t h e   R  f o r e c a s t i n g r u n s . T h e s m a l l e s t k e y i n t h e p r i o r i t y q u e u e i s o u t p u t a t e a c h s t e p ; i f t h a t k e y b e l o n g s t o t h e  

r  t h f o r e c a s t i n g d a t a r u n , t h e n t h e n e x t k e y f r o m t h a t r u n i s i n s e r t e d i n t o t h e p r i o r i t y q u e u e . T h e p r o c e s s c a n t h u s  

6 8 

Page 82: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 82/203

Page 83: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 83/203

i n a q u e u e o f   p l a c e h o l d e r s  , c a l l e d t h e   l o o k a h e a d q u e u e L Q   f o r r e a s o n s t h a t w i l l s o o n b e c l e a r . E a c h p l a c e h o l d e r i s a  

s t r u c t u r e w i t h a e l d   b l o c k p t r   t o s t o r e a p o i n t e r t o a b l o c k i n i n t e r n a l m e m o r y , a e l d   r u n i d   t o s t o r e t h e i d e n t i t y  

o f a r u n , a n d a e l d   b l o c k n u m   t o s t o r e t h e i n d e x o f a b l o c k w i t h i n a r u n . W e u s e   L Q  h e a d   a n d  L Q  t a i l   t o d e n o t e  

t h e p l a c e h o l d e r s a t t h e h e a d a n d t h e t a i l o f t h e q u e u e   L Q  . F o r e a c h d i s k 0     d < D  , w e m a i n t a i n a n   o c c u p a n c y  

q u e u e O Q  

o f e l e m e n t s . E a c h e l e m e n t i s a p o i n t e r t o s o m e p l a c e h o l d e r s t o r e d i n t h e l o o k a h e a d q u e u e   L Q  . E l e m e n t s  

i n  O Q 

a l w a y s p o i n t t o p l a c e h o l d e r s o f b l o c k s o n d i s k   d  t h a t a r e n o t y e t i n i n t e r n a l m e m o r y . W e u s e   O Q 

h e a d  

a n d  O Q 

t a i l   t o d e n o t e t h e e l e m e n t s a t t h e h e a d a n d t a i l o f t h e q u e u e   O Q 

. B y a p p e n d i n g ( r e s p . , p r e p e n d i n g ) a n  

e l e m e n t t o   O Q 

, w e r e f e r t o t h e a c t o f a d d i n g a n e l e m e n t b e h i n d ( r e s p . , i n f r o n t o f ) t h e e l e m e n t   O Q 

t a i l   ( r e s p . ,  

O Q 

h e a d   . ) T h e l o o k a h e a d q u e u e a s w e l l a s a l l t h e o c c u p a n c y q u e u e s m u s t b e t r a v e r s a b l e i n b o t h d i r e c t i o n s . W e  

u s e  s 

,  s 

,  ,  s 

R    1 

t o d e n o t e t h e s t a r t i n g d i s k s o f t h e   R  i n p u t r u n s . E a c h s t a r t i n g d i s k i s c h o s e n r a n d o m l y w h e n  

t h e r u n i s b e g u n a n d i s k n o w n t o t h e m e r g i n g a l g o r i t h m .  

T h e p u r p o s e o f t h e l o o k a h e a d q u e u e   L Q  i s t o m a i n t a i n p r e f e t c h e d i n p u t r u n b l o c k s i n p a r t i c i p a t i o n o r d e r . T h e  

p u r p o s e o f e a c h o c c u p a n c y q u e u e   O Q 

, w h e r e 0     d < D  , i s t o m a i n t a i n ( p o i n t e r s t o ) p l a c e h o l d e r s c o r r e s p o n d i n g t o  

b l o c k s f r o m d i s k   d  i n t h e i r p a r t i c i p a t i o n o r d e r , s o t h a t b l o c k s f r o m d i s k   d  c a n b e r e a d b y   P a r a l l e l R e a d   o p e r a t i o n s i n  

p r o p e r s e q u e n c e .  

O u r i m p l e m e n t a t i o n a n d S R M ' s p r o p e r t i e s e n s u r e t h a t t h e n u m b e r  

1 0 

o f e l e m e n t s i n t h e l o o k a h e a d q u e u e   L Q  i s 

n e v e r m o r e t h a n m a x  f  m ; R D   g  +  R  +  D  , a n d t h e n u m b e r o f e l e m e n t s i n a n y o c c u p a n c y q u e u e c a n n o t e x c e e d   R  +  D 

S i n c e e l e m e n t s o f t h e   L Q  o r a n y o f t h e   O Q 

' s a r e   O  ( 1 ) b y t e s i n s i z e , w e c a n v e r y s i m p l y i m p l e m e n t   L Q  a n d a l l  

t h e  O Q 

q u e u e s u s i n g s t a t i c a l l y a l l o c a t e d c i r c u l a r a r r a y s i n t h e o b v i o u s m a n n e r , w i t h i n s i g n i c a n t s p a c e o v e r h e a d i n  

p r a c t i c e .  

N e x t w e d e n e s o m e p r i m i t i v e o p e r a t i o n s i n o r d e r t o f a c i l i t a t e t h e p r e s e n t a t i o n o f o u r i m p l e m e n t a t i o n .  

1 L o o k a h e a d   ( ) . T h e o p e r a t i o n   L o o k a h e a d   ( ) g e t s t h e n e x t f o r e c a s t i n g k e y f r o m t h e f o r e c a s t i n g h e a p a n d u p d a t e s  

t h e f o r e c a s t i n g h e a p a p p r o p r i a t e l y , a s d i s c u s s e d e a r l i e r . I f t h e k e y s o o b t a i n e d p r e d i c t s t h e p a r t i c i p a t i o n t i m e o f  

t h e  i  t h b l o c k i n t h e   r  t h r u n , t h e n a n e w p l a c e h o l d e r    p  w i t h    p b l o c k n u m   : =  i  ,   p r u n i d   : =  r  , a n d    p b l o c k p t r   : = 

n i l  , i s a p p e n d e d t o   L Q  w h i c h m a k e s   L Q  : t a i l   =   p  . F i n a l l y , a n e l e m e n t p o i n t i n g t o p l a c e h o l d e r    p  i s a p p e n d e d t o  

O Q 

, w h e r e   d  = (  s 

+  i  ) m o d   D  i s t h e d i s k o n w h i c h t h e   i  t h b l o c k o f r u n   r  r e s i d e s .  

2 P a r a l l e l R e a d   . T h e o p e r a t i o n   P a r a l l e l R e a d   i s s u e s r e a d r e q u e s t s  

1 1 

f o r a s e t o f a t m o s t   D  b l o c k s , o n e p e r  

d i s k . T h e r e a d s a r e c a r r i e d o u t i n   p a r a l l e l   P a r a l l e l R e a d   i s  n o n - b l o c k i n g   i n t h e s e n s e t h a t i t r e t u r n s c o n t r o l  

1 0 

A l t h o u g h t h e l o o k a h e a d q u e u e   L Q  c a n h a v e   R  e n t r i e s f o r e a c h o f t h e   D  d i s k s , t h e n u m b e r o f  

b l o c k s o f i n t e r n a l m e m o r y a c t u a l l y i n u s e c a n n e v e r e x c e e d   m  . 

1 1 

O u r i m p l e m e n t a t i o n u s e s m e m o r y - m a p p e d I / O . T h e m e m o r y - m a p p e d I / O c a l l s w e u s e a r e a n  

e n h a n c e d v e r s i o n C A B G 9 8 ] o f t h e o r i g i n a l m e m o r y - m a p p e d c a l l s p r o v i d e d b y D i g i t a l U n i x . T h e  

e n h a n c e d v e r s i o n s e n d s o a n a s y n c h r o n o u s I / O r e q u e s t u n d e r t h e h o o d a s s o o n a s t h e c a l l i s  

m a d e . W e i m p l e m e n t a   D  - d i s k p a r a l l e l I / O o p e r a t i o n b y i s s u i n g   D  s u c h c a l l s f o r b l o c k s o n  

d i e r e n t d i s k s .  

7 0 

Page 84: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 84/203

i m m e d i a t e l y w i t h o u t w a i t i n g f o r t h e r e a d s t o a c t u a l l y c o m p l e t e . T h e p r e c i s e b l o c k o f d i s k   d  f o r w h i c h a r e a d i s  

i s s u e d i s d e t e r m i n e d a s f o l l o w s : I f t h e o c c u p a n c y q u e u e   O Q 

i s e m p t y , n o b l o c k i s r e a d f r o m d i s k   d  . O t h e r w i s e ,  

i f  O Q 

h e a d   p o i n t s t o p l a c e h o l d e r    p  i n  L Q  , t h e f o l l o w i n g i s d o n e :  

( a ) B l o c k    p b l o c k n u m   o f r u n    p r u n i d   i s r e a d f r o m d i s k   d  i n t o i n t e r n a l m e m o r y .  

( b ) T h e e l d    p b l o c k p t r   i s s e t t o p o i n t t o t h e n e w l y r e a d b l o c k i n i n t e r n a l m e m o r y .  

( c ) E l e m e n t   O Q 

h e a d   i s r e m o v e d f r o m   O Q 

4 . 4 . 3 B a s i c I d e a s o f O u r I m p l e m e n t a t i o n  

O u r i m p l e m e n t a t i o n r e a d s b l o c k s o f t h e i n p u t r u n i n t o i n t e r n a l m e m o r y o n l y v i a t h e   P a r a l l e l R e a d   o p e r a t i o n d e s c r i b e d  

a b o v e . W e m a i n t a i n t h e i n v a r i a n t t h a t w h e n e v e r a   P a r a l l e l R e a d   o p e r a t i o n i s e x e c u t e d , t h e b l o c k c o r r e s p o n d i n g t o t h e  

p l a c e h o l d e r p o i n t e d t o b y   O Q 

h e a d   f o r e a c h 0     d < D  i s t h e s m a l l e s t b l o c k o n d i s k   d  w i t h r e s p e c t t o p a r t i c i p a t i o n  

o r d e r a t t h a t t i m e . T h u s , t h e s m a l l e s t b l o c k i s r e a d f r o m e a c h o f t h e   D  d i s k s , w h i c h i m p l e m e n t s S t e p 1 c o f t h e f o r e c a s t  

a n d u s h s c h e m e o f S e c t i o n 4 . 3 . 1 . O u r i m p l e m e n t a t i o n a l s o m a i n t a i n s t h e i m p o r t a n t i n v a r i a n t t h a t t h e p a r t i c i p a t i o n  

o r d e r o f t h e i n p u t r u n b l o c k s w i t h p l a c e h o l d e r s i n   L Q  i s p r e c i s e l y t h e o r d e r o f t h e i r p l a c e h o l d e r s . A p l a c e h o l d e r  

 p  i n  L Q  h a s   p b l o c k p t r   =  n i l  i f a n d o n l y i f i t s c o r r e s p o n d i n g b l o c k i s n o t i n i n t e r n a l m e m o r y . T h u s , i n o r d e r t o  

u s h   f  b l o c k s a s i n S t e p 1 b o f S e c t i o n 4 . 3 . 1 , w e s i m p l y t r a v e r s e   L Q  f r o m t a i l t o h e a d , n d t h e r s t   f  p l a c e h o l d e r s  

 p 

; p 

; : : : ; p  

f    1 

s o f o u n d w i t h    p 

b l o c k p t r   6=  n i l  , a n d a m o n g o t h e r t h i n g s s e t    p 

b l o c k p t r   : =  n i l 

T h e l o o k a h e a d q u e u e f e e d s b l o c k s t o t h e m e r g e p r o c e s s ; t h e h e a d   L Q  h e a d   o f t h e l o o k a h e a d q u e u e g e t s r e m o v e d  

w h e n e v e r a r u n ' s l e a d i n g b l o c k g e t s d e p l e t e d b y t h e m e r g e . P l a c e h o l d e r s a r e a d d e d a t t h e e n d o f t h e l o o k a h e a d q u e u e  

b y t h e   L o o k a h e a d   ( ) o p e r a t i o n s . E v e n i f a b l o c k h a s a p l a c e h o l d e r i n   L Q  , t h e b l o c k i s n o t n e c e s s a r i l y i n i n t e r n a l  

m e m o r y . T h e o r d e r i n w h i c h b l o c k s a r e r e a d i n t o m e m o r y i s d e t e r m i n e d b y t h e o c c u p a n c y q u e u e s . T h e o c c u p a n c y  

q u e u e f e e d s t h e   P a r a l l e l R e a d   o p e r a t i o n s ; t h e h e a d o f e a c h o c c u p a n c y q u e u e   O Q 

, w h e r e 0     d < D  , i s r e m o v e d  

d u r i n g a   P a r a l l e l R e a d   o p e r a t i o n . E l e m e n t s a r e a d d e d a t t h e e n d o f t h e o c c u p a n c y q u e u e s b y t h e   L o o k a h e a d   ( ) 

o p e r a t i o n s .  

W h e n e v e r a   L o o k a h e a d   ( ) o p e r a t i o n i s e x e c u t e d , a p l a c e h o l d e r    p  f o r t h e b l o c k t h a t i m m e d i a t e l y f o l l o w s   L Q  t a i l  

i n p a r t i c i p a t i o n o r d e r i s c r e a t e d a n d m a d e t h e n e w   L Q  t a i l  . I n a d d i t i o n , t h e   L o o k a h e a d   ( ) o p e r a t i o n a l s o a n e l e m e n t  

p o i n t i n g t o    p  i s a d d e d a t t h e e n d o f   O Q 

, w h e r e   d  i s t h e d i s k o n w h i c h t h e b l o c k r e s i d e s . I n o r d e r t o e n s u r e t h a t  

a  P a r a l l e l R e a d   o p e r a t i o n r e a d s o n e b l o c k f r o m e a c h d i s k , w e s i m p l y h a v e t o e n s u r e t h a t   O Q 

i s n o n e m p t y f o r a l l  

0    d < D  . H e n c e , j u s t b e f o r e e x e c u t i n g a   P a r a l l e l R e a d   o p e r a t i o n w e p e r f o r m a s m a n y   L o o k a h e a d   ( ) o p e r a t i o n s  

a s a r e n e c e s s a r y t o e n s u r e t h a t e a c h   O Q 

q u e u e h a s a t l e a s t o n e e l e m e n t . T h e p r e c i s e n u m b e r o f   L o o k a h e a d   ( ) 

o p e r a t i o n s n e e d e d t o d o s o i s u n p r e d i c t a b l e a n d d e p e n d e n t u p o n t h e d i s k d i s t r i b u t i o n o f t h e r e l e v a n t b l o c k s a n d t h e i r  

p a r t i c i p a t i o n o r d e r . T h e a b o v e m e c h a n i s m a u t o m a t i c a l l y g u a r a n t e e s t h e i n v a r i a n t t h a t e a c h   P a r a l l e l R e a d   o p e r a t i o n  

a l w a y s r e a d s t h e s m a l l e s t b l o c k f r o m e a c h d i s k a t t h a t t i m e .  

7 1 

Page 85: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 85/203

O u r i m p l e m e n t a t i o n g u a r a n t e e s t h a t   w h e n e v e r a l e a d i n g r u n b l o c k g e t s d e p l e t e d , a r e a d r e q u e s t f o r t h e n e x t b l o c k o f  

t h a t r u n ( u n l e s s t h e r u n i t s e l f i s d e p l e t e d ) w a s a l r e a d y i s s u e d i n s o m e p r e v i o u s P a r a l l e l R e a d o p e r a t i o n , a n d m o r e o v e r ,  

t h a t b l o c k i s p r e c i s e l y t h e b l o c k p o i n t e d t o b y    p b l o c k p t r , w h e r e p l a c e h o l d e r    p  =  L Q  h e a d .   I n o r d e r t o d o s o , w e  

m a i n t a i n a s p e c i a l v a r i a b l e ,   m a r k e d   t h a t r e m e m b e r s t h e p l a c e h o l d e r o f t h e s m a l l e s t b l o c k f o r w h i c h a r e a d w a s i s s u e d  

i n t h e m o s t r e c e n t   P a r a l l e l R e a d   o p e r a t i o n . W h e n e v e r t h e p l a c e h o l d e r   m a r k e d   b e g i n s p a r t i c i p a t i n g i n t h e m e r g e , w e  

t e m p o r a r i l y i n t e r r u p t t h e ( i n t e r n a l m e m o r y ) m e r g i n g c o m p u t a t i o n , e m p l o y t h e m e c h a n i s m o f t h e p r e v i o u s p a r a g r a p h  

t o e n s u r e t h a t f u l l p a r a l l e l i s m f o r t h e   P a r a l l e l R e a d   o p e r a t i o n , e x e c u t e t h e   P a r a l l e l R e a d   o p e r a t i o n , u p d a t e t h e v a l u e  

o f  m a r k e d   , a n d t h e n r e s u m e t h e m e r g i n g c o m p u t a t i o n . S i n c e   P a r a l l e l R e a d   i s n o n - b l o c k i n g , o u r i m p l e m e n t a t i o n  

p e r f o r m s I / O o v e r l a p p e d w i t h c o m p u t a t i o n . S o m e t i m e s , i n t h e a b o v e p r o c e s s , a f e w b l o c k s m a y n e e d t o b e u s h e d .  

4 . 4 . 4 A l g o r i t h m i c D e s c r i p t i o n  

W e a r e n o w i n a p o s i t i o n t o g i v e a n a l g o r i t h m i c d e s c r i p t i o n o f o u r i m p l e m e n t a t i o n . F o r s i m p l i c i t y , w e d o n o t m e n t i o n  

t h e I / O o p e r a t i o n s i n t h e c o n t e x t o f t h e f o r e c a s t i n g h e a p , w i t h t h e u n d e r s t a n d i n g t h a t t h e i m p l e m e n t o r w i l l c h o o s e  

a n a p p r o p r i a t e t e c h n i q u e a n d p e r f o r m t h e c o r r e s p o n d i n g o p e r a t i o n s , b a s e d u p o n t h e d i s c u s s i o n i n S e c t i o n 4 . 4 . 1 .  

W e u s e t w o v a r i a b l e s   m a r k e d   a n d  n e x t m a r k e d   t o r e c o r d a p p r o p r i a t e p l a c e h o l d e r s i n t h e l o o k a h e a d q u e u e   L Q 

A s m e n t i o n e d e a r l i e r , t h e t o t a l n u m b e r o f b l o c k s a v a i l a b l e a t t h e s t a r t o f t h e m e r g e o p e r a t i o n f o r i n p u t r u n b l o c k s  

( i n c l u d i n g l e a d i n g b l o c k s , b l o c k s c u r r e n t l y b e i n g r e a d i n t o i n t e r n a l m e m o r y , a n d p r e f e t c h e d b l o c k s ) i s a s s u m e d t o b e  

a n u m b e r   m    2  R  +  D  . T h e o u t p u t r u n h a s t w o   D B  i t e m s i z e d b u e r s t h a t a r e u s e d i n t h e u s u a l d o u b l e - b u e r e d  

f a s h i o n , w i t h w r i t e s a t f u l l   D  - d i s k p a r a l l e l i s m . W h e n e v e r a n i n p u t r u n b l o c k g e t s d e p l e t e d b y t h e m e r g e o r w h e n a n  

i n p u t r u n b l o c k g e t s u s h e d , t h e n u m b e r o f f r e e b l o c k s i n c r e a s e s b y 1 . I f    p  i s a p l a c e h o l d e r i n   L Q  , t h e n w e f o l l o w t h e  

c o n v e n t i o n t h a t    p b l o c k p t r   i s  n i l  w h e n e v e r t h e b l o c k    p b l o c k n u m   o f r u n    p r u n i d   i s n o t i n i n t e r n a l m e m o r y a n d i s  

s t i l l o n d i s k .  

1 . F o r e a c h r u n 0     r < R  , r e a d i n t o i n t e r n a l m e m o r y i t s r s t b l o c k ( o n s t a r t i n g d i s k   s 

) . T h e p o i n t e r s   L e a d i n g  

L e a d i n g  

,  ,  L e a d i n g  

R    1 

a r e m a d e t o p o i n t t o t h e c o r r e s p o n d i n g r s t b l o c k s . T h e t o t a l n u m b e r o f p a r a l l e l  

I / O o p e r a t i o n s r e q u i r e d t o i m p l e m e n t t h i s s t e p i s e q u a l t o t h e m a x i m u m n u m b e r o f r s t b l o c k s o n a n y o n e d i s k .  

2 . I n s e r t t h e r s t k e y f r o m e a c h o n e o f t h e   R  f o r e c a s t i n g d a t a r u n s i n t o t h e f o r e c a s t i n g h e a p . I n s e r t t h e r s t i t e m  

f r o m e a c h r u n i n t o t h e m a i n m e r g e h e a p .  

3 . I n i t i a l i z e t h e l o o k a h e a d q u e u e   L Q  a n d t h e   D  o c c u p a n c y q u e u e s   O Q 

, f o r 0     d < D  , t o b e e m p t y q u e u e s .  

4 . W h i l e t h e r e e x i s t s a t l e a s t o n e e m p t y o c c u p a n c y q u e u e   O Q 

a n d t h e f o r e c a s t i n g h e a p i s n o t e m p t y , e x e c u t e a  

L o o k a h e a d   ( ) o p e r a t i o n .  

5 . S e t   m a r k e d   : =  L Q  h e a d  

7 2 

Page 86: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 86/203

6   G e t r e a d y f o r t h e n e x t p a r a l l e l r e a d i n t h e m e r g e b y u s h i n g b l o c k s i f n e c e s s a r y .  ] I f t h e r e a r e a t l e a s t   D  f r e e  

b l o c k s i n i n t e r n a l m e m o r y , t h e n p r o c e e d t o S t e p 7 . O t h e r w i s e l e t t h e n u m b e r o f f r e e b l o c k s i n i n t e r n a l m e m o r y  

b e  D    f  , w h e r e   f    1 . B e g i n n i n g w i t h t h e t a i l o f   L Q  , t r a v e r s e   L Q  t o w a r d s i t s h e a d u n t i l   f  p l a c e h o l d e r s    p 

,   p 

,   p 

f    1 

a r e f o u n d s u c h t h a t    p 

b l o c k p t r   6=  n i l  , f o r 0     j < f  . S u p p o s e t h a t d i s k   d 

i s t h e d i s k f r o m w h i c h  

t h e b l o c k    p 

b l o c k n u m   o f r u n    p 

r u n i d   o r i g i n a t e s . T h e n , f o r e a c h 0     j < f  , 

( a ) S e t    p 

b l o c k p t r   : =  n i l 

( b ) I f t h e o c c u p a n c y q u e u e   O Q 

i s e m p t y , i n s e r t a n e l e m e n t p o i n t i n g t o t h e p l a c e h o l d e r    p 

i n t o   O Q 

o t h e r w i s e p r e p e n d a n e l e m e n t p o i n t i n g t o p l a c e h o l d e r    p 

t o t h e h e a d o f q u e u e   O Q 

( c ) I f p l a c e h o l d e r    p 

i s a h e a d o f t h e p l a c e h o l d e r   m a r k e d   i n q u e u e   L Q  , t h e n s e t   m a r k e d   : =   p 

7 . E x e c u t e a   P a r a l l e l R e a d   o p e r a t i o n .  

8 . W h i l e t h e r e e x i s t s a t l e a s t o n e e m p t y o c c u p a n c y q u e u e   O Q 

a n d t h e f o r e c a s t i n g h e a p i s n o t e m p t y , e x e c u t e a  

L o o k a h e a d   ( ) o p e r a t i o n .  

9 . S e t   n e x t m a r k e d   : =   p 

, w h e r e    p 

i s t h e p l a c e h o l d e r i n   L Q  c l o s e s t t o   L Q  h e a d   a m o n g t h e p l a c e h o l d e r s p o i n t e d  

t o b y e l e m e n t s   O Q 

h e a d   , f o r 0     d < D 

1 0 a g  : = 0 .  

1 1 . W h i l e (   a g  = 0 ) 

( a ) G e n e r a t e t h e n e x t i t e m   x  f r o m t h e m a i n m e r g e h e a p . L e t   r  b e t h e r u n c o n t a i n i n g   x 

( b ) I f r u n   r  h a s n o m o r e i t e m s t o b e m e r g e d , f r e e t h e l e a d i n g b l o c k   L e a d i n g  

a n d p r o c e e d t o S t e p 1 1 d .  

O t h e r w i s e , i f t h e l e a d i n g b l o c k   L e a d i n g  

o f r u n   r  h a s j u s t b e e n d e p l e t e d , f r e e t h a t b l o c k , s e t   L e a d i n g  

t o 

p o i n t t o t h e b l o c k    p b l o c k p t r   , f o r p l a c e h o l d e r    p  =  L Q  h e a d   , a n d r e m o v e p l a c e h o l d e r    p  f r o m t h e l o o k a h e a d  

q u e u e   L Q  I f   p  =  m a r k e d   , s e t   a g  : = 1 .  

( c ) I n s e r t t h e n e x t i t e m f r o m r u n   r  i n t o t h e m a i n m e r g e p r i o r i t y q u e u e . ( I f t h e l e a d i n g b l o c k   L e a d i n g  

 j u s t  

c h a n g e d i n S t e p 1 1 b a b o v e , t h e n e x t i t e m f r o m r u n   r  i s t h e r s t i t e m o f b l o c k   L e a d i n g  

( d ) A d d i t e m   x  t o t h e o u t p u t r u n b u e r .  

( e ) I f a d d i n g   x  c o m p l e t e s t h e b l o c k o f a n o u t p u t r u n , a d d t h e k e y o f   x  t o t h e f o r e c a s t i n g d a t a r u n o f t h e  

o u t p u t r u n .  

( f ) I f t h e c u r r e n t o u t p u t r u n b u e r n o w h a s   D B  i t e m s , t h e n s w i t c h o u t p u t b u e r s a n d i s s u e a n o n - b l o c k i n g  

r e q u e s t t o w r i t e o u t   D B  i t e m s t o d i s k w i t h f u l l   D  - d i s k p a r a l l e l i s m .  

7 3 

Page 87: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 87/203

( g ) I f t h e m a i n m e r g e h e a p i s e m p t y , s e t   a g  : = 2 .  

1 2 . I f   a g  = 1 , s e t   m a r k e d   : =  n e x t m a r k e d   a n d l o o p b a c k t o S t e p 6 .  

1 3 . I f   a g  = 2 , w r i t e t o d i s k t h e r e m a i n i n g i t e m s f r o m t h e o u t p u t r u n b u e r a n d t h e m e r g e i s c o m p l e t e d .  

4 . 5 P e r f o r m a n c e R e s u l t s    

I n t h i s s e c t i o n w e p r e s e n t t h e p e r f o r m a n c e o f S R M i n p r a c t i c a l s c e n a r i o s a n d , i n p a r t i c u l a r , c o m p a r e i t s p e r f o r m a n c e  

t o t h a t o f a n e c i e n t i m p l e m e n t a t i o n o f D S M a n d d e m o n s t r a t e t h a t S R M s i g n i c a n t l y o u t p e r f o r m s D S M . W e b e g i n  

w i t h a d e s c r i p t i o n o f t h e c o m p u t e r s y s t e m a n d p r o g r a m m i n g e n v i r o n m e n t o f o u r i m p l e m e n t a t i o n s .  

4 . 5 . 1 C o m p u t e r S y s t e m a n d E n v i r o n m e n t  

O u r e x p e r i m e n t s w e r e c a r r i e d o u t o n a D i g i t a l P e r s o n a l W o r k s t a t i o n w i t h a 5 0 0 M h z E V 5 . 6 ( 2 1 1 6 4 A ) C P U . W e u s e d  

D  = 6 s t a t e - o f - t h e - a r t S T 3 4 5 0 1 W C h e e t a h I n c ] d i s k s f o r o u r e x p e r i m e n t s , t w o d i s k s o n e a c h o n e o f t h r e e U l t r a - W i d e  

S C S I b u s e s a t t a c h e d t o t h e s y s t e m . T h e o p e r a t i n g s y s t e m w a s D i g i t a l U n i x V e r s i o n 4 . 0 .  

B o t h t h e a l g o r i t h m s w e r e i m p l e m e n t e d u s i n g t h e   T r a n s p a r e n t P a r a l l e l I / O E n v i r o n m e n t ( T P I E )   V e n 9 5 ] p r o -  

g r a m m i n g e n v i r o n m e n t , w h i c h w a s o r i g i n a l l y d e v e l o p e d b y D a r r e n V e n g r o V e n 9 4 ] f o r h i s P h D a n d i s c u r r e n t l y  

b e i n g e x t e n d e d a s p a r t o f a n o n g o i n g p r o j e c t a t D u k e U n i v e r s i t y ' s C e n t e r f o r G e o m e t r i c C o m p u t i n g . T P I E i s a  

s t r e a m - o r i e n t e d e n v i r o n m e n t w r i t t e n i n C + + d e s i g n e d t o e n a b l e t h e i m p l e m e n t a t i o n o f e c i e n t e x t e r n a l m e m o r y a l -  

g o r i t h m s o n s i n g l e a n d m u l t i p l e d i s k s y s t e m s . I t p r o v i d e s b a s i c b u i l d i n g b l o c k s f o r p r o g r a m m e r s t o u s e w h i l e w r i t i n g  

e x t e r n a l m e m o r y p r o g r a m s . T P I E h a s b u i l t - i n f e a t u r e s s u c h a s a m e m o r y m a n a g e r t h a t m a n a g e s b u e r s ; i t a l s o k e e p s  

t r a c k o f t h e a m o u n t o f i n t e r n a l m e m o r y u s e d b y a p r o g r a m , w h i c h i s v e r y u s e f u l t o c o n t r o l m e m o r y u t i l i z a t i o n d u r i n g  

e x p e r i m e n t s a s w e l l a s i n m e m o r y m a n a g e m e n t i n g e n e r a l .  

W e i m p l e m e n t e d a n i n t e r f a c e f o r p a r a l l e l d i s k s t r e a m s s t r i p e d i n t h e u s u a l r o u n d - r o b i n m a n n e r i n u n i t s o f l o g i c a l  

b l o c k s a c r o s s t h e s i x d i s k s . E a c h s t r i p e d s t r e a m c o n s i s t s o f o n e U n i x l e o n e a c h d i s k ; e a c h d i s k i s a s e p a r a t e l y  

m o u n t e d l e s y s t e m . I n o r d e r t o f a c i l i t a t e r a n d o m i z e d s t r i p i n g , o u r i n t e r f a c e a l l o w s a n a p p l i c a t i o n t o b e g i n s t r i p i n g  

o n a n y d i s k o f i t s c h o i c e . T h e I / O o p e r a t i o n s o f T P I E u s e d i n o u r e x p e r i m e n t s w e r e i m p l e m e n t e d u s i n g a n e n h a n c e d  

v e r s i o n C A B G 9 8 ] o f m e m o r y - m a p p e d I / O c a l l s . A p a r a l l e l I / O o p e r a t i o n i s s i m u l a t e d b y s i x m e m o r y - m a p p e d I / O  

c a l l s , o n e t o e a c h d i s k . E a c h m e m o r y - m a p p e d I / O c a l l i s a n o n - b l o c k i n g c a l l t h a t i n s t a n t a n e o u s l y d i s p a t c h e s o a n  

a s y n c h r o n o u s I / O o p e r a t i o n u n d e r t h e h o o d . I n a l l o u r e x p e r i m e n t s , t h e s i z e o f t h e u n i e d b u e r c a c h e w a s s m a l l  

e n o u g h ( r e l a t i v e t o t h e a m o u n t o f d a t a i n v o l v e d w h i l e s o r t i n g ) s o t h a t e e c t s f r o m t h e b u e r i n g i n t h e u n i e d b u e r  

c a c h e w e r e n e g l i g i b l e .  

7 4 

Page 88: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 88/203

B l o c k S i z e  

I n o u r e x p e r i m e n t s , w e u s e d a l o g i c a l b l o c k s i z e o f 2 5 6 K B ; t h u s , a l l t h e m e m o r y - m a p p e d I / O c a l l s m a p p e d r e g i o n s  

o f s i z e 2 5 6 K B . I t w o u l d b e i n t e r e s t i n g t o e x p l o r e u s e o f a s m a l l e r l o g i c a l b l o c k s i z e i f w e h a d c o n t r o l o v e r d i s k  

b l o c k a l l o c a t i o n , d i s k s c h e d u l i n g a n d s o o n , b e c a u s e w e c o u l d u s e t e c h n i q u e s a s i n Z L 9 6 , Z L 9 8 ] t o a c h i e v e g o o d I / O  

p e r f o r m a n c e . S i n c e w e u s e l e s y s t e m s a n d d o n o t h a v e s u c h c o n t r o l , w e c a n s t i l l e n s u r e t h a t t h e d i s k b l o c k a l l o c a t i o n ,  

r e a d a h e a d , a n d d i s k s c h e d u l i n g w i l l b e d o n e e c i e n t l y b y u s e o f l a r g e b l o c k s i z e s i n m e m o r y - m a p p e d c a l l s ( h e n c e  

o u r c h o i c e o f t h e 2 5 6 K B s i z e ) a n d b y m a k i n g s u r e t h a t e a c h U n i x l e i s a c c e s s e d s e q u e n t i a l l y ( s o t h a t l e s y s t e m  

r e a d a h e a d i s t r i g g e r e d w h e r e v e r p o s s i b l e ) . W e s e t t h e b l o c k s i z e t o 2 5 6 K B f o r b o t h D S M a n d S R M s o a s t o a l l o w  

p r o p e r c o m p a r i s o n s i n p e r f o r m a n c e .  

4 . 5 . 2 I n p u t C h a r a c t e r i s t i c s  

F o r a l l o u r e x p e r i m e n t s , w e c o n s i d e r e d i t e m s o f s i z e   I  = 1 0 4 b y t e s , w i t h k e y s o f s i z e   K  = 8 b y t e s a n d a b l o c k s i z e  

B  = 2 5 2 0 i t e m s ( o f s i z e 2 5 6 K B ) . T h e u n s o r t e d i n p u t s t r e a m f o r e a c h r u n o f t h e t w o s o r t i n g a l g o r i t h m s w a s a l w a y s  

a u n i f o r m l y r a n d o m l y g e n e r a t e d s e q u e n c e o f i t e m s .   B o t h S R M a n d D S M , i n o u r i m p l e m e n t a t i o n , u s e t h e s a m e r u n  

f o r m a t i o n a l g o r i t h m a n d s o f o r a g i v e n i n t e r n a l m e m o r y s i z e , b o t h a l g o r i t h m s h a v e t o m e r g e a n i d e n t i c a l n u m b e r o f  

r u n s d u r i n g t h e i r m e r g i n g p h a s e .  

B e c a u s e o f t h e r a n d o m i z a t i o n u s e d b y S R M , i t i s h a r d t o c o n s t r u c t a p a r t i c u l a r s e q u e n c e o f i n p u t r e c o r d s t h a t  

b r i n g s o u t b a d I / O p e r f o r m a n c e i n S R M ' s m e r g i n g p h a s e ; i n d e e d , t h e w h o l e p o i n t o f r a n d o m i z a t i o n i s t o e n s u r e  

t h a t n o p a t h o l o g i c a l l y o r d e r e d i n p u t l e c a n h i n d e r t h e p e r f o r m a n c e o f S R M . M o r e o v e r t h e v e r y n a t u r e o f S R M  

e n s u r e s t h a t i t s p e r f o r m a n c e c a n n o t d e g r a d e i f s o m e r u n s u d d e n l y g e t s c o n s u m e d a t h i g h e r r a t e s r e l a t i v e t o o t h e r s ;  

t h i s i s b e c a u s e a l l r u n s a r e s t r i p e d a n d b e c a u s e e a c h   P a r a l l e l R e a d   o p e r a t i o n a l w a y s r e a d s i n t o i n t e r n a l m e m o r y  

t h e s m a l l e s t b l o c k f r o m e a c h d i s k . W e b e l i e v e t h a t s k e w e d a n d n o n u n i f o r m l y r a n d o m l y g e n e r a t e d i n p u t s c a n n o t  

s i g n i c a n t l y c h a n g e t h e p e r f o r m a n c e c h a r a c t e r i s t i c s o f S R M a n d D S M .  

4 . 5 . 3 D S M a n d S R M C o n g u r a t i o n s  

E a c h b u e r o f a s t r i p e d - I / O p a r a l l e l d i s k s t r e a m c o n t a i n s   D B  i t e m s . S i n c e e a c h s t r i p e d - I / O s t r e a m u s e s d o u b l e  

b u e r i n g , t h e a m o u n t o f i n t e r n a l m e m o r y u s e d b y e a c h s t r i p e d - I / O p a r a l l e l d i s k s t r e a m i s 3   2 M B , w h i c h s l i g h t l y  

l a r g e r t h a n 2  D B I  b y t e s o w i n g t o s o m e o t h e r i m p l e m e n t a t i o n r e l a t e d o v e r h e a d s .  

R u n F o r m a t i o n a n d t h e N u m b e r o f R u n s F o r m e d  

T h e r u n f o r m a t i o n s t a g e o f b o t h S R M a n d D S M i n v o l v e s a t m o s t t w o s t r i p e d - I / O p a r a l l e l d i s k s t r e a m s a c t i v e a t a n y  

t i m e . T h u s , t h e n u m b e r o f r u n s g e n e r a t e d d u r i n g r u n f o r m a t i o n i s d e t e r m i n e d b y t h e a m o u n t o f i n t e r n a l m e m o r y t h e  

a l g o r i t h m i s a l l o w e d t o u s e , t h e a m o u n t o f i n t e r n a l m e m o r y c o n s u m e d b y t h e b u e r s o f a s t r i p e d - I / O s t r e a m , a n d t h e  

7 5 

Page 89: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 89/203

a m o u n t o f i n t e r n a l m e m o r y t h a t T P I E r e s e r v e s f o r p r o g r a m v a r i a b l e s . I n t h e r e s t o f t h i s s e c t i o n , w e u s e t h e s y m b o l  

U  t o d e n o t e t h e n u m b e r o f r u n s f o r m e d d u r i n g t h e r u n f o r m a t i o n s t a g e o f a n y g i v e n e x p e r i m e n t .  

D e t e r m i n i n g t h e M e r g e O r d e r  

D u r i n g t h e m e r g i n g p a s s , S R M a n d D S M u s e i n t e r n a l m e m o r y i n v e r y d i e r e n t w a y s . G i v e n t h e s a m e a m o u n t s o f  

m e m o r y , t h e m a x i m u m m e r g e o r d e r o f a n S R M m e r g e o p e r a t i o n i s s i g n i c a n t l y l a r g e r t h a n t h e m a x i m u m m e r g e o r d e r  

o f a D S M m e r g e o p e r a t i o n . D u r i n g a m e r g e o f o r d e r   R  , D S M r e q u i r e s e n o u g h i n t e r n a l m e m o r y t o h a v e 3   2 M B s i z e d  

b u e r s f o r e a c h o n e o f   R  + 1 s t r e a m s . T h u s t h e m e r g e o r d e r f o r D S M i s d e t e r m i n e d i n a s t r a i g h t f o r w a r d m a n n e r .  

O n t h e o t h e r h a n d , i n o r d e r t o c a r r y o u t a n   R  - w a y m e r g e , S R M r e q u i r e s o n l y o n e b u e r o f s i z e 3   2 M B ( c o r r e -  

s p o n d i n g t o t w o b u e r s o f s i z e   D B  f o r i t s o u t p u t r u n ) , 2  R  +  D  b u e r s o f s i z e 2 5 6 K B ( c o r r e s p o n d i n g t o   B  ) , s p a c e  

f o r f o r e c a s t i n g d a t a a n d s o m e o t h e r s m a l l p e r - r u n m e m o r y o v e r h e a d s . I n a l l o u r e x p e r i m e n t s , a l l t h e f o r e c a s t i n g d a t a  

c o n s u m e d a v e r y s m a l l f r a c t i o n o f t h e t o t a l a m o u n t o f i n t e r n a l m e m o r y a v a i l a b l e : I t w a s a l w a y s s m a l l e r t h a n 1 0 0 K B ,  

w h e r e a s t h e i n t e r n a l m e m o r y a v a i l a b l e i n o u r t w o s e t s o f e x p e r i m e n t s w e r e     1 5 M B a n d     2 4 M B r e s p e c t i v e l y . I t i s  

v e r y o f t e n t h e c a s e i n S R M t h a t t h e r e i s a w i d e r a n g e o f f e a s i b l e v a l u e s f o r   R  i n w h i c h t h e r e s u l t i n g n u m b e r   d  l o g 

U  e 

o f m e r g i n g p a s s e s r e q u i r e d t o m e r g e t h e i n i t i a l   U  r u n s i s t h e s a m e o p t i m a l v a l u e . I n s u c h c a s e s ,   w e s e t S R M ' s m e r g e  

o r d e r   R  t o b e e q u a l t o t h e s m a l l e s t p o s s i b l e f e a s i b l e v a l u e r e s u l t i n g i n a n o p t i m a l n u m b e r   d  l o g 

U  e  o f m e r g i n g p a s s e s ,  

b u t f o r p r a c t i c a l r e a s o n s w e n e v e r s e t   R  h i g h e r t h a n 1 9 .   T h e a d v a n t a g e o f u s i n g t h e s m a l l e s t p o s s i b l e m e r g e o r d e r i s  

t h a t t h e n u m b e r o f l e s i n v o l v e d i n t h e m e r g e i s t h e s m a l l e s t p o s s i b l e , w h i c h t e n d s t o k e e p t h e a m o u n t o f d i s k l a t e n c y  

i n c u r r e d w h i l e m e r g i n g a s s m a l l a s p o s s i b l e . A n o t h e r a d v a n t a g e i s t h a t t h e a v e r a g e a m o u n t o f i n t e r n a l m e m o r y s p a c e  

a v a i l a b l e p e r i n p u t r u n d u r i n g a m e r g e o p e r a t i o n i s i n c r e a s e d , w h i c h h a s t h e e e c t o f m i n i m i z i n g t h e o v e r h e a d    

( d e n e d i n S e c t i o n 4 . 3 ) i n c u r r e d i n e v e r y m e r g i n g p a s s .  

E v e n t h o u g h w e t r y t o k e e p t h e m e r g e o r d e r o f S R M a s s m a l l a s i s p o s s i b l e ,   t h e m e r g e o r d e r o f S R M m e r g i n g  

o p e r a t i o n s i s s i g n i c a n t l y g r e a t e r t h a n D S M m e r g i n g o p e r a t i o n s .   H e n c e o n e e x p e c t s t h a t D S M m e r g i n g p a s s e s w i l l  

h a v e h i g h e r d i s k l o c a l i t y a n d t h a t S R M m e r g i n g p a s s e s w i l l i n c u r m o r e o v e r h e a d r e l a t i v e t o D S M m e r g i n g p a s s e s o n  

a c c o u n t o f d i s k l a t e n c y .  

4 . 5 . 4 P e r f o r m a n c e N u m b e r s a n d G r a p h s  

I n t h i s s e c t i o n w e r e p o r t o n t w o s e t s o f e x p e r i m e n t s t o c o m p a r e t h e p e r f o r m a n c e o f S R M a n d D S M . I n b o t h c a s e s ,  

t h e i n p u t l e s i z e w a s v a r i e d i n u n i t s o f o n e m i l l i o n i t e m s (    1 0 0 M B ) i n t h e r a n g e f r o m 1 m i l l i o n i t e m s (    1 0 0 B )  

t o 1 0 m i l l i o n i t e m s (    1 G B ) . I n t h e r s t s e t o f e x p e r i m e n t s , t h e a m o u n t o f i n t e r n a l m e m o r y a v a i l a b l e t o t h e s o r t i n g  

a l g o r i t h m w a s 1 5 M B w h e r e a s i n t h e s e c o n d s e t o f e x p e r i m e n t s i t w a s 2 4 M B .  

I n F i g u r e 4 . 1 T a b l e s 4 . 1 a n d 4 . 2 , w e p r e s e n t t h e p e r f o r m a n c e n u m b e r s f o r t h e m e r g i n g p h a s e s o f b o t h a l g o r i t h m s  

f o r t h e t w o s e t s o f e x p e r i m e n t s . T a b l e 4 . 1 i s t h e t a b l e c o r r e s p o n d i n g t o e x p e r i m e n t s f o r i n t e r n a l m e m o r y s i z e 1 5 M B ,  

a n d T a b l e 4 . 2 i s t h e t a b l e c o r r e s p o n d i n g t o e x p e r i m e n t s f o r i n t e r n a l m e m o r y s i z e 2 4 M B . E a c h d a t a p o i n t i n T a b l e s  

7 6 

Page 90: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 90/203

N  = 1  N  = 2  N  = 3  N  = 4  N  = 5  N  = 6  N  = 7  N  = 8  N  = 9  N  = 1 0 

U  1 2 2 4 3 6 4 7 5 9 7 1 8 2 9 4 1 0 6 1 1 7  

P a s s e s  

D S M 

3 3 4 4 4 4 5 5 5 5  

D S M 

3 3 3 3 3 3 3 3 3 3  

T i m e  

D S M 

( s ) 1 8  3 3 5  7 7 0  8 9 5  8 1 2 2 1 4 1  2 1 9 8  4 2 2 6  2 2 5 4  8 2 8 4  2 

R a t e  

D S M 

( M B / s ) 3 2  5 3 3  3 3 3  6 3 3  1 3 2  5 3 3  7 3 5  0 3 5  1 3 5  0 3 4  9 

P a s s e s  

S R M 

1 2 2 2 2 2 2 2 2 2  

S R M 

1 2 5 6 7 8 9 1 0 1 0 1 1 1 1  

T i m e  

S R M 

( s ) 6  3 2 6  6 3 9  2 5 2  0 6 5  8 7 9  2 9 1  0 1 0 4  8 1 1 9  2 1 3 8  4 

R a t e  

S R M 

( M B / s ) 3 1  5 2 9  8 3 0  4 3 0  5 3 0  2 3 0  1 3 0  5 3 0  3 3 0  0 2 8  7 

  1  0 4 1  0 3 1  0 4 1  0 3 1  0 3 1  0 4 1  0 3 1  0 3 1  0 3 1  0 3 

T a b l e 4 . 1   : C o m p a r i n g S R M a n d D S M w h e n i n t e r n a l m e m o r y i s 1 5 M B a n d t h e r e a r e   D  = 6 d i s k s . T h e i n p u t s i z e  

N  i s i n u n i t s o f 1 m i l l i o n i t e m s , e a c h o f s i z e 1 0 4 b y t e s .  

N  = 1  N  = 2  N  = 3  N  = 4  N  = 5  N  = 6  N  = 7  N  = 8  N  = 9  N  = 1 0 

U  7 1 4 2 0 2 7 3 3 4 0 4 6 5 3 6 0 6 6  

P a s s e s  

D S M 

2 2 2 3 3 3 3 3 3 3  

D S M 

5 5 5 5 5 5 5 5 5 5  

T i m e  

D S M 

( s ) 1 1  5 2 1  2 3 2  4 6 3  0 7 9  6 9 5  0 1 1 0  6 1 2 7  2 1 4 3  2 1 5 8  2 

R a t e  

D S M 

( M B / s ) 3 4  5 3 7  4 3 6  7 3 7  8 3 7  4 3 7  6 3 7  7 3 7  4 3 7  4 3 7  6 

P a s s e s  

S R M 

1 1 2 2 2 2 2 2 2 2  

S R M 

7 1 4 5 6 6 7 7 8 8 9  

T i m e  

S R M 

( s ) 6  0 2 0  0 3 6  0 4 8  8 6 2  4 7 5  4 8 9  2 1 0 0  4 1 1 4  6 1 2 6  0 

R a t e  

S R M 

( M B / s ) 3 3  1 1 9  8 3 3  1 3 2  5 3 1  8 3 1  6 3 1  1 3 1  6 3 1  2 3 1  5 

  1  0 0 1  0 0 1  0 0 1  0 1 1  0 1 1  0 1 1  0 1 1  0 1 1  0 1 1  0 1 

T a b l e 4 . 2  : C o m p a r i n g S R M a n d D S M w h e n m e m o r y i s 2 4 M B a n d t h e r e a r e   D  = 6 d i s k s . T h e i n p u t s i z e   N  i s i n  

u n i t s o f 1 m i l l i o n s i t e m s , e a c h o f s i z e 1 0 4 b y t e s .  

4 . 1 a n d 4 . 2 i s b a s e d u p o n t h e a v e r a g e v a l u e o b t a i n e d b y c o n d u c t i n g t h e s a m e e x p e r i m e n t v e t i m e s w i t h a d i e r e n t  

r a n d o m i n p u t o n e a c h r u n . T h e g r a p h i n F i g u r e 4 . 1 p l o t s t h e a v e r a g e t i m e i n s e c o n d s r e q u i r e d t o c o m p l e t e t h e  

m e r g i n g p h a s e o f S R M o r D S M a t a g i v e n d a t a p o i n t . T h e t a b l e s p r o v i d e a d d i t i o n a l i n s i g h t f u l i n f o r m a t i o n . O f  

p a r t i c u l a r i n t e r e s t i s t h e   a v e r a g e d a t a s t r e a m i n g r a t e   d u r i n g a m e r g i n g p h a s e , w h i c h i s d e n e d a s t h e t o t a l a m o u n t  

o f I / O ( r e a d s a s w e l l a s w r i t e s ) i n b y t e s d u r i n g t h e m e r g i n g p h a s e , d i v i d e d b y t h e t i m e r e q u i r e d t o c o m p l e t e t h e  

m e r g i n g p h a s e .  

E a c h t a b l e l i s t s t h e t o t a l n u m b e r   U  o f r u n s f o r m e d d u r i n g r u n f o r m a t i o n , w h i c h i s i d e n t i c a l f o r b o t h S R M a n d  

D S M . F o r D S M , t h e t a b l e l i s t s t h e m e r g e o r d e r   R 

D S M 

( e a c h m e r g e o p e r a t i o n e x c e p t p o s s i b l y t h e l a s t m e r g e o p e r a t i o n  

o f a D S M m e r g i n g p h a s e h a s t h i s m e r g e o r d e r ) , t h e n u m b e r   P a s s e s  

D S M 

o f p a s s e s , t h e t i m e   T i m e  

D S M 

r e q u i r e d t o  

c o m p l e t e t h e m e r g i n g p h a s e , a n d t h e d a t a s t r e a m i n g r a t e   R a t e  

D S M 

a t t a i n e d b y D S M d u r i n g i t s m e r g i n g p h a s e .  

F o r S R M , f o r e a c h d a t a p o i n t , t h e t a b l e l i s t s t h e n u m b e r   P a s s e s  

S R M 

o f p a s s e s , t h e m e r g e o r d e r   R 

S R M 

( o f e a c h  

S R M m e r g i n g o p e r a t i o n i n t h e m e r g i n g p h a s e e x c e p t p o s s i b l y t h e l a s t o n e ) , t h e t i m e   T i m e  

S R M 

r e q u i r e d t o c o m p l e t e  

t h e m e r g i n g p h a s e , S R M ' s d a t a s t r e a m i n g r a t e   R a t e  

S R M 

, a n d t h e o v e r h e a d     c o r r e s p o n d i n g t o e x t r a p a r a l l e l r e a d  

o p e r a t i o n s .  

4 . 5 . 5 R e l a t i v e P e r f o r m a n c e C o m p a r i s o n s  

S R M s i g n i c a n t l y o u t p e r f o r m s D S M i n t h e e x p e r i m e n t s . F o r t h e e x p e r i m e n t s w i t h i n t e r n a l m e m o r y s i z e 1 5 M B ,  

S R M ' s p e r f o r m a n c e i s b e t t e r b y a m a r g i n o f a l m o s t 5 0 % . S R M ' s m a r g i n o f i m p r o v e m e n t i s l e s s i m p r e s s i v e w i t h  

i n t e r n a l m e m o r y s i z e 2 4 M B ; b u t t h e i m p r o v e m e n t i s s t i l l i n t h e 2 5 % b a l l p a r k f o r i n p u t s i z e s l a r g e r t h a n   N  = 4 

m i l l i o n i t e m s . T h e r e i s o n e d a t a p o i n t (  N  = 3 m i l l i o n i t e m s , w i t h m e m o r y s i z e o f 2 4 M B ) a t w h i c h D S M i s a c t u a l l y  

7 7 

Page 91: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 91/203

0.0

50.0

100.0

150.0

200.0

250.0

300.0

1 2 3 4 5 6 7 8 9 10

   T   i  m  e   i  n  s  e  c  o  n   d  s

Input Size N in millions of items

"DSM,15""SRM,15""DSM,24""SRM,24"

F i g u r e 4 . 1  : M e r g i n g P h a s e T i m i n g s o f S R M a n d D S M .  

m a r g i n a l l y b e t t e r t h a n S R M ; t h i s h a p p e n s t o b e t h e o n l y p o i n t i n a l l o u r e x p e r i m e n t s i n w h i c h D S M a n d S R M r e q u i r e  

t h e s a m e n u m b e r o f p a s s e s .  

T h e a v e r a g e d a t a s t r e a m i n g r a t e o f D S M i s c o n s i s t e n t l y b e t t e r t h a n t h a t o f S R M , a s a n t i c i p a t e d , b u t S R M  

o u t p e r f o r m s D S M b e c a u s e o f i t s s m a l l e r n u m b e r o f p a s s e s . W h e n w e c o m p a r e S R M ' s s t r e a m i n g r a t e f o r 1 5 M B w i t h  

i t s s t r e a m i n g r a t e f o r 2 4 M B , w e s e e a n o v e r a l l i m p r o v e m e n t i n s t r e a m i n g r a t e f o r t h e l a r g e r i n t e r n a l m e m o r y s i z e ,  

s i n c e t h e n u m b e r o f r u n s i s r e d u c e d a n d S R M ' s m e r g e o r d e r t e n d s t o b e s m a l l e r . W e a r e n o t a b l e t o e x p l a i n t h e  

i m p r o v e m e n t i n t h e s t r e a m i n g r a t e o f D S M ' s p e r f o r m a n c e i n t h e e x p e r i m e n t s w i t h 2 4 M B r e l a t i v e t o i t s p e r f o r m a n c e  

i n t h e e x p e r i m e n t s w i t h 1 5 M B ; t h e i m p r o v e m e n t i s s o m e w h a t s u r p r i s i n g b e c a u s e D S M ' s m e r g e o r d e r i n c r e a s e s f r o m 3  

t o 5 w h e n t h e i n t e r n a l m e m o r y i s i n c r e a s e d .  

T h e o v e r h e a d     i n t h e t o t a l n u m b e r o f   P a r a l l e l R e a d   o p e r a t i o n s r e q u i r e d b y S R M i s s m a l l , v e r y c l o s e t o 1 , a s  

e x p e c t e d o n t h e b a s i s o f p r e v i o u s a n a l y s i s i n C h a p t e r 3 . T h i s s u g g e s t s t o u s t h a t t h e e l a p s e d t i m e p e r f o r m a n c e i s  

n o t h i n d e r e d b y t h e u s h o p e r a t i o n s i n c u r r e d b y S R M ; i f t h e i m p l e m e n t a t i o n o f t h e   P a r a l l e l R e a d   c a n b e i m p r o v e d ,  

w h i c h w e t h i n k p o s s i b l e , w e c a n g e t f u r t h e r i m p r o v e m e n t o f S R M ' s e l a p s e d t i m e p e r f o r m a n c e . W e b r i e y m e n t i o n  

p o s s i b l e a p p r o a c h e s t o i m p r o v e t h e p e r f o r m a n c e o f e a c h p a r a l l e l I / O o p e r a t i o n i n S e c t i o n 4 . 5 . 6 .  

O n e i n t e r e s t i n g o b s e r v a t i o n r e g a r d i n g o u r d a t a p o i n t s i s t h e s u d d e n d r o p i n s t r e a m i n g r a t e w h e n t h e m e r g e o r d e r  

b e c o m e s 1 4 , a s i n t h e c a s e w i t h   N  = 2 m i l l i o n i t e m s a n d a n i n t e r n a l m e m o r y s i z e o f 2 4 M B . I n t h i s c a s e , t h e  

s t r e a m i n g r a t e i s 2 2 M B / s e c , a l t h o u g h a s t r e a m i n g r a t e o f a l m o s t 3 0 M B / s e c i s p o s s i b l e f o r   R  = 1 1 ,   N  = 9 m i l l i o n  

i t e m s a n d   N  = 1 0 m i l l i o n i t e m s , a n d i n t e r n a l m e m o r y s i z e o f 1 5 M B . W e w e r e n o t a b l e t o a c c o u n t f o r t h e s u d d e n  

7 8 

Page 92: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 92/203

d r o p i n s t r e a m i n g r a t e ; s o m e p r e l i m i n a r y e x p e r i m e n t s i n d i c a t e t h a t t h e m o s t i m p o r t a n t r e a s o n f o r t h e s u d d e n d r o p i n  

s t r e a m i n g r a t e m a y n o t b e t h e i n c r e a s e d s e e k i n g b u t s o m e o t h e r e e c t s p e r h a p s r e l a t e d t o t h e n u m b e r o f l e s o p e n e d  

b y t h e a p p l i c a t i o n a t a n y t i m e .  

4 . 5 . 6 I m p r o v i n g I / O P e r f o r m a n c e  

S R M c a n b e m a d e t o p e r f o r m e v e n b e t t e r i f t h e i m p l e m e n t a t i o n o f t h e p a r a l l e l I / O i s i m p r o v e d . T h e h a r d w a r e b e i n g  

u s e d ( t h e C P U a n d t h e I / O s y s t e m ) a n d o u r e x p e r i e n c e w i t h p a r a l l e l I / O s y s t e m s B S G  

9 8 , B G H  

9 7 ] s u g g e s t t h a t  

t h e r e i s s c o p e f o r i m p r o v i n g t h e p e r f o r m a n c e o f p a r a l l e l I / O o p e r a t i o n s i n o u r i m p l e m e n t a t i o n , t h e r e b y i m p r o v i n g t h e  

s t r e a m i n g d a t a r a t e s . P o s s i b l e t e c h n i q u e s t o i m p r o v e p e r f o r m a n c e w h e n w e h a v e c o n t r o l o v e r d i s k b l o c k a l l o c a t i o n ,  

d i s k s c h e d u l i n g e t c . ( a s d i s c u s s e d i n S e c t i o n 4 . 5 . 1 ) i n c l u d e c o n t r o l l i n g t h e l a y o u t o f b l o c k s o f r u n s a n d c a r e f u l l y  

p l a n n i n g t h e s e q u e n c e i n w h i c h b l o c k s f r o m e a c h d i s k c a n b e r e a d i n t o m e m o r y Z L 9 6 , Z L 9 8 ] . A n o t h e r a p p r o a c h t h a t  

m a y h e l p i n i m p r o v i n g I / O p e r f o r m a n c e i s t o u s e t e c h n i q u e s s u c h a s t h e o n e i n B S G  

9 8 ] w h i c h e x p l o i t t h e r e a d a h e a d  

m e c h a n i s m u s e d b y d i s k d r i v e c o n t r o l l e r s t o l o a d d a t a i n t o t h e i r t r a c k b u e r s . A s i m p l e h i g h - l e v e l a p p r o a c h t h a t m a y  

r e s u l t i n i m p r o v e d p e r f o r m a n c e i s i f w e s p l i t t h e s e t o f d i s k s i n t o t w o s e t s a n d t h e n u s e d o n e s e t t o s t o r e i n p u t r u n s  

a n d t h e o t h e r f o r o u t p u t r u n s , s w a p p i n g t h e i r r o l e a f t e r e a c h m e r g e p a s s ; t h i s a p p r o a c h e n s u r e s t h a t w r i t e s a n d r e a d s  

d o n o t i n t e r f e r e d u r i n g t h e e x t e r n a l m e r g i n g p r o c e s s .  

4 . 6 O t h e r A p p l i c a t i o n s    

I n t h i s s e c t i o n w e b r i e y m e n t i o n o t h e r s i t u a t i o n s i n w h i c h t h e d a t a s t r u c t u r e s a n d t e c h n i q u e s w e d e v e l o p e d t o  

i m p l e m e n t S R M c a n b e u s e d f r u i t f u l l y .  

4 . 6 . 1 D i s t r i b u t i o n S o r t a n d M u l t i - w a y P a r t i t i o n i n g  

C o n s i d e r a d i s t r i b u t i o n s o r t o r t h e p a r t i t i o n i n g o f a s t r e a m i n t o s e v e r a l o t h e r s t r e a m s o n a n I / O s y s t e m w i t h   D  d i s k s .  

S u c h a d i s t r i b u t i o n / p a r t i t i o n i n g t y p e o f c o m p u t a t i o n m a y b e r e q u i r e d a s p a r t o f s o m e o t h e r d a t a b a s e o p e r a t i o n , f o r  

e x a m p l e i n a h a s h j o i n . W e c o u l d e n v i s a g e u s i n g s t r i p e d I / O t o e n s u r e p e r f e c t p a r a l l e l i s m o n a l l   D  d i s k s . B u t u s e  

o f s t r i p e d I / O w o u l d m e a n t h a t t h e n u m b e r o f s t r e a m s i n t o w h i c h a n i n p u t s t r e a m c a n b e d i s t r i b u t e d u s i n g i n t e r n a l  

m e m o r y s i z e   M  w o u l d b e   O  (  M = D B   ) ; w h e n t h e n u m b e r o f p a r t i t i o n s o r b u c k e t s d e s i r e d i s l a r g e , m a n y d i s t r i b u t i o n  

p a s s e s w o u l d b e r e q u i r e d . I n t h i s s i t u a t i o n , j u s t l i k e i t w a s d e s i r a b l e t o m e r g e   O  (  M = B  ) r u n s a t a t i m e d u r i n g e x t e r n a l  

m e r g e s o r t , i t i s d e s i r a b l e t o b e a b l e t o p a r t i t i o n a n i n p u t s t r e a m i n t o   O  (  M = B  ) s t r e a m s . A r a n d o m i z e d s t r i p i n g o f  

t h e  R  o u t p u t s t r e a m s a n d 2  R  i n t e r n a l m e m o r y b l o c k s w i l l h e l p i n i m p l e m e n t i n g a n   R  - w a y d i s t r i b u t i o n . I n s u c h a  

s c h e m e , d a t a s t r u c t u r e s a n d m e c h a n i s m s s i m i l a r t o t h e o n e s w e d e v e l o p e d i n t h i s c h a p t e r c a n b e u s e d : F o r i n s t a n c e ,  

b l o c k s d e s t i n e d t o g o t o d i s k   d  c a n b e q u e u e d u p i n q u e u e   O Q 

, a n d a   P a r a l l e l W r i t e   a n a l o g o u s t o   P a r a l l e l R e a d  

c a n w r i t e t h e b l o c k c o r r e s p o n d i n g t o t h e h e a d o f t h e   O Q 

q u e u e a p p r o p r i a t e l y t o d i s k   d 

7 9 

Page 93: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 93/203

4 . 6 . 2 S t r e a m i n g T h r o u g h M u l t i m e d i a F i l e s  

T h e p r o b l e m o f e x t e r n a l m e r g i n g o f s t r e a m s t h a t a r e s t r i p e d a c r o s s d i s k s i s s i m i l a r i n t e r m s o f a c c e s s p a t t e r n s t o a  

v i d e o s e r v e r t h a t h a s t o s t r e a m t h r o u g h m u l t i p l e s t r e a m s t h a t a r e s t r i p e d a c r o s s d i s k s . T h e n o n u n i f o r m i t y o f t h e  

r a t e s a t w h i c h r u n s g e t d e p l e t e d i s s i m i l a r t o n o n u n i f o r m i t y o f s t r e a m i n g r a t e s o w i n g t o d i e r e n t c o m p r e s s i o n r a t e s  

f o r d i e r e n t f r a m e s i n t h e s t r e a m . I n b o t h c a s e s t h o u g h , t h e r a t e s o f s t r e a m i n g r e q u i r e d a r e p a r t i a l l y p r e d i c t a b l e ,  

a l b e i t t o a l i m i t e d e x t e n t . W h i l e m e r g i n g , t h e f o r e c a s t i n g k e y s p r e d i c t t h e p a r t i c i p a t i o n o r d e r o f b l o c k s o f a m e r g e .  

C o n s i d e r u s i n g a l e o f t i m e s t a m p s , w h e r e e a c h t i m e s t a m p c o r r e s p o n d s t o t h e t i m e a t w h i c h a b l o c k f r o m t h a t s t r e a m  

m u s t b e i n i n t e r n a l m e m o r y . A l e o f s u c h t i m e s t a m p s c o r r e s p o n d i n g t o a v i d e o s t r e a m i s a n a l o g o u s t o t h e f o r e c a s t i n g  

d a t a r u n c o r r e s p o n d i n g t o a r u n . H e n c e , t h e t e c h n i q u e s w e d e v e l o p e d t o i m p l e m e n t t h e l o o k a h e a d m e c h a n i s m a n d  

t h e f o r e c a s t a n d u s h b u e r m a n a g e m e n t a n d p r e f e t c h i n g s c h e m e c a n n o w b e a n a l o g o u s l y i m p l e m e n t e d u s i n g t h e  

t i m e s t a m p s t o p r e d i c t t h e t i m e a t w h i c h a b l o c k m u s t b e i n m e m o r y . O u r d a t a s t r u c t u r e s a n d t e c h n i q u e s m a y t h u s  

h a v e a p p l i c a t i o n s t o v i d e o s e r v e r s , a l t h o u g h s u b s t a n t i a l m o d i c a t i o n s m a y b e n e e d e d t o i m p l e m e n t t h e r e a l t i m e  

a s p e c t o f v i d e o s e r v e r s .  

4 . 7 C o n c l u s i o n s a n d F u t u r e W o r k      

I n t h i s c h a p t e r , w e c o n s i d e r e d t h e i m p o r t a n t p r o b l e m o f e x t e r n a l s o r t i n g i n a p a r a l l e l d i s k s e t t i n g . W e h a v e p r o p o s e d  

s i m p l e a n d e l e g a n t d a t a s t r u c t u r e s a n d t e c h n i q u e s t o i m p l e m e n t t h e S R M m e r g e s o r t a l g o r i t h m f o r p a r a l l e l d i s k s .  

T o o u r k n o w l e d g e , t h i s i s t h e r s t p r a c t i c a l i m p l e m e n t a t i o n o f a p a r a l l e l d i s k s o r t i n g a l g o r i t h m t h a t p e r f o r m s a  

p r o v a b l y o p t i m a l n u m b e r o f p a s s e s . O u r s i m p l i e d i m p l e m e n t a t i o n o f S R M i n c l u d e s a n o v e l t e c h n i q u e t o i m p l e m e n t  

a l o o k a h e a d m e c h a n i s m u s i n g f o r e c a s t i n g k e y s . O u r i m p l e m e n t a t i o n s i g n i c a n t l y o u t p e r f o r m s t h e p o p u l a r d o u b l e -  

b u e r e d d i s k - s t r i p e d m e r g e s o r t ( D S M ) t e c h n i q u e . A l t h o u g h e a c h m e r g i n g p a s s o f D S M o c c u r s a l i t t l e f a s t e r t h a n  

t h a t o f S R M , t h e s m a l l e r n u m b e r o f p a s s e s r e q u i r e d b y S R M m a k e s S R M ' s o v e r a l l p e r f o r m a n c e b e t t e r t h a n t h a t o f  

D S M . O u r t e c h n i q u e s a r e a l s o a p p l i c a b l e t o o t h e r s t r e a m i n g o p e r a t i o n s i n d a t a b a s e s .  

I n f u t u r e w o r k , w e h o p e t o i m p r o v e t h e i m p l e m e n t a t i o n o f p a r a l l e l I / O o p e r a t i o n s i n T P I E a n d t h u s g e t a n  

i m p r o v m e n t i n t h e e l a p s e d t i m e p e r f o r m a n c e o f S R M . W e a l s o p l a n t o i m p l e m e n t a p a r a l l e l d i s k d i s t r i b u t i o n s o r t b a s e d  

u p o n a s i m p l i e d v e r s i o n o f t h e a l g o r i t h m i n V S 9 4 ] , b u t d o i n g t h e d i s t r i b u t i o n u s i n g t h e a p p r o a c h o f S e c t i o n 4 . 6 . 1 ,  

a n a l o g o u s t o t h e o n e i n S R M e x e c u t e d i n \ r e v e r s e " . C o m p a r i n g t h e p e r f o r m a n c e o f s u c h a s o r t w i t h S R M s h o u l d  

b e p a r t i c u l a r l y i n t e r e s t i n g b e c a u s e d i s k d r i v e s m a y b e s o m e w h a t b e t t e r a t p e r f o r m i n g t h e k i n d o f I / O n e e d e d f o r  

d i s t r i b u t i o n c o m p a r e d t o m e r g i n g . ( I n t h e e n v i s i o n e d p a r a l l e l e x t e r n a l d i s t r i b u t i o n o p e r a t i o n , t h e i n p u t s t r e a m i s  

i m p l e m e n t e d u s i n g s t r i p e d I / O , w h e r e a s t h e o u t p u t s t r e a m r e q u i r e s p a r a l l e l i n d e p e n d e n t d i s k a c c e s s e s . )  

8 0 

Page 94: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 94/203

C h a p t e r 5      

M e m o r y - A d a p t i v e E x t e r n a l M e m o r y      

A l g o r i t h m s    

S u m m a r y .  

W e c o n s i d e r t h e p r o b l e m o f d e v i s i n g e x t e r n a l m e m o r y a l g o r i t h m s w h o s e m e m o r y a l l o c a t i o n s c a n c h a n g e d y n a m i c a l l y  

a n d u n p r e d i c t a b l y a t r u n - t i m e . T h e i n v e s t i g a t i o n o f \ m e m o r y - a d a p t i v e " a l g o r i t h m s , w h i c h a r e d e s i g n e d t o a d a p t t o  

d y n a m i c a l l y c h a n g i n g m e m o r y a l l o c a t i o n s , c a n b e c o n s i d e r e d a n a t u r a l e x t e n s i o n o f t h e i n v e s t i g a t i o n o f t r a d i t i o n a l ,  

n o n - a d a p t i v e e x t e r n a l m e m o r y a l g o r i t h m s . O u r s t u d y i s m o t i v a t e d b y h i g h p e r f o r m a n c e d a t a b a s e s y s t e m s a n d  

o p e r a t i n g s y s t e m s i n w h i c h a p p l i c a t i o n s a r e p r i o r i t i z e d a n d i n t e r n a l m e m o r y i s d y n a m i c a l l y a l l o c a t e d i n a c c o r d a n c e  

w i t h t h e p r i o r i t i e s . I n s u c h s i t u a t i o n s , e x t e r n a l m e m o r y a p p l i c a t i o n s a r e e x p e c t e d t o p e r f o r m a s w e l l a s p o s s i b l e f o r  

t h e c u r r e n t m e m o r y a l l o c a t i o n . T h e c o m p u t a t i o n m u s t b e r e o r g a n i z e d t o a d a p t t o t h e s e q u e n c e o f m e m o r y a l l o c a t i o n s  

i n a n o n l i n e m a n n e r .  

I n t h i s p a p e r w e p r e s e n t a s i m p l e a n d n a t u r a l d y n a m i c m e m o r y a l l o c a t i o n m o d e l . W e d e n e m e m o r y - a d a p t i v e  

e x t e r n a l m e m o r y a l g o r i t h m s a n d s p e c i f y w h a t i s n e e d e d f o r t h e m t o b e d y n a m i c a l l y o p t i m a l . U s i n g n o v e l t e c h n i q u e s ,  

w e d e s i g n a n d a n a l y z e d y n a m i c a l l y o p t i m a l m e m o r y - a d a p t i v e a l g o r i t h m s f o r t h e p r o b l e m s o f s o r t i n g , p e r m u t i n g ,  

F F T , p e r m u t a t i o n n e t w o r k s , ( s t a n d a r d ) m a t r i x m u l t i p l i c a t i o n a n d L U d e c o m p o s i t i o n . W e a l s o p r e s e n t a d y n a m i c a l l y  

o p t i m a l ( i n a n a m o r t i z e d s e n s e ) m e m o r y - a d a p t i v e v e r s i o n o f t h e b u e r t r e e , a g e n e r i c e x t e r n a l m e m o r y d a t a s t r u c t u r e  

f o r a l a r g e n u m b e r o f b a t c h e d d y n a m i c a p p l i c a t i o n s . W e s h o w t h a t a p r e v i o u s l y d e v i s e d a p p r o a c h t o m e m o r y - a d a p t i v e  

e x t e r n a l m e r g e s o r t i s p r o v a b l y n o n o p t i m a l b e c a u s e o f f u n d a m e n t a l d r a w b a c k s . T h e l o w e r b o u n d p r o o f t e c h n i q u e s f o r  

s o r t i n g a n d m a t r i x m u l t i p l i c a t i o n a r e f u n d a m e n t a l l y d i s t i n c t t e c h n i q u e s , a n d t h e y a r e i n v o k e d b y m o s t o t h e r e x t e r n a l  

m e m o r y l o w e r b o u n d s ; h e n c e w e a n t i c i p a t e t h a t t h e t e c h n i q u e s p r e s e n t e d h e r e w i l l a p p l y t o m a n y e x t e r n a l m e m o r y  

p r o b l e m s .  

5 . 1 I n t r o d u c t i o n a n d M o t i v a t i o n      

T h e g r e a t m a j o r i t y o f t h e p r e v i o u s w o r k o n e x t e r n a l m e m o r y ( E M ) a l g o r i t h m s , i n c l u d i n g o u r w o r k i n t h e p r e v i o u s  

c h a p t e r s , a s s u m e s t h a t i n t e r n a l m e m o r y i s s t a t i c a l l y a l l o c a t e d a n d c a n h o l d   M  i t e m s t h r o u g h o u t t h e e x e c u t i o n o f  

t h e E M a l g o r i t h m . P r e v i o u s w o r k i n E M a l g o r i t h m s a s s u m e s t h a t a s t a t i c a l l y a l l o c a t e d i n t e r n a l m e m o r y c a p a b l e o f  

h o l d i n g   M  i t e m s i s a v a i l a b l e t h r o u g h o u t t h e e x e c u t i o n o f t h e e x t e r n a l m e m o r y a l g o r i t h m . A n a t u r a l e x t e n s i o n i s  

t o c o n s i d e r t h e p e r f o r m a n c e o f a n e x t e r n a l m e m o r y a l g o r i t h m w h e n t h e s i z e o f t h e a v a i l a b l e i n t e r n a l m e m o r y v a r i e s  

8 1 

Page 95: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 95/203

d y n a m i c a l l y b e c a u s e o f o t h e r o n g o i n g a c t i v i t y o n t h e c o m p u t i n g m a c h i n e . W i t h t h e a d v e n t o f r e a l - t i m e d a t a b a s e  

s y s t e m s S y s 9 2 , R e c 8 8 ] a n d d a t a b a s e s y s t e m s b a s e d u p o n a d m i n i s t r a t i v e l y d e n e d g o a l s F N G 8 9 , B C L 9 3 ] , i t h a s  

b e c o m e n e c e s s a r y P C L 9 3 b ] t o d e s i g n E M a p p l i c a t i o n s t h a t c a n c o p e e c i e n t l y w i t h d y n a m i c a n d u n p r e d i c t a b l e  

u c t u a t i o n s i n m e m o r y a l l o c a t i o n . A s a r e s u l t , e x t e r n a l m e m o r y a p p l i c a t i o n s a n d q u e r i e s a r e e x p e c t e d t o e c i e n t l y  

a d a p t   t o s i t u a t i o n s i n w h i c h p o r t i o n s o f t h e i r i n t e r n a l m e m o r y a r e t a k e n a w a y f r o m t h e m o r a r e a l l o c a t e d t o t h e m  

u n p r e d i c t a b l y   a n d  d y n a m i c a l l y   , i n c o u r s e o f t h e e x e c u t i o n o f t h e c o m p u t a t i o n . E x t e r n a l m e m o r y a l g o r i t h m s t h a t c a n  

a d a p t t o d y n a m i c a l l y c h a n g i n g a m o u n t s o f i n t e r n a l m e m o r y a r e s a i d t o b e   m e m o r y - a d a p t i v e   P C L 9 3 a ] . M e m o r y -  

a d a p t i v e a l g o r i t h m s s h o u l d p e r f o r m a s e c i e n t l y a s p o s s i b l e w h e n m e m o r y i s s c a r c e a n d s h o u l d t a k e a d v a n t a g e o f  

e x t r a m e m o r y w h e n i t b e c o m e s a v a i l a b l e . T h e c o m p u t a t i o n m u s t b e r e o r g a n i z e d t o a d a p t t o t h e s e q u e n c e o f m e m o r y  

a l l o c a t i o n s i n a n o n l i n e m a n n e r .  

P r i o r w o r k o n m e m o r y - a d a p t i v e E M a l g o r i t h m s h a s b e e n i n c o m p l e t e a n d e x c l u s i v e l y e m p i r i c a l i n n a t u r e . T h e  

d e v e l o p m e n t o f m e m o r y - a d a p t i v e a l g o r i t h m s s e e m s t o h a v e b e e n m o t i v a t e d b y t h e f a c t t h a t c o n v e n t i o n a l j o i n a l g o -  

r i t h m s ( i n t e n d e d t o h a v e a x e d m e m o r y a l l o c a t i o n t h r o u g h o u t t h e i r e x e c u t i o n ) a r e e x t r e m e l y s e n s i t i v e t o m e m o r y  

u c t u a t i o n s a n d a r e t i m e c o n s u m i n g . H a s h j o i n a l g o r i t h m s c a p a b l e o f a d a p t i n g e c i e n t l y t o m e m o r y u c t u a t i o n s   a s 

l o n g a s t h e s i z e o f i n t e r n a l m e m o r y r e m a i n s a t l e a s t s q u a r e r o o t o f t h e l e s i z e   w e r e d e v e l o p e d a n d e x p e r i m e n t a l l y  

a n a l y z e d b y Z e l l e r a n d G r a y Z G 9 0 ] a n d P a n g e t a l . P C L 9 3 b ] . T h e n o t i o n o f m e m o r y - a d a p t i v e a l g o r i t h m s i s m u c h  

m o r e p o w e r f u l t h a n t h e p a s s i v e a p p r o a c h o f r e l y i n g o n v i r t u a l m e m o r y p a g i n g o r s u s p e n d i n g a n a p p l i c a t i o n u n t i l t h e r e  

i s a d e q u a t e m e m o r y P C L 9 3 a ] . P a n g e t a l . P C L 9 3 a ] p r o p o s e d a s c h e m e f o r m e m o r y - a d a p t i v e e x t e r n a l m e r g e s o r t  

a n d a r e l a t e d s o r t - j o i n s c h e m e , w h i c h t h e y a n a l y z e d u s i n g a n e x p e r i m e n t a l f r a m e w o r k . Z h a n g a n d L a r s o n Z L 9 7 ]  

e x p e r i m e n t a l l y e v a l u a t e d t h e i r m e m o r y - a d a p t i v e m e r g e s o r t s t r a t e g y , b u t t h e y m a d e t h e r e s t r i c t i o n t h a t o n c e a m e r g e  

o p e r a t i o n i s i n p r o g r e s s i t s m e m o r y a l l o c a t i o n c a n n o t b e c h a n g e d u n t i l i t c o m p l e t e s .  

I n t h e n e x t s e c t i o n , w e p r e s e n t a r e a l i s t i c m o d e l f o r t h e d e s i g n a n d a n a l y s i s o f m e m o r y - a d a p t i v e a l g o r i t h m s  

a n d w e d e n e   d y n a m i c a l l y o p t i m a l   m e m o r y - a d a p t i v e a l g o r i t h m s . I n S e c t i o n 5 . 3 , w e p r e s e n t a s y m p t o t i c a l l y t i g h t  

r e s o u r c e c o n s u m p t i o n   b o u n d s f o r k e y p r o b l e m s s u c h a s p e r m u t i n g , s o r t i n g , F F T , p e r m u t a t i o n n e t w o r k s a n d m a t r i x  

m u l t i p l i c a t i o n . O u r l o w e r b o u n d s p r o v i d e a r e i n t e r p r e t a t i o n o f t h e l o w e r b o u n d s o f A V 8 8 ] a n d H K 8 1 a ] i n a d y n a m i c  

m e m o r y a l l o c a t i o n c o n t e x t . I n o r d e r t o p r o v e a l g o r i t h m s f o r t h e a b o v e p r o b l e m s t o b e d y n a m i c a l l y o p t i m a l , w e d e n e  

n a t u r a l , a p p l i c a t i o n - s p e c i c m e a s u r e s f o r t h e r e s o u r c e - c o n s u m p t i o n a t e a c h I / O s t e p . T h e m e a s u r e s d e t e r m i n e h o w  

e c i e n t l y a n a l g o r i t h m a d a p t s t o m e m o r y u c t u a t i o n s . I n t h e r e m a i n i n g s e c t i o n s , b e s i d e s t h e a b o v e p r o b l e m s , w e  

a l s o s h o w h o w t o d e s i g n a n d a n a l y z e d y n a m i c a l l y o p t i m a l a l g o r i t h m s f o r t h e a m e m o r y - a d a p t i v e v e r s i o n o f t h e b u e r  

t r e e A r g 9 4 ] a n d L U d e c o m p o s i t i o n W G W R 9 3 ] . T h e l o w e r b o u n d p r o o f t e c h n i q u e s f o r s o r t i n g a n d r e l a t e d p r o b l e m s  

o n t h e o n e h a n d , a n d t h e p r o b l e m o f m a t r i x m u l t i p l i c a t i o n o n t h e o t h e r , a r e f u n d a m e n t a l l y d i s t i n c t t e c h n i q u e s , a n d  

t h e y a r e i n v o k e d b y m o s t o t h e r e x t e r n a l m e m o r y l o w e r b o u n d s ; h e n c e w e a n t i c i p a t e t h a t t h e t e c h n i q u e s p r e s e n t e d  

h e r e w i l l a p p l y t o m a n y e x t e r n a l m e m o r y p r o b l e m s V S 9 4 , G T V V 9 3 , C G G  

9 5 , A V 9 6 , A r g 9 4 , V V 9 5 ] .  

I n S e c t i o n 5 . 4 w e d i s c u s s a n a p p r o a c h t o d e s i g n m e m o r y - a d a p t i v e a l g o r i t h m s u s i n g o p t i m a l s t a t i c m e m o r y I / O  

8 2 

Page 96: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 96/203

Page 97: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 97/203

Page 98: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 98/203

a l l  m  i n t e r n a l m e m o r y b l o c k s t o b e u s e d . T h a t r e q u i r e m e n t i s i m p l i c i t l y m e t i n c o n v e n t i o n a l   v i r t u a l m e m o r y p a g i n g  

s y s t e m s d e s i g n e d f o r n o n - a d a p t i v e e x t e r n a l m e m o r y a l g o r i t h m s . F o r e x a m p l e , i n a v i r t u a l m e m o r y s y s t e m s u p p o s e a t  

s o m e p o i n t a n a p p l i c a t i o n h a s   m  m e m o r y b l o c k s . I f , f o r s o m e r e a s o n , t h e v i r t u a l m e m o r y s y s t e m n o w d e c i d e s t o l e a v e  

t h a t a p p l i c a t i o n w i t h o n l y ( s a y )  

m  m e m o r y b l o c k s t o c r e a t e i n t e r n a l m e m o r y s p a c e f o r s o m e o t h e r h i g h e r - p r i o r i t y  

a p p l i c a t i o n , t h e v i r t u a l m e m o r y s y s t e m w o u l d i m m e d i a t e l y h a v e t o w r i t e   m   

m  = (  m  ) b l o c k s t o d i s k , t h e r e b y  

i n c u r r i n g (  m  ) I / O o p e r a t i o n s .  

5 . 2 . 1 D y n a m i c a l l y O p t i m a l M e m o r y - A d a p t i v e A l g o r i t h m s  

W e n o w d e n e w h a t i t m e a n s f o r a m e m o r y - a d a p t i v e a l g o r i t h m t o b e d y n a m i c a l l y o p t i m a l .  

D e n i t i o n 2 1   C o n s i d e r a c o m p u t a t i o n a l p r o b l e m   P  a n d a m e m o r y - a d a p t i v e a l g o r i t h m   A  t h a t s o l v e s   P  . G i v e n a n y  

N  - s i z e d i n s t a n c e   I 

o f  P  , w e s a y t h a t a l g o r i t h m   A  s o l v e s   I 

d u r i n g a l l o c a t i o n s e q u e n c e     i f  A  b e g i n s e x e c u t i o n w i t h  

t h e r s t p h a s e o f     a n d c o m p l e t e s e x e c u t i o n b y t h e e n d o f     . W e s a y t h a t   A  s o l v e s   P  d u r i n g a l l o c a t i o n s e q u e n c e    

i f  A  c a n s o l v e a n y i n s t a n c e   I 

o f  P  d u r i n g    

D e n i t i o n 2 2   C o n s i d e r a m e m o r y - a d a p t i v e a l g o r i t h m   A  f o r p r o b l e m   P  . W e s a y t h a t   A  i s  d y n a m i c a l l y o p t i m a l   f o r 

P  i f , f o r a l l m i n i m a l a l l o c a t i o n s e q u e n c e s     s u c h t h a t   A  s o l v e s   P  d u r i n g     ( b u t   A  d o e s n o t s o l v e   P  d u r i n g a p r o p e r  

p r e x o f    ) , n o o t h e r m e m o r y - a d a p t i v e a l g o r i t h m c a n s o l v e   P  m o r e t h a n a c o n s t a n t n u m b e r o f t i m e s d u r i n g    

F o r i n s t a n c e s u p p o s e t h a t a m e m o r y - a d a p t i v e s o r t i n g a l g o r i t h m   A 

c a n s o r t a l e o f  N  i t e m s d u r i n g a n a l l o c a t i o n  

s e q u e n c e     =  s 

; s 

; : : : ; s  

 ̀

. T h e n f o r   A 

t o b e d y n a m i c a l l y o p t i m a l t h e r e m u s t b e n o m o r e t h a n a c o n s t a n t n u m b e r  

c  o f n o n - o v e r l a p p i n g c o n t i g u o u s s u b s e q u e n c e s    

;  

; : : : ;  

o f    s u c h t h a t s o m e m e m o r y - a d a p t i v e s o r t i n g a l g o r i t h m  

 

c a n s o r t a n a r b i t r a r y   N  - s i z e d l e d u r i n g e a c h    

5 . 3 M e m o r y - A d a p t i v e L o w e r B o u n d s    

W e n o w p r e s e n t a s y m p t o t i c a l l y t i g h t b o u n d s f o r t h e m e m o r y a n d I / O r e s o u r c e s c o n s u m e d b y m e m o r y - a d a p t i v e  

a l g o r i t h m s f o r t h e f u n d a m e n t a l p r o b l e m s o f p e r m u t i n g , s o r t i n g , f a s t f o u r i e r t r a n s f o r m ( F F T ) , p e r m u t a t i o n n e t w o r k s ,  

b u e r t r e e o p e r a t i o n s a n d m a t r i x m u l t i p l i c a t i o n . T h e p r o b l e m o f p e r m u t i n g a l e o f   N  i t e m s i s t h e s a m e a s s o r t i n g  

a l e o f   N  i t e m s e x c e p t t h a t t h e k e y v a l u e s o f t h e   N  i t e m s i n t h e o u t p u t a r e r e q u i r e d t o f o r m a p e r m u t a t i o n o f  

f  1  ;  2  ; : : : ; N   g  . B u e r t r e e o p e r a t i o n s r e f e r t o o p e r a t i o n s o n a m e m o r y - a d a p t i v e v e r s i o n o f A r g e ' s b u e r - t r e e A r g 9 4 ]  

d a t a s t r u c t u r e , d i s c u s s e d i n S e c t i o n 5 . 1 2 .  

I n t h i s s e c t i o n , w e p r o v e o n l y t h e p e r t i n e n t l o w e r b o u n d s ; t h e u p p e r b o u n d s a r e p r o v e d i n s u b s e q u e n t s e c t i o n s a s  

i n d i c a t e d b e l o w . B a s e d u p o n t h e l o w e r b o u n d o n t h e r e s o u r c e s t h a t a r e n e e d e d t o s o l v e a p r o b l e m , w e c a n d e n e t h e  

r e s o u r c e c o n s u m p t i o n a t e a c h I / O s t e p o f a m e m o r y - a d a p t i v e a l g o r i t h m f o r t h a t p r o b l e m .  

8 5 

Page 99: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 99/203

I n t h e f o l l o w i n g t h e o r e m , w e u s e t h e n o t i o n o f d y n a m i c a l l y o p t i m a l a l g o r i t h m s t o p r e s e n t o u r r e s o u r c e c o n s u m p t i o n  

b o u n d s .  

T h e o r e m 8   S u p p o s e t h a t   A  i s a m e m o r y - a d a p t i v e a l g o r i t h m t h a t n i s h e s i t s c o m p u t a t i o n d u r i n g a n a l l o c a t i o n  

s e q u e n c e     o f s i z e s   m 

; m 

; : : : ; m  

 ̀ (  A  ) 

. L e t   T 

d e n o t e t h e t o t a l n u m b e r  

P  

 ̀ (  A  ) 

j  = 1 

2  m 

o f I / O o p e r a t i o n s i n c u r r e d b y  

1 . S u p p o s e t h a t   A  i s a d y n a m i c a l l y o p t i m a l a l g o r i t h m f o r p e r m u t i n g , t h e n  

(  T 

l g  N  ) + 

 ̀ (  A  ) 

X   

j  = 1 

2  m 

l g  m 

= (  n  l g  n  )  ( 5 . 1 )  

2 . S u p p o s e t h a t   A  i s a d y n a m i c a l l y o p t i m a l a l g o r i t h m f o r s o r t i n g o r F F T o r p e r m u t a t i o n n e t w o r k s o r e x e c u t i n g  

a s e q u e n c e o f i n s e r t / d e l e t e o p e r a t i o n s  

o n o u r m e m o r y - a d a p t i v e b u e r t r e e . T h e n w e h a v e  

 ̀ (  A  ) 

X   

j  = 1 

2  m 

l g  m 

= (  n  l g  n  )  ( 5 . 2 )  

3 . S u p p o s e t h a t   A  i s a d y n a m i c a l l y o p t i m a l a l g o r i t h m f o r ( s t a n d a r d ) m a t r i x m u l t i p l i c a t i o n o f t w o  

 ̂

N   

 ̂

N  m a t r i c e s ,  

o r L U d e c o m p o s i t i o n o f a n  

 ̂

N   

 ̂

N  m a t r i x  

. T h e n  

 ̀ (  A  ) 

X   

j  = 1 

3  =  2 

= (  n 

3  =  2 

)  ( 5 . 3 )  

T h e b u e r t r e e a l l u d e d t o i n t h e t h e o r e m i s a m e m o r y - a d a p t i v e v e r s i o n o f t h e o r i g i n a l b u e r t r e e A r g 9 4 ] . I t i s  

d e s c r i b e d i n S e c t i o n 5 . 1 2 . T h e b o u n d s i n T h e o r e m 8 l e a d t o n a t u r a l n o t i o n s o f r e s o u r c e c o n s u m p t i o n o f m e m o r y -  

a d a p t i v e a l g o r i t h m s f o r t h e v a r i o u s p r o b l e m s d i s c u s s e d .  

D e n i t i o n 2 3   C o n s i d e r t h e 2  m  I / O o p e r a t i o n s o f a m e m o r y - a d a p t i v e a l g o r i t h m   A  d u r i n g a n y a l l o c a t i o n p h a s e o f  

s i z e   m 

1 . I f   A  i s a p e r m u t i n g a l g o r i t h m , t h e   r e s o u r c e c o n s u m p t i o n   o f e a c h I / O o p e r a t i o n i s d e n e d t o b e t h e q u a n t i t y  

l g  N  + l g  m 

2 . I f   A  i s a n a l g o r i t h m f o r s o r t i n g , F F T , p e r m u t a t i o n n e t w o r k s , o r f o r e x e c u t i n g a s e q u e n c e o f o p e r a t i o n s o n a  

b u e r t r e e A r g 9 4 ] , t h e n t h e   r e s o u r c e c o n s u m p t i o n   o f e a c h I / O o p e r a t i o n i s d e n e d t o b e t h e q u a n t i t y l g   m 

I n t h e c a s e o f t h e b u e r t r e e ,   N  d e n o t e s t h e n u m b e r o f i n s e r t / d e l e t e o p e r a t i o n s .  

I n t h e c a s e o f m a t r i x m u l t i p l i c a t i o n a n d L U d e c o m p o s i t i o n ,   N  d e n o t e s  

 ̂

8 6 

Page 100: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 100/203

3 . I f   A  i s a n a l g o r i t h m f o r m a t r i x m u l t i p l i c a t i o n o r L U d e c o m p o s i t i o n , t h e n t h e   r e s o u r c e c o n s u m p t i o n   o f e a c h I / O  

o p e r a t i o n i s d e n e d t o b e t h e q u a n t i t y  

m =  2

T h e  r e s o u r c e c o n s u m p t i o n   o f a l g o r i t h m   A  i s d e n e d t o b e t h e s u m o f t h e r e s o u r c e c o n s u m p t i o n s t h e I / O o p e r a t i o n s  

o f  A 

W e c a n r e c a s t T h e o r e m 8 i n t e r m s o f r e s o u r c e c o n s u m p t i o n a s f o l l o w s :  

C o r o l l a r y 2   A m e m o r y - a d a p t i v e a l g o r i t h m   A  i s d y n a m i c a l l y o p t i m a l i f a n d o n l y i f i t s r e s o u r c e c o n s u m p t i o n i s  

(  n  l g  n  )  f o r p e r m u t i n g ,   (  n  l g  n  )  f o r s o r t i n g , F F T , p e r m u t a t i o n n e t w o r k s , a n d b u e r t r e e o p e r a t i o n s , a n d   (  n 

3  =  2 

f o r ( s t a n d a r d ) m a t r i x m u l t i p l i c a t i o n a n d L U d e c o m p o s i t i o n .  

B e l o w , w e p r o v e t h e l o w e r b o u n d s i m p l i c i t i n T h e o r e m 8 f o r p e r m u t i n g , s o r t i n g , F F T , p e r m u t a t i o n n e t w o r k s  

a n d m a t r i x m u l t i p l i c a t i o n b y r e i n t e r p r e t i n g t h e o r i g i n a l I / O l o w e r b o u n d s p r o v e d i n A V 8 8 ] a n d H K 8 1 a , S V 8 7 ] i n  

a d y n a m i c m e m o r y c o n t e x t . T h e l o w e r b o u n d f o r b u e r t r e e o p e r a t i o n s c a n b e p r o v e d b y a d a p t i n g t h e a r g u m e n t s  

o f A K L 9 3 ] r e l a t i n g c o m p a r i s o n t r e e l o w e r b o u n d s t o I / O l o w e r b o u n d s t o t h e d y n a m i c m e m o r y m o d e l .  

I n S e c t i o n 5 . 8 a n d S e c t i o n 5 . 1 3 , w e p r e s e n t d y n a m i c a l l y o p t i m a l a l g o r i t h m s f o r s o r t i n g a n d m a t r i x m u l t i p l i c a t i o n  

r e s p e c t i v e l y . W e d e m o n s t r a t e o p t i m a l i t y i n e a c h c a s e b y s h o w i n g t h a t t h e r e s o u r c e c o n s u m p t i o n m e e t s t h e b o u n d  

g i v e n a b o v e . I n S e c t i o n 5 . 1 1 , w e s h o w h o w t o a p p l y o u r m e m o r y - a d a p t i v e m e r g e s o r t a n d r e l a t e d t e c h n i q u e s t o o b t a i n  

d y n a m i c a l l y o p t i m a l a l g o r i t h m s f o r p e r m u t i n g , F F T a n d p e r m u t a t i o n n e t w o r k s . I n S e c t i o n 5 . 1 2 , w e s h o w h o w t o u s e  

o u r s o r t i n g a l g o r i t h m a s a s u b r o u t i n e t o d e v i s e a d y n a m i c a l l y o p t i m a l m e m o r y - a d a p t i v e b u e r t r e e . B y o b s e r v a t i o n s  

m a d e i n W G W R 9 3 ] , t h e d y n a m i c a l l y o p t i m a l a l g o r i t h m d e v e l o p e d f o r m a t r i x m u l t i p l i c a t i o n c a n b e m o d i e d t o  

o b t a i n a d y n a m i c a l l y o p t i m a l a l g o r i t h m f o r L U f a c t o r i z a t i o n .  

5 . 3 . 1 M e m o r y - A d a p t i v e L o w e r B o u n d s f o r P e r m u t i n g  

W e p r o v e a l o w e r b o u n d o n t h e r e s o u r c e c o n s u m p t i o n i n c u r r e d b y   a n y  m e m o r y - a d a p t i v e a l g o r i t h m t o p e r m u t e a l e  

o f  n  b l o c k s o f i t e m s .  

T h e o r e m 9   C o n s i d e r a n y m e m o r y - a d a p t i v e a l g o r i t h m   A  t h a t p e r m u t e s a l e c o n t a i n i n g   N  =  n B  i t e m s d u r i n g t h e  

a l l o c a t i o n s e q u e n c e     =  m 

; m 

; : : : ; m  

 ̀ (  A  ) 

. L e t   T 

d e n o t e t h e t o t a l n u m b e r  

P  

 ̀ (  A  ) 

i  = 1 

2  m 

o f I / O o p e r a t i o n s i n c u r r e d  

b y  A  . T h e n w e h a v e  

(  T 

l g  N  ) + 

 ̀ (  A  ) 

X   

i  = 1 

2  m 

l g  m 

= (  n  l g  n  )  ;  ( 5 . 4 )  

8 7 

Page 101: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 101/203

w h e r e , b y d e n i t i o n , t h e l e f t h a n d s i d e i s t h e r e s o u r c e c o n s u m p t i o n o f a l g o r i t h m   A  . I n t h e c a s e w h e n  

(  T 

l g  N  )   

 ̀ (  A  ) 

X   

i  = 1 

2  m 

l g  m 

, t h e b o u n d ( 5 . 4 ) i m p l i e s t h e l o w e r b o u n d  

= (  N  )  ( 5 . 5 )  

O t h e r w i s e , t h e b o u n d ( 5 . 4 ) i m p l i e s t h e l o w e r b o u n d  

 ̀ (  A  ) 

X   

i  = 1 

( 2  m 

l g  m 

) = (  n  l g  n  )  ( 5 . 6 )  

P r o o f   : W i t h o u t l o s s o f g e n e r a l i t y , w e m a k e t h e f o l l o w i n g a s s u m p t i o n s m a d e i n A V 8 8 ] : I / O o p e r a t i o n s a r e \ s i m p l e "  

a n d r e s p e c t b l o c k b o u n d a r i e s . I f a b l o c k o f   B  i t e m s i s i n p u t i n t o m e m o r y a t a n y t i m e a n d t h o s e   B  i t e m s h a d b e e n  

o u t p u t t o d i s k d u r i n g a n e a r l i e r o u t p u t o p e r a t i o n , t h e n w e a s s u m e t h a t t h e r e l a t i v e o r d e r o f t h o s e   B  i t e m s w a s  

c o m p u t e d w h e n t h e y w e r e l a s t t o g e t h e r i n i n t e r n a l m e m o r y . W e a l s o a s s u m e t h a t i f   m B    B  i t e m s r e s i d e i n m e m o r y  

a t t h e t i m e o f i n i t i a t i n g a n i n p u t o p e r a t i o n , t h e n t h e r e l a t i v e o r d e r i n g o f t h e   m B  i n - m e m o r y i t e m s i s d e t e r m i n e d o n  

c o m p l e t i o n o f t h e i n p u t o p e r a t i o n .  

C o n s i d e r a n y o n e o f t h e 2  m 

I / O o p e r a t i o n s o f t h e   i  t h a l l o c a t i o n p h a s e   m 

o f a l g o r i t h m   A  a n d s u p p o s e i t i s a n  

i n p u t I / O o p e r a t i o n . T h e r e a r e l e s s t h a n   n  + 

P  

j  = 1 

2  m 

  n  +  T 

  N  l g  N  b l o c k s o n d i s k o f w h i c h   A  m u s t r e a d  

o n e , s o t h e r e a r e n o m o r e t h a n   N  l g  N  c h o i c e s a v a i l a b l e t o   A  . L e t u s c o n s i d e r h o w t h e n u m b e r o f r e a l i z a b l e o r d e r i n g s  

c h a n g e s w h e n a g i v e n d i s k b l o c k i s r e a d i n t o i n t e r n a l m e m o r y . B y d e n i t i o n , t h e m a x i m u m n u m b e r o f i n - m e m o r y  

i t e m s a t t h e t i m e o f a n y I / O o p e r a t i o n d u r i n g t h e   i  t h p h a s e i s   M 

  B  , w h e r e   M 

=  m 

B  . T h e r e a r e a t m o s t   B  i t e m s  

i n t h e i n p u t b l o c k a n d t h e y c a n i n t e r s p e r s e a m o n g t h e   M 

i t e m s i n i n t e r n a l m e m o r y i n a t m o s t  

 

 

w a y s , s o t h e  

n u m b e r o f r e a l i z a b l e o r d e r i n g s i n c r e a s e s b y a f a c t o r o f  

 

 

. I f t h e i n p u t b l o c k h a s n e v e r b e f o r e r e s i d e d i n i n t e r n a l  

m e m o r y , t h e n u m b e r o f r e a l i z a b l e o r d e r i n g s i n c r e a s e s b y a   B  ! f a c t o r s i n c e t h e   B  i t e m s c a n b e p e r m u t e d a m o n g s t  

t h e m s e l v e s . ( T h i s e x t r a c o n t r i b u t i o n o f   B  ! c a n h a p p e n o n l y o n c e f o r e a c h o f t h e   n  o r i g i n a l b l o c k s . ) T h e i n c r e a s e i n  

t h e n u m b e r o f r e a l i z a b l e o r d e r i n g s f r o m w r i t i n g a d i s k b l o c k i s c o n s i d e r a b l y l e s s t h a n r e a d i n g i t . T h u s t h e n u m b e r o f  

d i s t i n c t o r d e r i n g s t h a t c a n b e r e a l i z e d b y a l g o r i t h m   A  i n c r e a s e s b y a f a c t o r o f a t m o s t  

(  B  ! ) 

 

  

N  ( l g  N  ) 

 

 

 

2  m 

d u r i n g t h e   i  t h a l l o c a t i o n p h a s e , w h e r e   i 

i s t h e n u m b e r o f p r e v i o u s l y u n r e a d b l o c k s r e a d d u r i n g t h e   i  t h p h a s e . T h e  

t o t a l n u m b e r o f d i s t i n c t o r d e r i n g s t h a t c a n b e r e a l i z e d b y   A  d u r i n g a l l o c a t i o n s e q u e n c e     i s n o m o r e t h a n  

(  B  ! ) 

N = B 

Y  

1    i     ̀ (  A  ) 

  

N  ( l g  N  ) 

 

 

 

2  m 

( 5 . 7 )  

8 8 

Page 102: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 102/203

S e t t i n g t h e a b o v e e x p r e s s i o n t o b e a t l e a s t   N  !  =  2 , t a k i n g l o g a r i t h m s a n d a p p l y i n g S t i r l i n g ' s f o r m u l a K n u 9 7 ] , w e h a v e  

N  l g  B  + 

 ̀ (  A  ) 

X   

i  = 1 

2  m 

  

l g  N  +  B  l g 

 

= (  N  l g  N  ) 

=  ) 

 ̀ (  A  ) 

X   

i  = 1 

2  m 

  

l g  N  +  B  l g 

 

=  

  

N  l g 

 

w h i c h c a n b e s i m p l i e d f u r t h e r t o  

 ̀ (  A  ) 

X   

i  = 1 

2  m 

( l g  N  +  B  l g  m 

) = (  N  l g  n  ) 

=  )  T 

l g  N  + 

 ̀ (  A  ) 

X   

i  = 1 

2  m 

B  l g  m 

= (  N  l g  n  ) 

D i v i d i n g t h r o u g h o u t b y   B  a n d s i m p l i f y i n g , w e e s t a b l i s h t h e l o w e r b o u n d ( 5 . 4 ) .  

W e n o w h a v e t o c o n s i d e r t w o s e p a r a t e c a s e s . F i r s t w e c o n s i d e r t h e c a s e  

(  T 

l g  N  )   

 ̀ (  A  ) 

X   

i  = 1 

2  m 

l g  m 

, s o t h a t w e  

h a v e t h e l o w e r b o u n d  

(  T 

l g  N  ) = (  n  l g  n  )  ( 5 . 8 )  

S i n c e  

(  T 

l g  N  )   

 ̀ (  A  ) 

X   

i  = 1 

2  m 

l g  m 

, w e h a v e  

l g  N   

  

l g 

 

m i n 

1    i     ̀ (  A  ) 

f  m 

 

 

( 5 . 9 )  

U s i n g t h e f a c t t h a t  

l g ( m i n  

1    i     ̀ (  A  ) 

f  m 

g  )    l g   

m o d e l  

w h e r e    

m o d e l  

i s t h e c o n s t a n t d e n e d i n t h e d y n a m i c m e m o r y m o d e l , w e h a v e  

l g ( m i n  

1    i     ̀ (  A  ) 

f  m 

g  )    c 

  2 

B y ( 5 . 9 ) , w e h a v e l g   N    c 

B  a n d s o  

1  = c 

= ( 2 

l g  N 

1  = c 

  ( 2 

1  = c 

  2 

8 9 

Page 103: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 103/203

w h i c h i m p l i e s t h a t   B < 

N  . T h e b o u n d ( 5 . 5 ) f o l l o w s f r o m ( 5 . 8 ) a f t e r s o m e s i m p l i c a t i o n .  

I n t h e c a s e w h e n  

(  T 

l g  N  )  < 

 ̀ (  A  ) 

X   

i  = 1 

l g  m 

, t h e l o w e r b o u n d ( 5 . 6 ) f o l l o w s t r i v i a l l y f r o m ( 5 . 4 ) .  

T h e l o w e r b o u n d ( 5 . 1 ) o n t h e r e s o u r c e c o n s u m p t i o n o f d y n a m i c a l l y o p t i m a l p e r m u t i n g a l g o r i t h m s i n T h e o r e m 8  

f o l l o w s f r o m ( 5 . 4 ) .  

I n t u i t i v e l y , T h e o r e m 9 s a y s t h a t t h e r e s o u r c e c o n s u m p t i o n o f p e r m u t i n g i s i d e n t i c a l t o t h e r e s o u r c e c o n s u m p t i o n o f  

s o r t i n g ( T h e o r e m 8 ) e x c e p t w h e n t h e a l l o c a t i o n s e q u e n c e i s w h a t w e c a l l a   s c a n t y a l l o c a t i o n s e q u e n c e  . A n a l l o c a t i o n  

s e q u e n c e o f    ̀ p h a s e s   m 

; m 

; : : : ; m  

 ̀

i s s a i d t o b e s c a n t y i f  

( l g  N  ) 

 ̀

X   

i  = 1 

2  m 

= (  N  l g  n  ) 

b u t 

 ̀

X   

i  = 1 

2  m 

l g  m 

 

( l g  N  ) 

 ̀

X   

i  = 1 

2  m 

I t i s u n l i k e l y f o r a n a l l o c a t i o n s e q u e n c e t o b e s c a n t y i n p r a c t i c e , s o , i n t h e m o s t l i k e l y c a s e w h e n a n a l l o c a t i o n s e q u e n c e  

i s n o t s c a n t y , t h e r e s o u r c e c o n s u m p t i o n o f p e r m u t i n g i s i d e n t i c a l t o t h a t o f s o r t i n g . I n t e r e s t i n g l y , w h e n t h e a l l o c a t i o n  

s e q u e n c e i s s c a n t y , e v e n t h e n a i v e p e r m u t i n g a l g o r i t h m i n c u r r i n g   T  = (  N  ) I / O o p e r a t i o n s i s a d y n a m i c a l l y o p t i m a l  

p e r m u t i n g a l g o r i t h m .  

5 . 3 . 2 M e m o r y - A d a p t i v e L o w e r B o u n d s f o r S o r t i n g , F F T a n d  

P e r m u t a t i o n N e t w o r k s  

P e r m u t i n g i s a s p e c i a l c a s e o f s o r t i n g , a n d h e n c e t h e l o w e r b o u n d f o r p e r m u t i n g a p p l i e s t o s o r t i n g a s w e l l . H o w e v e r ,  

i n t h e c a s e i n w h i c h t h e n a i v e (  N  ) - I / O p e r m u t i n g a l g o r i t h m i s d y n a m i c a l l y o p t i m a l f o r p e r m u t i n g , w e c a n p r o v e a  

s t r o n g e r l o w e r b o u n d f o r s o r t i n g u s i n g a n a d v e r s a r i a l a r g u m e n t a n d t h e c o m p a r i s o n m o d e l o f c o m p u t a t i o n . U s i n g t h e  

s a m e n o t a t i o n a s i n T h e o r e m 9 a n d a r g u m e n t s s i m i l a r t o t h e o n e s i n A V 8 8 ] w e c a n s h o w t h a t t h e m a x i m u m n u m b e r  

o f t o t a l o r d e r s c o n s i s t e n t w i t h c o m p a r i s o n s m a d e d u r i n g t h e a l l o c a t i o n s e q u e n c e   m 

; m 

; : : : ; m  

 ̀ (  A  ) 

i s n o m o r e t h a n  

(  B  ! ) 

N = B 

Y  

1    i     ̀ (  A  ) 

 

 2  m 

( 5 . 1 0 )  

U s i n g a r g u m e n t s s i m i l a r t o t h e o n e s i n A V 8 8 ] w e c a n s h o w t h a t t h e m a x i m u m n u m b e r o f r e a l i z a b l e o r d e r i n g s f o r  

a m e m o r y - a d a p t i v e p e r m u t a t i o n n e t w o r k a l g o r i t h m d u r i n g    ̀ (  A  ) a l l o c a t i o n p h a s e s i s n o m o r e t h a n ( 5 . 1 0 ) a s w e l l . I n  

9 0 

Page 104: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 104/203

c o n t r a s t t o s o r t i n g , t h e p r o o f o f t h e a b o v e b o u n d f o r p e r m u t a t i o n n e t w o r k s d o e s n o t i n v o l v e a n y c o m p a r i s o n m o d e l  

b a s e d a r g u m e n t s a r g u m e n t s a n d f o l l o w s d i r e c t l y f r o m a c o u n t i n g a r g u m e n t .  

A s i n A V 8 8 ] , w e c a n e x p l o i t t h e f a c t t h a t a n y p e r m u t a t i o n n e t w o r k c a n b e c o n s t r u c t e d b y s t a c k i n g t o g e t h e r a t  

m o s t t h r e e a p p r o p r i a t e F F T n e t w o r k s t o c o n c l u d e t h a t t h e F F T a n d p e r m u t a t i o n n e t w o r k p r o b l e m s a r e e s s e n t i a l l y  

e q u i v a l e n t . T h u s t h e p r o b l e m o f F F T c o m p u t a t i o n h a s t h e s a m e l o w e r b o u n d a s t h a t f o r p e r m u t a t i o n n e t w o r k s .  

T h e t h e o r e m b e l o w f o l l o w s b y s e t t i n g t h e e x p r e s s i o n ( 5 . 1 0 ) t o b e a t l e a s t   N  ! , t a k i n g l o g a r i t h m s , a p p l y i n g S t i r l i n g ' s  

i n e q u a l i t y K n u 9 7 ] a n d t h e n s i m p l i f y i n g .  

T h e o r e m 1 0   C o n s i d e r a n y m e m o r y - a d a p t i v e a l g o r i t h m   A  f o r s o r t i n g a l e c o n t a i n i n g   N  =  n B  i t e m s o r f o r  

c o m p u t i n g t h e   N  - i n p u t F F T d i g r a p h o r a n   N  - i n p u t p e r m u t a t i o n n e t w o r k d u r i n g t h e a l l o c a t i o n s e q u e n c e     = 

; m 

; : : : ; m  

 ̀ (  A  ) 

. T h e n w e h a v e  

 ̀

X   

i  = 1 

2  m 

l g  m 

= (  n  l g  n  )  ;  ( 5 . 1 1 )  

w h e r e , b y d e n i t i o n , t h e l e f t h a n d s i d e i s t h e r e s o u r c e c o n s u m p t i o n o f a l g o r i t h m   A 

T h e l o w e r b o u n d ( 5 . 2 ) o f T h e o r e m 8 f o l l o w s f r o m T h e o r e m 1 0 .  

5 . 3 . 3 M e m o r y - A d a p t i v e L o w e r B o u n d s f o r M a t r i x M u l t i p l i -  

c a t i o n  

W e n o w d e r i v e l o w e r b o u n d s o n t h e r e s o u r c e s c o n s u m e d b y a n y m e m o r y - a d a p t i v e a l g o r i t h m t o m u l t i p l y t w o  

 ̂

N   

 ̂

m a t r i c e s .  

C o n s i d e r t h e p r o b l e m o f m u l t i p l y i n g t w o  

 ̂

N   

 ̂

N  m a t r i c e s , c o n s i s t i n g o f   N  = 

 ̂

e l e m e n t s i n t o t a l . H o n g a n d  

K u n g H K 8 1 a ] p r o v e d f u n d a m e n t a l I / O b o u n d s f o r t h i s p r o b l e m u s i n g   g r a p h p e b b l i n g   a r g u m e n t s . B a s e d u p o n t h e i r  

a r g u m e n t s , S a v a g e a n d V i t t e r S V 8 7 ] s h o w e d t h a t i f t h e a m o u n t o f m a i n m e m o r y a v a i l a b l e t o a n e x t e r n a l m e m o r y  

a l g o r i t h m i s x e d t o b e   M  t h e n a n y ( s t a n d a r d ) m a t r i x m u l t i p l i c a t i o n a l g o r i t h m t a k e s a t l e a s t (  N 

3  =  2 

= B 

M  ) = 

(  n 

3  =  2 

m  ) I / O o p e r a t i o n s , w h e r e   n  =  N = B  a n d  m  =  M = B  . T h i s b o u n d i s e a s i l y r e a l i z e d b y a s i m p l e e x t e r n a l  

m e m o r y a l g o r i t h m V S 9 4 ] .  

T h e p r o b l e m o f c o m p u t i n g t h e p r o d u c t   C  =  A    B  o f t w o  

 ̂

N   

 ̂

N  m a t r i c e s c a n b e v i e w e d a s p e b b l i n g t h r o u g h a  

d i r e c t e d a c y c l i c g r a p h ( D A G ) c o n t a i n i n g (  

 ̂

) c o n s t a n t d e g r e e n o d e s . F o r o u r p u r p o s e s , i t s u c e s t o s a y t h a t i n  

o r d e r t o c o m p u t e   C  i t i s n e c e s s a r y t o p e b b l e t h r o u g h a l l (  

 ̂

) n o d e s o f t h e m a t r i x m u l t i p l i c a t i o n D A G . W e r e f e r  

t h e r e a d e r t o S V 8 7 ] f o r a s t u d y o f i s s u e s r e l a t e d t o p e b b l i n g - b a s e d I / O c o m p l e x i t y a r g u m e n t s .  

9 1 

Page 105: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 105/203

I n o r d e r t o a d a p t t h e l o w e r b o u n d a r g u m e n t f o r m a t r i x m u l t i p l i c a t i o n t o o u r m e m o r y - a d a p t i v e s e t t i n g w e c o n s i d e r  

t h e m a x i m u m n u m b e r o f n o d e s ( o f t h e m a t r i x m u l t i p l i c a t i o n D A G ) t h a t m a y b e p e b b l e d i n a s i n g l e a l l o c a t i o n p h a s e  

o f s i z e   s  ; t h a t i s , t h e m a x i m u m n u m b e r o f D A G n o d e s p e b b l e d u s i n g a t m o s t   s  i n t e r n a l m e m o r y b l o c k s a n d n o m o r e  

t h a n 2  s  I / O o p e r a t i o n s . W e s t a t e t h e f o l l o w i n g l e m m a w h o s e p r o o f f o l l o w s f r o m t h e a r g u m e n t s o f S V 8 7 ] w h i c h a r e  

b a s e d u p o n i d e a s f r o m H K 8 1 a ] .  

L e m m a 2 2   L e t t h e p e b b l i n g o p e r a t i o n s o f m a t r i x m u l t i p l i c a t i o n b e a s d e n e d i n S V 8 7 ] . T h e m a x i m u m n u m b e r  

o f m a t r i x m u l t i p l i c a t i o n D A G n o d e s t h a t c a n b e p e b b l e d d u r i n g a n a l l o c a t i o n p h a s e o f s i z e   m  i s  O  (  M 

3  =  2 

)  , w h e r e  

M  =  m B   

 ̂

T h e l o w e r b o u n d o f T h e o r e m 8 f o r m a t r i x m u l t i p l i c a t i o n f o l l o w s e a s i l y f r o m L e m m a 2 2 . T h e s a m e l o w e r b o u n d  

a p p l i e s t o a n y s t a n d a r d L U f a c t o r i z a t i o n a l g o r i t h m a s w e l l : T h i s i s b e c a u s e t h e D A G c o r r e s p o n d i n g t o a s t a n d a r d  

L U f a c t o r i z a t i o n a l g o r i t h m o n a n  

 ̂

N   

 ̂

N  m a t r i x a l s o c o n t a i n s (  

 ̂

) n o d e s t h a t n e e d t o b e p e b b l e d a n d a v e r s i o n o f  

L e m m a 2 2 i s a p p l i c a b l e t o a n L U f a c t o r i z a t i o n D A G .  

5 . 4 D e s i g n i n g M e m o r y - A d a p t i v e A l g o r i t h m s    

W e n o w c o n s i d e r h o w m e m o r y - a d a p t i v e a l g o r i t h m s c a n m a k e \ o p t i m u m u t i l i z a t i o n " o f t h e m e m o r y a n d I / O r e s o u r c e s  

c o m p r i s i n g a n   m  - s i z e d a l l o c a t i o n p h a s e . I n o r d e r t o g e t a n i d e a o f h o w t h i s m a y b e a c h i e v e d , w e e x a m i n e e x t e r n a l  

m e m o r y a l g o r i t h m s t h a t a r e o p t i m a l f o r a x e d i n t e r n a l m e m o r y a l l o c a t i o n o f   m  b l o c k s .  

5 . 4 . 1 O p t i m a l n o n - a d a p t i v e e x t e r n a l m e m o r y a l g o r i t h m s  

C o n s i d e r a n o p t i m a l e x t e r n a l m e r g e s o r t a l g o r i t h m . G i v e n a x e d n u m b e r   m  o f i n t e r n a l m e m o r y b l o c k s a n o p t i m a l  

m e r g e s o r t a l g o r i t h m c o n s i s t s o f a r u n - f o r m a t i o n s t a g e f o l l o w e d b y a s e q u e n c e o f   u  (  m  ) - w a y e x t e r n a l m e r g e o p e r a t i o n s ,  

w h e r e   u  (  m  ) = (  m 

) f o r 0   < c    1 . D u r i n g a t y p i c a l s e q u e n c e o f (  m  ) I / O o p e r a t i o n s , t h i s a l g o r i t h m ' s e x e c u t i o n  

c o n s i s t s o f g e n e r a t i n g (  m  ) b l o c k s o u t p u t b y a n   u  (  m  ) - w a y e x t e r n a l m e r g e . C o n s i d e r t h e d e s i g n o f a n e x t e r n a l  

m e m o r y a l g o r i t h m t o c a r r y o u t t h e m a t r i x m u l t i p l i c a t i o n   A B  =  C  . G i v e n a x e d n u m b e r   m  o f i n t e r n a l m e m o r y  

b l o c k s , a n o p t i m a l m a t r i x m u l t i p l i c a t i o n a l g o r i t h m c o n s i s t s o f a s e q u e n c e o f \  v  (  m  ) - o p e r a t i o n s " e a c h o f w h i c h c o n s i s t s  

o f c a r r y i n g o u t a n i n t e r n a l m e m o r y m u l t i p l i c a t i o n o f s u b m a t r i c e s o f   A  a n d  B  e a c h c o n s i s t i n g o f   v  (  m  ) b l o c k s , w h e r e  

v  (  m  ) = (  m  ) . C l e a r l y e a c h s u c h o p e r a t i o n c o n s i s t s o f (  m  ) I / O o p e r a t i o n s .  

5 . 4 . 2 M i m i c k i n g O p t i m a l S t a t i c M e m o r y A l g o r i t h m s  

T h e c o m p u t a t i o n c a r r i e d o u t b y a n o p t i m a l e x t e r n a l m e m o r y a l g o r i t h m o v e r a s e q u e n c e o f (  m  ) I / O o p e r a t i o n s i s  

d e t e r m i n e d b y t h e n u m b e r   m  o f i n t e r n a l m e m o r y b l o c k s a l l o c a t e d t o t h e a l g o r i t h m . O p t i m a l i t y r e s u l t s f r o m t h e  

9 2 

Page 106: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 106/203

f a c t t h a t t h e a l g o r i t h m a c h i e v e s \ o p t i m a l r e s o u r c e u t i l i z a t i o n " d u r i n g a t y p i c a l a l l o c a t i o n p h a s e o f s i z e   m  . B y t h e  

a b o v e r e a s o n i n g , f o r a m e m o r y - a d a p t i v e a l g o r i t h m t o b e e c i e n t , t h e c o m p u t a t i o n i t c a r r i e s o u t o v e r e a c h a l l o c a t i o n  

p h a s e s h o u l d b e d e t e r m i n e d b y t h e s i z e o f t h a t p h a s e . I n o r d e r t o a t t a i n d y n a m i c o p t i m a l i t y , a m e m o r y - a d a p t i v e  

a l g o r i t h m ' s \ p r o g r e s s " d u r i n g a n a l l o c a t i o n p h a s e o f s i z e   m  s h o u l d m i m i c b e c o m p a r a b l e t o t h a t o f i t s o p t i m a l , x e d -  

m e m o r y a n a l o g o v e r (  m  ) I / O o p e r a t i o n s . I d e a l l y , d u r i n g e a c h a l l o c a t i o n p h a s e o f s i z e   m  , w h e r e 1     m    m 

m a x 

a m e m o r y - a d a p t i v e m e r g e s o r t a l g o r i t h m s h o u l d w r i t e t o d i s k (  m  ) b l o c k s r e s u l t i n g f r o m   u  (  m  ) - w a y m e r g i n g a n d a  

m e m o r y - a d a p t i v e m a t r i x m u l t i p l i c a t i o n a l g o r i t h m s h o u l d e x e c u t e a   v  (  m  ) - o p e r a t i o n .  

5 . 4 . 3 A d a p t i v e O r g a n i z a t i o n o f C o m p u t a t i o n  

T h e c h a l l e n g e i n d e s i g n i n g d y n a m i c a l l y o p t i m a l m e m o r y - a d a p t i v e a l g o r i t h m s i s t o o r g a n i z e , i n a n   e c i e n t   a n d  o n l i n e  

m a n n e r , t h e e x t e r n a l m e m o r y c o m p u t a t i o n s o a s t o a t t a i n o p t i m a l r e s o u r c e u t i l i z a t i o n d u r i n g e v e r y a l l o c a t i o n p h a s e  

a s d e s c r i b e d a b o v e . T h e i s s u e o f e c i e n c y i n t h i s o n l i n e o r g a n i z a t i o n o f e x t e r n a l m e m o r y c o m p u t a t i o n a r i s e s i n t w o  

c o n t e x t s .  

F i r s t l y , i n o r d e r t o c o p e w i t h a r b i t r a r y v a r i a t i o n i n a l l o c a t i o n s , t h e c o m p u t a t i o n n e e d s t o b e b r o k e n d o w n i n  

a n o n l i n e m a n n e r i n t o a s e q u e n c e o f \ s m a l l e r g r a n u l a r i t y " c o m p u t a t i o n s s u c h t h a t e x e c u t i n g t h a t s e q u e n c e o f  

c o m p u t a t i o n s i s a r e s o u r c e - e c i e n t r e n d e r i n g o f t h e o r i g i n a l c o m p u t a t i o n . F o r i n s t a n c e , a n   s  - w a y m e r g e o f r u n s  

o f t h e s e t   U  =  f  r 

; r 

; : : : ; r  

s    1 

g  c a n b e r e o r g a n i z e d a s f o l l o w s : F i r s t w e c a n c o m p u t e t h e   h  r u n s o f t h e s e t  

=  f  r 

; r 

; : : : ; r  

h    1 

g  s u c h t h a t r u n   r 

, w h e r e 0     i    h    1 , i s a m e r g e o f   s 

r u n s o f   U  a n d 

P  

h    1 

i  = 0 

=  s 

F o r e a c h   i ; j  s u c h t h a t   i  6=  j  a n d 0     i ; j    h    1 , t h e   s 

r u n s m e r g e d t o o b t a i n   r 

a r e a l l d i s t i n c t f r o m t h e   s 

r u n s  

m e r g e d t o o b t a i n   r 

. T h e n w e c a n m e r g e t o g e t h e r t h e r u n s o f t h e s e t   U 

t o c o m p l e t e t h e o r i g i n a l m e r g e o f r u n s o f t h e  

s e t  U  . E a c h o f   h  m e r g e o p e r a t i o n s p r o d u c i n g   r 

; r 

; : : : ; r  

h    1 

m a y o r m a y n o t s u b s e q u e n t l y n e e d t o b e b r o k e n d o w n  

f u r t h e r i n t o s m a l l e r m e r g e o p e r a t i o n s a n d s o o n , d e p e n d i n g u p o n t h e a l l o c a t i o n s e q u e n c e . T h e d y n a m i c o p t i m a l i t y ( o r  

n o n - o p t i m a l i t y ) o f a m e m o r y - a d a p t i v e m e r g e s o r t d e p e n d s u p o n h o w i t d e c i d e s   h  ,  s 

a n d t h e   s 

r u n s c h o s e n t o p r o d u c e  

r u n  r 

. S i m i l a r l y a c o m p u t a t i o n c o n s i s t i n g o f m u l t i p l y i n g m a t r i c e s , e a c h c o n s i s t i n g o f   s  b l o c k s , c a n b e a c h i e v e d b y  

c a r r y i n g o u t a s e r i e s o f a p p r o p r i a t e l y c h o s e n m a t r i x m u l t i p l i c a t i o n o p e r a t i o n s e a c h m u l t i p l y i n g m a t r i c e s c o n s i s t i n g o f  

< s  b l o c k s . E a c h   s 

- s i z e d m u l t i p l i c a t i o n o p e r a t i o n m a y o r m a y n o t n e e d t o b e b r o k e n d o w n i n t o s m a l l e r o p e r a t i o n s ,  

d e p e n d i n g u p o n t h e a l l o c a t i o n s e q u e n c e . T h e d y n a m i c o p t i m a l i t y o f a m e m o r y - a d a p t i v e m u l t i p l i c a t i o n d e p e n d s u p o n  

h o w i t d e t e r m i n e s t h e v a l u e o f   s 

T h e s e c o n d c o n t e x t i n w h i c h e c i e n c y i s i m p o r t a n t i s w h i l e b r e a k i n g d o w n a c o m p u t a t i o n i n t o s u b c o m p u t a t i o n :  

S i n c e s u c h a c t i v i t y m a y a l s o i n v o l v e e x t e r n a l m e m o r y o p e r a t i o n s , t h e d a t a s t r u c t u r e s a n d t e c h n i q u e s c h o s e n t o  

r e o r g a n i z e e x t e r n a l m e m o r y c o m p u t a t i o n i n a n o n l i n e m a n n e r m u s t t h e m s e l v e s b e e c i e n t .  

9 3 

Page 107: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 107/203

5 . 4 . 4 A l l o c a t i o n L e v e l s  

A s o b s e r v e d i n S e c t i o n 5 . 4 . 2 , a m e m o r y - a d a p t i v e a l g o r i t h m ' s c o m p u t a t i o n i n a n a l l o c a t i o n p h a s e s h o u l d b e d e t e r m i n e d  

b y t h e s i z e o f t h e p h a s e . W h i l e m i m i c k i n g a n o p t i m a l e x t e r n a l m e m o r y a l g o r i t h m , i t i s c o n v e n i e n t t o c l u m p t o g e t h e r  

r a n g e s o f a l l o c a t i o n p h a s e s i z e s i n t o s i n g l e a l l o c a t i o n l e v e l s a n d t h e r e b y p a r t i t i o n t h e w h o l e r a n g e   f   

m o d e l  

; : : : ;  m 

m a x 

o f a l l o c a t i o n p h a s e s i z e s i n t o s e v e r a l a l l o c a t i o n l e v e l s . C o n s i d e r u s i n g t h e f o l l o w i n g m i m i c k i n g s t r a t e g y i n a n a t t e m p t  

t o d e v i s e a d y n a m i c a l l y o p t i m a l m e r g e s o r t a l g o r i t h m : D u r i n g a n a l l o c a t i o n p h a s e o f s i z e   m  , w e a l w a y s t r y t o c o m p u t e  

(  m  ) b l o c k s c o r r e s p o n d i n g t o t h e o u t p u t o f a   u  (  m  ) - w a y m e r g e , w h e r e   u  (  m  ) = 2 

b  l g (  m    1 )  c 

  m =  2 . I n t h i s c a s e , a n y  

a l l o c a t i o n p h a s e o f s i z e   s  s u c h t h a t   s  2 f  2 

 ̀

+ 1  ;  2 

 ̀

+ 2  ; : : : ;   2 

 ̀ + 1 

g  i s s a i d t o b e a t a l l o c a t i o n l e v e l    ̀ w i t h r e s p e c t t o  

o u r s t r a t e g y s i n c e w e a l w a y s t r y t o o u t p u t (  s  ) b l o c k s o f a 2  

 ̀

- w a y m e r g e d u r i n g t h a t a l l o c a t i o n p h a s e . O n t h e o t h e r  

h a n d , s u p p o s e w e s e t   u  (  m  ) = 2 

b  l g l g (  m    1 )  c 

 

m  , t h e n a n y p h a s e o f s i z e   s  2 f  2 

 ̀

+ 1  ;  2 

 ̀

+ 2  ; : : : ;  2 

 ̀ + 1 

g  c a n b e  

s a i d a t a l l o c a t i o n l e v e l    ̀ w i t h r e s p e c t t o t h e m o d i e d s t r a t e g y . I n t h i s c h a p t e r , w e f o r m a l l y d e n e a l l o c a t i o n l e v e l s  

f o r e a c h m e m o r y - a d a p t i v e a l g o r i t h m w e p r e s e n t .  

5 . 5 A F r a m e w o r k f o r M e m o r y - A d a p t i v e M e r g e -    

s o r t    

I n t h i s s e c t i o n , w e d i s c u s s a s i m p l e f r a m e w o r k t h a t c a n b e u s e d t o c o n s t r u c t m e m o r y - a d a p t i v e m e r g e s o r t a l g o r i t h m s .  

T h e m e m o r y - a d a p t i v e m e r g e s o r t b a s e d u p o n t e c h n i q u e s p r o p o s e d b y P a n g e t a l . P C L 9 3 a ] c a n b e c a s t i n t e r m s o f o u r  

f r a m e w o r k . H o w e v e r , t h e t e c h n i q u e s o f P C L 9 3 a ] s u e r f r o m f u n d a m e n t a l d r a w b a c k s t h a t m a k e t h e r e s u l t i n g s o r t i n g  

a l g o r i t h m n o n o p t i m a l a s w e s h o w i n S e c t i o n 5 . 6 a n d 5 . 7 . I n S e c t i o n 5 . 8 , w e d e s i g n a n e w m e m o r y - a d a p t i v e m e r g i n g  

a l g o r i t h m t h a t y i e l d s a d y n a m i c a l l y o p t i m a l s o r t i n g a l g o r i t h m w h e n a p p l i e d u s i n g o u r f r a m e w o r k .  

E x t e r n a l m e r g e s o r t s K n u 9 8 , A V 8 8 ] c o n s i s t o f a   r u n f o r m a t i o n s t a g e   i n w h i c h s o r t e d r u n s a r e f o r m e d ( b y r e a d i n g i n  

m e m o r y l o a d s o f i t e m s , s o r t i n g t h e m a n d w r i t i n g t h e m o u t t o d i s k ) f o l l o w e d b y a   m e r g i n g s t a g e   i n w h i c h t h e m e r g e s o r t  

a l g o r i t h m k e e p s m e r g i n g ( a s l a r g e a s p o s s i b l e ) a n u m b e r o f r u n s t o g e t h e r u n t i l t h e r e i s o n l y o n e r u n r e m a i n i n g . T h u s  

w e n e e d t o d e v i s e m e m o r y - a d a p t i v e t e c h n i q u e s f o r r u n f o r m a t i o n a n d m e r g i n g .  

5 . 5 . 1 M e m o r y - A d a p t i v e R u n F o r m a t i o n  

T h e s t r a i g h t f o r w a r d m e m o r y - a d a p t i v e r u n f o r m a t i o n t e c h n i q u e w e p r o p o s e i s a s f o l l o w s : I n a n a l l o c a t i o n p h a s e o f  

s i z e   m  , w e r e a d i n   m  b l o c k s o f i t e m s f r o m t h e i n p u t l e , s o r t t h e m u s i n g a n o p t i m a l i n - p l a c e s o r t i n g t e c h n i q u e , a n d  

w r i t e t h e m o u t u s i n g   m  w r i t e I / O o p e r a t i o n s .  

T h e n u m b e r a n d t h e l e n g t h s o f t h e r u n s f o r m e d d u r i n g r u n f o r m a t i o n  

d e p e n d s u p o n t h e a l l o c a t i o n s e q u e n c e .  

I n o r d e r t o s i m p l i f y d i s c u s s i o n s w e n e g l e c t d e t a i l s r e g a r d i n g s m a l l a m o u n t s o f a d d i t i o n a l m e m o r y  

s p a c e r e q u i r e d b y i n - m e m o r y s o r t i n g .  

9 4 

Page 108: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 108/203

L e m m a 2 3   F o r a l e o f   n  b l o c k s , e a c h r u n t h a t i s f o r m e d u s i n g t h e a b o v e m e m o r y - a d a p t i v e r u n f o r m a t i o n s t r a t e g y ,  

w i t h t h e p o s s i b l e e x c e p t i o n o f o n e r u n , i s a t l e a s t    

m o d e l  

b l o c k s l o n g a n d t h e n u m b e r o f r u n s f o r m e d i s a t m o s t  

d  n =  

m o d e l  

e  . T h e r e s o u r c e c o n s u m p t i o n o f t h e a b o v e r u n f o r m a t i o n s t r a t e g y i s n o m o r e t h a n   2  n  l g  m 

m a x 

, w h e r e m  

m a x 

i s d e n e d i n D e n i t i o n 1 9 .  

5 . 5 . 2 M e m o r y - a d a p t i v e m e r g i n g s t a g e  

T h e m a i n d i c u l t y o f m e m o r y - a d a p t i v e m e r g e s o r t i n g l i e s i n m e r g i n g . I f a n e x t e r n a l m e r g e s o r t a l g o r i t h m h a s a s t a t i c  

n u m b e r   m  o f i n t e r n a l m e m o r y b l o c k s t o u s e t h r o u g h o u t t h e a l g o r i t h m , a n I / O - o p t i m a l s t r a t e g y A V 8 8 ] i s t o m e r g e  

t o g e t h e r t h e   m    1 s h o r t e s t r u n s a n d t o r e p e a t t h e p r o c e s s u n t i l a s i n g l e s o r t e d r u n r e m a i n s .  

T h u s i f t h e i n p u t l e i s  

n  b l o c k s l o n g a n d t h e r e a r e   n 

s o r t e d r u n s a f t e r r u n f o r m a t i o n ,   d  l o g 

m    1 

e  =  d  ( l g  n 

)  =  l g (  m    1 )  e  m e r g e p a s s e s   a r e 

r e q u i r e d t o c o m p l e t e t h e s o r t .  

T h e m e r g i n g s t a g e w e p r o p o s e i s a m o d i c a t i o n o f t h e a b o v e a p p r o a c h . L e t   Q  b e t h e q u e u e o f ( p o i n t e r s t o ) r u n s  

t h a t n e e d t o b e m e r g e d d u r i n g t h e m e r g i n g s t a g e . W e i m p l e m e n t   Q  a s a b l o c k e d l i s t o f p o i n t e r s . W h e n e v e r a r u n i s  

f o r m e d d u r i n g t h e r u n - f o r m a t i o n s t a g e a p o i n t e r t o t h a t r u n i s i n s e r t e d i n t o   Q  . A t t h e e n d o f r u n f o r m a t i o n   Q  c a n 

h a v e u p t o   d  n =  

m o d e l  

e  p o i n t e r s . L e t   M  b e a n y m e m o r y - a d a p t i v e m e r g e s u b r o u t i n e t h a t c a n m e r g e u p t o    

r u n s ,  

w h e r e    

  2 , t o p r o d u c e a s i n g l e o u t p u t r u n . I n t h e m e r g i n g s t a g e , t h e m e m o r y - a d a p t i v e m e r g e s u b r o u t i n e   M  i s 

u s e d r e p e a t e d l y i n t h e f o l l o w i n g m a n n e r u n t i l o n l y a s i n g l e r u n r e m a i n s i n   Q  : 

1 . R e m o v e t h e l e a d i n g m i n  f   

;  j Q j g   ( p o i n t e r s t o ) r u n s f r o m   Q 

2 . M e r g e t h e s e r u n s t o g e t h e r u s i n g   M  i n a m e m o r y - a d a p t i v e m a n n e r .  

3 . A p p e n d ( t h e p o i n t e r t o ) t h e o u t p u t r u n t o t h e e n d o f  Q 

W e h a v e t h e f o l l o w i n g e s t i m a t e o f r e s o u r c e c o n s u m p t i o n o v e r t h e m e r g i n g s t a g e a s a f u n c t i o n o f t h e r e s o u r c e  

c o n s u m p t i o n o f   M 

L e m m a 2 4   S u p p o s e t h a t t h e r e s o u r c e c o n s u m p t i o n o f m e r g e a l g o r i t h m   M  w h e n m e r g i n g    

r u n s t o t a l l y c o n t a i n i n g  

b l o c k s i s b o u n d e d b y   n 

  g  (   

)  . S u p p o s e t h a t t h e s i z e o f t h e l e t o s o r t i s   n  b l o c k s a n d t h a t t h e t o t a l n u m b e r  

o f r u n s i n   Q  i m m e d i a t e l y a f t e r t h e r u n f o r m a t i o n s t a g e i s   n 

b  n =  

m o d e l  

c  . T h e n t h e r e s o u r c e c o n s u m p t i o n o f t h e  

m e r g i n g s t a g e i s n o m o r e t h a n  

 

l g  n 

l g   

 

+ 1 

 

g  (   

I f d o u b l e b u e r i n g i s u s e d t o o v e r l a p I / O a n d C P U t i m e , t h e n a p p r o x i m a t e l y   m =  2 r u n s a r e m e r g e d  

t o g e t h e r .  

9 5 

Page 109: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 109/203

P r o o f  : E a c h t i m e a n i t e m   x  i s i n o n e o f t h e r u n s b e i n g m e r g e d b y   M  w e s a y t h a t   M  t o u c h e s i t e m   x  . B y a s s u m p t i o n ,  

e a c h i t e m t o u c h e d b y   M  i s c h a r g e d a r e s o u r c e c o n s u m p t i o n o f   g  (   

)  = B  f o r t h a t e x e c u t i o n o f   M  . W e p r o v e b e l o w  

t h a t t h e m a x i m u m n u m b e r o f t i m e s a n y e l e m e n t c a n b e t o u c h e d i s   d  l g  n 

=  l g   

e  + 1 , t h u s p r o v i n g t h e l e m m a .  

I n s t e a d o f u s i n g t h e l i s t   Q  o f r u n s t h r o u g h o u t t h e m e r g i n g s t a g e , c o n s i d e r t h e f o l l o w i n g m o d i e d m e r g i n g s t a g e  

u s i n g s e v e r a l d i e r e n t q u e u e s f o r t h e s a k e o f t h i s a n a l y s i s . L e t   Q 

b e t h e l i s t o f   n 

r u n s i m m e d i a t e l y a f t e r t h e r u n  

f o r m a t i o n s t a g e . A t   m e r g e l e v e l   i  , w e m e r g e r u n s f r o m q u e u e   Q 

a n d i n s e r t e a c h r u n o u t p u t b y s u c h a m e r g e i n t o l i s t  

i  + 1 

. A t t h e b e g i n n i n g o f m e r g e - l e v e l   i  , i f t h e n u m b e r o f r u n s i n   Q 

i s n o g r e a t e r t h a n    

, w e m e r g e a l l r u n s i n   Q 

t o t e r m i n a t e t h e m e r g i n g s t a g e . I f t h i s i s n o t t h e c a s e , t h e n w h i l e t h e n u m b e r o f r u n s i n   Q 

i s a t l e a s t    

, w e r e p e a t  

t h e f o l l o w i n g o p e r a t i o n : W e r e m o v e     r u n s f r o m   Q 

, m e r g e t h e m t o g e t h e r t o f o r m a n e w r u n   r  , a n d i n s e r t r u n   r  i n t o  

l i s t   Q 

i  + 1 

. W h e n t h e n u m b e r o f r u n s i n   Q 

b e c o m e s l e s s t h a n    

, w e a p p e n d   Q 

t o  Q 

i  + 1 

T h e m a x i m u m n u m b e r o f t i m e s a n y i t e m c a n b e t o u c h e d d u r i n g o u r o r i g i n a l m e r g i n g s t a g e i s n o m o r e t h a n t h e  

n u m b e r o f m e r g e l e v e l s i n t h e m e r g i n g s t a g e d e s c r i b e d a b o v e . B e l o w w e b o u n d t h e t o t a l n u m b e r o f m e r g e l e v e l s ,  

w h i c h w e d e n o t e b y #   P a s s e s  . C o n s i d e r a n    

- a r y r e p r e s e n t a t i o n o f t h e n u m b e r   j Q 

j  o f r u n s i n   j Q 

j   j u s t p r i o r t o  

b e g i n n i n g t h e   i  t h m e r g e - l e v e l , f o r 0     i    #  P a s s e s     1 . T h e n u m b e r o f d i g i t s i n t h e    

- a r y r e p r e s e n t a t i o n o f   j Q 

j  i s 

a l w a y s o n e l e s s t h a n t h e n u m b e r o f d i g i t s i n t h e    

- a r y r e p r e s e n t a t i o n o f   j Q 

i    1 

j  , f o r a l l e x c e p t p o s s i b l y o n e v a l u e o f  

i  i n t h e r a n g e 1     i    #  P a s s e s     1 . I f t h e n u m b e r o f   

- a r y d i g i t s i n t h e r e p r e s e n t a t i o n o f   j Q 

j  i s t h e s a m e a s t h a t  

o f  j Q 

i    1 

j  , t h e n t h e m o s t s i g n i c a n t d i g i t i n t h e    

- a r y r e p r e s e n t a t i o n o f   j Q 

j  i s 1 a n d a l l o t h e r d i g i t s a r e s t r i c t l y l e s s  

t h a n    

  1 . I t f o l l o w s t h a t #   P a s s e s    

 

l g  n 

l g   

 

+ 1 . T h i s p r o v e s t h e l e m m a .  

5 . 5 . 3 R e s o u r c e c o n s u m p t i o n o f m e m o r y - a d a p t i v e e x t e r n a l  

m e r g e s o r t  

W e w i l l n o w d i s c u s s t h e r e q u i r e m e n t s t h a t t h e m e m o r y - a d a p t i v e m e r g i n g s u b r o u t i n e   M  n e e d s t o s a t i s f y i n o r d e r f o r  

o u r a p p r o a c h t o r e s u l t i n a d y n a m i c a l l y o p t i m a l m e m o r y - a d a p t i v e s o r t i n g a l g o r i t h m .  

L e m m a 2 5   T h e r e s o u r c e c o n s u m p t i o n o f t h e s o r t i n g a l g o r i t h m b a s e d u p o n o u r m e m o r y - a d a p t i v e m e r g e s o r t ( r u n  

f o r m a t i o n a n d m e r g i n g s t a g e ) f r a m e w o r k i s a t m o s t  

2  n  l g  m 

m a x 

+  n 

 

l g  n 

l g   

 

+ 1 

 

g  (   

w h e r e   n  i s t h e n u m b e r o f b l o c k s i n t h e i n p u t l e ,   M  a n d   

a r e a s d e n e d i n S e c t i o n 5 . 5 . 2 a n d   g  ( )  a n d  n 

 

d  n =  

m o d e l  

e  a r e a s d e n e d i n L e m m a 2 4 .  

I f f o r a g i v e n m e m o r y - a d a p t i v e s u b r o u t i n e   M  w e h a v e   g  (   

) =  O  ( l g   

) , t h e n b y L e m m a 2 5 , o u r f r a m e w o r k  

r e s u l t s i n a t o t a l r e s o u r c e c o n s u m p t i o n o f   O  (  n  l g  n  ) a n d b y C o r o l l a r y 2 t h e s o r t i n g a l g o r i t h m i s d y n a m i c a l l y o p t i m a l .  

9 6 

Page 110: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 110/203

O n t h e o t h e r h a n d i f   g  (   

) =  !  ( l g   

) t h e n u s i n g   M  i n o u r f r a m e w o r k r e s u l t s i n a d y n a m i c a l l y n o n o p t i m a l s o r t i n g  

a l g o r i t h m .  

C o r o l l a r y 3   A m e m o r y - a d a p t i v e s o r t i n g a l g o r i t h m c a s t i n o u r m e r g e s o r t f r a m e w o r k i s d y n a m i c a l l y o p t i m a l i f a n d  

o n l y i f   g  (   

) =  O  ( l g   

T h u s a s f a r a s o u r f r a m e w o r k i s c o n c e r n e d t h e o p t i m a l i t y o f t h e m e m o r y - a d a p t i v e s o r t i n g a l g o r i t h m d e p e n d s u p o n  

t h e r e s o u r c e c o n s u m p t i o n o f t h e m e m o r y - a d a p t i v e m e r g i n g s u b r o u t i n e   M 

L e t u s c o n s i d e r t h e q u a n t i t y    

, t h e n u m b e r o f r u n s m e r g e d b y a s i n g l e a p p l i c a t i o n o f t h e m e m o r y - a d a p t i v e  

m e r g i n g s u b r o u t i n e   M  I f   

i s a c o n s t a n t , s a y 2 , t h e n t h e r e s o u r c e c o n s u m p t i o n o f   M  c a n b e a s h i g h a s  

(  n 

l g  m 

m a x 

) =  !  (  n 

l g   

) w h e r e   n 

i s t h e t o t a l n u m b e r o f b l o c k s i n v o l v e d i n t h e b i n a r y m e r g e c a r r i e d o u t b y  

M  . T h i s h i g h r e s o u r c e c o n s u m p t i o n i s i n c u r r e d b y   M  i f t h e a l l o c a t i o n s e q u e n c e c o n s i s t s o f a l l o c a t i o n p h a s e s o f  

m a x 

b l o c k s t h r o u g h o u t t h e d u r a t i o n o f   M  ' s e x e c u t i o n , w h i c h s p a n s (  n 

) I / O o p e r a t i o n s . C l e a r l y , t h e s t r a t e g y o f  

r e s t r i c t i n g    

t o 2 i s i n c o n t r a s t t o t h e s t r a t e g y ( s u g g e s t e d i n S e c t i o n 5 . 4 . 2 ) o f h a v i n g m e m o r y - a d a p t i v e a l g o r i t h m s  

m i m i c o p t i m a l s t a t i c m e m o r y a l g o r i t h m s : W h e n t h e m e m o r y s i z e i s   m  b l o c k s , a n o p t i m a l s t a t i c m e m o r y m e r g e s o r t  

a l g o r i t h m a l w a y s m e r g e s (  m 

) r u n s w h e r e   c  i s a p o s i t i v e c o n s t a n t . H o w e v e r , a s i l l u s t r a t e d i n S e c t i o n 5 . 7 , t h e t a s k  

o f d y n a m i c a l l y r e o r g a n i z i n g m e r g e c o m p u t a t i o n i n a m a n n e r t h a t e n s u r e s t h a t t h e a r i t y o f m e r g i n g c o m p u t a t i o n i s  

p r o p o r t i o n a l t o t h e m e m o r y a l l o c a t i o n i s n o t a s t r a i g h t f o r w a r d o n e .  

5 . 6 P o t e n t i a l o f a M e r g e      

W e n o w d i s c u s s t h e n o t i o n o f t h e p o t e n t i a l o f a m e r g e w h i c h a p p l i e s t o a n y m e r g i n g a l g o r i t h m . T h e p o t e n t i a l o f a  

m e r g e a t a n y t i m e i s a q u a n t i c a t i o n o f t h e p r o g r e s s m a d e b y t h e m e r g e u p t o t h a t t i m e .  

D e n i t i o n 2 4   L e t  U  b e a s e t o f r u n s i n p u t t o a m e r g i n g r o u t i n e   M  . E v e r y s u b s e t   u  o f  U  h a s a r u n   r 

a s s o c i a t e d  

w i t h i t : I f   u  i s t h e s i n g l e t o n s e t t h e n   r 

i s t h e r u n i t c o n t a i n s o t h e r w i s e   r 

i s t h e r u n o u t p u t b y a m e r g e o f t h e r u n s  

c o n t a i n e d i n   u  . T h e   r a n k    p  (  r 

) o f a r u n   r 

i s d e n e d t o b e t h e c a r d i n a l i t y   j  u  j  o f  u  . T h e   p h y s i c a l s e q u e n c e   q  (  r 

; t  ) 

c o r r e s p o n d i n g t o r u n   r 

a t t i m e   t  i s d e n e d a s f o l l o w s :  

1 . A t t i m e   t  = 0 , t h e p h y s i c a l s e q u e n c e   q  (  r 

;  0 ) o f a n y i n p u t r u n   r 

, w i t h   j  u  j  = 1 , i s t h e e n t i r e s e q u e n c e o f e l e m e n t s  

o f  r 

t a k e n i n o r d e r . T h e p h y s i c a l s e q u e n c e   q  (  r 

0  ;  0 ) o f r u n   r 

0  a t t i m e   t  = 0 , w h e r e   u 

  U  i s n o t a s i n g l e t o n  

s e t , i s t h e e m p t y s e q u e n c e .  

2 . S u p p o s e t h a t a t t i m e   t  , a l g o r i t h m   M  i s i n t h e p r o c e s s o f e x e c u t i n g a m e r g e o p e r a t i o n . L e t   r 

b e t h e r u n  

c o r r e s p o n d i n g t o t h e o u t p u t r u n o f t h a t m e r g e o p e r a t i o n a n d r u n s   r 

; r 

; : : : ; r  

a r e t h e i n p u t r u n s o f t h e  

m e r g e o p e r a t i o n , s o w e h a v e   u  = 

S  

1    j    h 

. S u p p o s e t h a t t h e p h y s i c a l s e q u e n c e s   q  (  r 

; t  ) a n d   q  (  r 

; t  ) , w h e r e  

1    j    h  , a r e d e n e d i n d u c t i v e l y . T h e n i f , a t t i m e   t  , a l g o r i t h m   M  r e m o v e s t h e l e a d i n g i t e m   x  o f t h e p h y s i c a l  

9 7 

Page 111: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 111/203

s e q u e n c e o f r u n   r 

a n d  a p p e n d s   i t t o t h e p h y s i c a l s e q u e n c e o f r u n   r 

, w e h a v e   q  (  r 

; t  + 1 ) =   q  (  r 

; t  )    x  a n d 

q  (  r 

; t  ) =  x    q  (  r 

; t  + 1 ) , w h e r e \    " d e n o t e s c o n c a t e n a t i o n .  

W e s a y t h e f o r m a t i o n o f t h e r u n   r 

a s s o c i a t e d w i t h s e t   u  i s  l o g i c a l l y c o m p l e t e   a t t i m e   t  i f n o a p p e n d o p e r a t i o n ( a s i n  

S t e p 2 a b o v e ) c o r r e s p o n d i n g t o   q  (  r 

; t 

+ 1 ) =   q  (  r 

; t 

)    x  f o r s o m e   x  c a n b e e x e c u t e d a t a n y t i m e   t 

  t 

W e i l l u s t r a t e t h i s n o t i o n b y m e a n s o f a n e x a m p l e : S u p p o s e t h a t t h e m e r g e o f r u n s o f t h e s e t   S 

=  f   p 

; p 

; p 

; p 

; p 

i s i n p r o g r e s s a n d b y s o m e p o i n t   t  o f t i m e , r u n s    p 

a n d   p 

h a v e a l r e a d y b e e n d e p l e t e d b y t h a t m e r g e . T h e n a t t i m e  

t  t h e f o r m a t i o n o f t h e r u n   r 

a s s o c i a t e d w i t h t h e s e t   s  =  f   p 

; p 

g  i s l o g i c a l l y c o m p l e t e : S i n c e a l l e l e m e n t s o f    p 

a n d 

 p 

h a v e a l r e a d y b e e n a p p e n d e d i n t o t h e p h y s i c a l s e q u e n c e   q  (  r 

0  ; t  ) o f r u n   r 

0  b y t i m e   t  , n o e l e m e n t c a n e v e r b e  

a p p e n d e d t o t h e e m p t y p h y s i c a l s e q u e n c e   q  (  r 

; t  ) a t a n y t i m e a f t e r t i m e   t 

D e n i t i o n 2 5   T h e  r a n k    p  (  x ; t  ) o f a n i t e m   x  a t t i m e   t  i s t h e r a n k    p  (  r  ) o f t h e r u n   r  s u c h t h a t   x  l i e s i n t h e p h y s i c a l  

s e q u e n c e   q  (  r ; t  ) o f r u n   r  a t t i m e   t  . S u p p o s e t h a t   x 

; x 

; : : : ; x  

0  a r e t h e   N 

=  n 

B  i t e m s o f a l l t h e r u n s i n t h e s e t   U 

b e i n g m e r g e d b y t h e m e r g i n g r o u t i n e   M  . T h e n t h e   p o t e n t i a l   (  t  )  o f t h e m e r g e   a t t i m e   t  i s d e n e d t o b e  

(  t  ) = 

X   

i  = 1 

l g   p  (  x 

; t  ) 

C l e a r l y , a t t h e t i m e   t  = 0 o f t h e b e g i n n i n g o f t h e m e r g e , t h e p o t e n t i a l o f t h e m e r g e i s 0 . W h e n a l g o r i t h m   M 

n i s h e s t h e m e r g e o f r u n s o f s e t   U  , t h e p o t e n t i a l o f t h e m e r g e ( o r r a t h e r , t h e p r o g r e s s m a d e b y   M  ) i s  n 

l g  j  U  j  , w h e r e  

B  i s t h e t o t a l n u m b e r o f i t e m s m e r g e d .  

T h e m a n n e r i n w h i c h t h e p o t e n t i a l o f a m e r g e c h a n g e s o v e r a n a l l o c a t i o n s e q u e n c e d e p e n d s u p o n t h e m e r g i n g  

a l g o r i t h m . W e a r e a b l e t o r e l a t e t h e c u m u l a t i v e r e s o u r c e c o n s u m p t i o n o f o u r a l g o r i t h m   M A M e r g e  , p r e s e n t e d i n  

S e c t i o n 5 . 8 , u p t o a n y t i m e   t  t o t h e p o t e n t i a l (  t  ) o f t h e m e r g e a t t i m e   t  ; t h u s w e u s e p o t e n t i a l o f t h e m e r g e t o k e e p  

t r a c k o f t h e r e s o u r c e c o n s u m p t i o n o f   M A M e r g e  

5 . 7 N o n o p t i m a l i t y o f a s i m p l e m e m o r y - a d a p t i v e      

m e r g e s o r t a l g o r i t h m          

I n t h i s s e c t i o n , w e d i s c u s s a n e l e g a n t m e m o r y - a d a p t i v e m e r g e s o r t b a s e d u p o n t h e t e c h n i q u e s d e v e l o p e d b y P a n g e t  

a l . P C L 9 3 a ] . W e p r o v e t h a t i t s r e s o u r c e c o n s u m p t i o n i s n o n o p t i m a l .  

T h e m e m o r y - a d a p t i v e m e r g i n g a l g o r i t h m p r e s e n t e d i n P C L 9 3 a ] i s n o t d e s c r i b e d c o m p l e t e l y . B e l o w , w e p r e s e n t  

a n i n t u i t i v e l y a p p e a l i n g a l g o r i t h m f o r m e m o r y - a d a p t i v e m e r g i n g c a l l e d   M 

w h i c h c a n r e a s o n a b l y b e c o n s i d e r e d t o b e  

a n e x t e n s i o n o f t h e m e m o r y - a d a p t i v e m e r g i n g t e c h n i q u e s o f P C L 9 3 a ] . W e p r e s e n t t w o v a r i a n t s o f   M 

: O n e v a r i a n t ,  

9 8 

Page 112: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 112/203

w h i c h w e c a l l t h e   l i n e a r v a r i a n t  , t r i e s t o e x e c u t e (  m  ) - w a y m e r g e s w h e n t h e m e m o r y a l l o c a t e d i s   m  b l o c k s a n d t h e  

o t h e r v a r i a n t , w h i c h w e c a l l t h e   s u b l i n e a r v a r i a n t  , t r i e s t o e x e c u t e (  

m  ) - w a y m e r g e s w h e n t h e m e m o r y a l l o c a t e d  

i s  m  b l o c k s . U s i n g a n a d v e r s a r i a l a r g u m e n t w e s h o w t h a t s o r t i n g a l g o r i t h m s b a s e d u p o n t h e l i n e a r a n d s u b l i n e a r  

v a r i a n t s o f   M 

r e s p e c t i v e l y i n c u r a r e s o u r c e c o n s u m p t i o n o f  

 

n  ( l g  n  ) 

 

a n d  

 

n  ( l g  n  ) ( l g l g   n  ) 

 

r e s p e c t i v e l y a n d s o ,  

b y C o r o l l a r y 2 , a r e d y n a m i c a l l y n o n o p t i m a l .  

5 . 7 . 1 S k e t c h o f t h e m e m o r y - a d a p t i v e e x t e r n a l m e m o r y  

m e r g e s o r t  

T h e r u n f o r m a t i o n s t a g e r e m a i n s t h e o n e w e p r o p o s e d i n S e c t i o n 5 . 5 .  

D u r i n g t h e m e r g i n g s t a g e , a s i n g l e a p p l i c a t i o n  

o f t h e s u b r o u t i n e   M 

o f P C L 9 3 a ] c a n b e c o n s i d e r e d t o m e r g e a t m o s t    

=  m 

m a x 

  1 r u n s , w h e r e   m 

m a x 

i s t h e  

m a x i m u m n u m b e r o f d i s k b l o c k s t h a t c a n b e t i n p h y s i c a l m e m o r y . W e w i l l o n l y s k e t c h t h e m e m o r y - a d a p t i v e  

m e r g i n g a l g o r i t h m   M 

i n t h i s s e c t i o n : O u r f o c u s i s o n a s p e c t s o f t h e a l g o r i t h m t h a t m a k e t h e r e s o u r c e c o n s u m p t i o n  

o f  M 

s u b - o p t i m a l , s o w e s k i p s e v e r a l o f t h e d e t a i l s o f t h e a l g o r i t h m P C L 9 3 a ] .  

M e m o r y - a d a p t i v e s u b r o u t i n e   M 

W e n o w d e s c r i b e t h e m e m o r y - a d a p t i v e m e r g i n g s u b r o u t i n e   M 

w h i c h a t t e m p t s t o m i m i c a n o p t i m a l ( s t a t i c ) e x t e r n a l  

m e m o r y m e r g e s o r t a s d e s c r i b e d i n S e c t i o n 5 . 4 . 2 . T h e t w o v a r i a n t s o f   M 

c o r r e s p o n d t o t h e t w o m i m i c k i n g s t r a t e g i e s  

m e n t i o n e d i n S e c t i o n 5 . 4 . 4 f o r m e m o r y - a d a p t i v e m e r g e s o r t .  

S u p p o s e t h a t   M 

t r i e s t o e x e c u t e a   u  (  m  ) - w a y m e r g e d u r i n g a l l o c a t i o n p h a s e s o f s i z e   m  . T h e n t h e l i n e a r v a r i a n t  

o f  M 

c o r r e s p o n d s t o   u  (  m  ) = 2 

b  l g (  m    1 )  c 

w h i l e t h e s u b l i n e a r v a r i a n t o f   M 

c o r r e s p o n d s t o   u  (  m  ) = 2 

b  l g l g (  m    1 )  c 

W e n o w d e n e t h e   l e v e l   f u n c t i o n   f  ( ) t h a t m a p s a l l o c a t i o n p h a s e s t o a l l o c a t i o n l e v e l s , a s e x p l a i n e d i n S e c t i o n 5 . 4 . 4 .  

D e n i t i o n 2 6   F o r t h e l i n e a r v a r i a n t o f   M 

, w e d e n e   f  (  m  ) t o b e   b  l g (  m    1 )  c  a n d  f 

  1 

(   ̀ ) t o b e 2  

 ̀

. F o r t h e s u b l i n e a r  

v a r i a n t o f   M 

w e d e n e   f  (  m  ) t o b e   b  l g l g (   m    1 )  c  a n d  f 

  1 

(   ̀ ) t o b e 2  

 ̀

. ( S t r i c t l y s p e a k i n g , t h e f u n c t i o n s   f  ( ) a n d  

  1 

( ) a r e n o t m a t h e m a t i c a l i n v e r s e s o f e a c h o t h e r . ) A n a l l o c a t i o n p h a s e o f s i z e   m  i s s a i d t o b e a t a l l o c a t i o n l e v e l  

f  (  m  ) ; o r a l t e r n a t i v e l y , d u r i n g a n a l l o c a t i o n p h a s e o f s i z e   m  , t h e a l l o c a t i o n l e v e l i s s a i d t o b e   f  (  m  )

I n t h e c o n t e x t o f t h e m e m o r y - a d a p t i v e m e r g e s o r t f r a m e w o r k w e i n t r o d u c e d i n S e c t i o n 5 . 5 , w e u s e   M 

a s a 

s u b r o u t i n e t o m e m o r y - a d a p t i v e l y m e r g e    

=  f 

  1 

(  f  (  m 

m a x 

) ) r u n s a t a t i m e . T h i s m e a n s t h a t t h e l i n e a r v a r i a n t o f  

h a s   

= (  m 

m a x 

) w h e r e a s t h e s u b l i n e a r v a r i a n t h a s    

= ( 

m a x 

)

T h e p a p e r P C L 9 3 a ] c o n s i d e r s q u i c k s o r t a n d d i e r e n t v a r i a n t s o f r e p l a c e m e n t - s e l e c t i o n i n t h e  

c o n t e x t o f p r a c t i c a l i s s u e s s u c h a s l e n g t h s o f r u n s , r e s p o n s e - t i m e t o u c t u a t i o n s i n m e m o r y a n d  

d i s k - l o c a l i t y d u r i n g t h e r u n - f o r m a t i o n s t a g e . O u r a p p r o a c h c a n b e e x t e n d e d t o a d d r e s s m o s t o f  

t h e p r a c t i c a l i s s u e s t h e y c o n s i d e r w i t h r e s p e c t t o t h e r u n - f o r m a t i o n s t a g e .  

9 9 

Page 113: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 113/203

T h e b a s i c i d e a o f   M 

i s t o a l w a y s a s s o c i a t e e a c h a l l o c a t i o n l e v e l    ̀ w i t h a s e t   S 

 ̀

o f r u n s s u c h t h a t t h e r a n k    p  (  r 

 ̀

o f t h e r u n   r 

 ̀

a s s o c i a t e d w i t h   S 

 ̀

i s  f 

  1 

(   ̀ ) . T h e s e t   S 

 ̀

o f i n p u t r u n s a s s o c i a t e d w i t h a l l o c a t i o n l e v e l    ̀ m a y c h a n g e  

o v e r t h e c o u r s e o f t h e a l l o c a t i o n s e q u e n c e . T h e c o m p u t a t i o n l i n k e d t o l e v e l    ̀ a t a n y t i m e i s t h e m e r g e c o m p u t a t i o n  

n e c e s s a r y t o p r o d u c e b l o c k s o f t h e r u n   r 

 ̀

a s s o c i a t e d w i t h   S 

 ̀

. W h e n e v e r t h e l e v e l o f a l l o c a t i o n i s    ̀ ,  M 

e x e c u t e s  

a p o r t i o n o f t h e c o m p u t a t i o n l i n k e d t o l e v e l    ̀ . W h e n e v e r t h e f o r m a t i o n o f t h e r u n   r 

 ̀

i s l o g i c a l l y c o m p l e t e ,   M 

i s 

a s s i g n e d a n e w s e t o f r u n s s u c h t h a t t h e c o n d i t i o n    p  (  r 

 ̀

) =  f 

  1 

(   ̀ ) i s s a t i s e d e v e n w i t h t h e n e w v a l u e o f   S 

 ̀

a n d t h e  

p r o c e s s c o n t i n u e s .  

M e m b e r r u n s o f t h e s e t   S 

 ̀

m a y e i t h e r b e   m a r k e d   o r  u n m a r k e d   . T h e s e t s   S 

 ̀

f o r   ̀ 2 f  1  ;  2  ; : : : ; f   (  m 

m a x 

)  g  a r e 

m a i n t a i n e d b y   M 

o v e r t i m e a s f o l l o w s :  

1 . I n i t i a l i z a t i o n : T h e s e t   S 

f  (  m 

m a x 

i s i n i t i a l i z e d t o t h e    

r u n s t h a t a r e t h e r u n s t o b e m e r g e d . A l l r u n s i n  

f  (  m 

m a x 

a r e u n m a r k e d . T h e s e t s   S 

 ̀

c o r r e s p o n d i n g t o a l l o t h e r a l l o c a t i o n l e v e l s a r e s e t t o   n i l 

2 . D u r i n g t h e a l g o r i t h m , a s s o o n a s t h e m e r g e p r o d u c i n g t h e r u n   r 

 ̀

a s s o c i a t e d w i t h a s e t   S 

 ̀

b e c o m e s l o g i c a l l y  

c o m p l e t e , t h e s e t   S 

 ̀

i s s e t t o a n e m p t y s e t .  

3 . D u r i n g a n a l l o c a t i o n p h a s e o f s i z e   m  , w e c h e c k t o s e e i f s e t   S 

 ̀

, w h e r e    ̀ =  f  (  m  ) , i s e m p t y o n a c c o u n t o f p o i n t s 1  

o r 2 . I f s e t   S 

 ̀

i s e m p t y , w e e x e c u t e p r o c e d u r e   l o a d   (  S 

 ̀

) d e n e d i n p o i n t 4 b e l o w . S u p p o s i n g   S 

 ̀

i s n o n - e m p t y ,  

t h e n d u r i n g t h a t a l l o c a t i o n p h a s e   M 

c o m p u t e s b l o c k s o f t h e r u n   r 

 ̀

a s s o c i a t e d w i t h s e t   S 

 ̀

4 . W h e n e v e r a s e t   S 

 ̀

, w h e r e    ̀ 6=  f  (  m 

m a x 

) , n e e d s t o b e l o a d e d w e e x e c u t e t h e p r o c e d u r e   l o a d   (  S 

 ̀

) . I n t h i s p r o c e d u r e ,  

i f s e t   S 

 ̀ + 1 

i s e m p t y w e r e c u r s i v e l y l o a d i t b y e x e c u t i n g   l o a d   (  S 

 ̀ + 1 

) . S u p p o s i n g   S 

 ̀ + 1 

i s n o t e m p t y , i f i t c o n t a i n s  

0 u n m a r k e d r u n s , w e u n m a r k a l l r u n s o f t h a t s e t a n d s e t   S 

 ̀

t o  S 

 ̀ + 1 

. O n t h e o t h e r h a n d , i f   S 

 ̀ + 1 

c o n t a i n s  

u n m a r k e d r u n s , w e r e m o v e a s u b s e t   s    S 

 ̀ + 1 

c o n t a i n i n g   f 

  1 

(   ̀ ) u n m a r k e d r u n s  

f r o m   S 

 ̀ + 1 

, s e t   S 

 ̀

=  s  a n d 

a d d a m a r k e d r u n   r 

t h a t i s a s s o c i a t e d w i t h s u b s e t   s  i n t o s e t   S 

 ̀ + 1 

T h e b i g g e s t d r a w b a c k o f t h e a b o v e s c h e m e f o r m e m o r y - a d a p t i v e m e r g i n g i s t h a t m e r g e c o m p u t a t i o n p r o d u c i n g  

b l o c k s o f r u n   r 

 ̀

a s s o c i a t e d w i t h s e t   S 

 ̀

i s c a r r i e d o u t i n a l l o c a t i o n p h a s e s o f s i z e a t l e a s t   f 

  1 

(   ̀ ) e v e n i f o n l y a 2 - w a y  

( b i n a r y ) m e r g e i s n e e d e d t o p r o d u c e r u n   r 

 ̀

, o w i n g t o p r e v i o u s l y e x e c u t e d c o m p u t a t i o n s a t l o w e r l e v e l s : T h e r s t  

t i m e s e t   S 

 ̀

g e t s l o a d e d i t m a y h a v e a l a r g e n u m b e r   f 

  1 

(   ̀ ) , o f r u n s t o m e r g e . A t s u c h t i m e s , t h e m e r g e c o m p u t a t i o n  

p r o d u c i n g b l o c k s o f t h e r u n   r 

 ̀

m a k e s v e r y e c i e n t u s e o f   m  - s i z e d a l l o c a t i o n p h a s e s , w h e r e    ̀ =  f  (  m  ) . H o w e v e r , i n  

g e n e r a l , a l l o c a t i o n l e v e l s u c t u a t e . I f t h e a l l o c a t i o n l e v e l s r e m a i n s m a l l e r t h a n    ̀ f o r l o n g e n o u g h , i t i s p o s s i b l e t h a t  

w h e n t h e a l l o c a t i o n l e v e l n e x t b e c o m e s    ̀ , a b i n a r y m e r g e i s w h a t i s r e q u i r e d i n o r d e r t o p r o d u c e b l o c k s o f t h e r u n   r 

 ̀

I f s e t   S 

 ̀ + 1 

c o n t a i n s e v e n o n e u n m a r k e d r u n i t c o n t a i n s a t l e a s t   f 

  1 

(   ̀ ) u n m a r k e d r u n s .  

1 0 0 

Page 114: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 114/203

T h e t r a n s f o r m a t i o n o f w h a t w a s o r i g i n a l l y a n   f 

  1 

(   ̀ ) - w a y m e r g e i n t o a 2 - w a y m e r g e c a n t a k e p l a c e i f t h e f o r m a t i o n  

o f b o t h t h e r u n s   r 

0  a n d  r 

0 0  , w h e r e   S 

 ̀

=  S 

  S 

0 0 

, i s l o g i c a l l y c o m p l e t e d w h e n t h e a l l o c a t i o n l e v e l i s s m a l l e r t h a n    ̀

E v e n w h e n t h e m e r g e r e q u i r e d t o p r o d u c e b l o c k s o f   r 

 ̀

i s t r a n s f o r m e d i n t o a b i n a r y m e r g e , t h e a l g o r i t h m   M 

w i l l p e r s i s t i n u s i n g l e v e l    ̀ a l l o c a t i o n p h a s e s t o e x e c u t e t h a t b i n a r y m e r g e . T h i s i s i n e c i e n t b e c a u s e h u g e a l l o c a t i o n  

p h a s e s o f s i z e   m  s u c h t h a t   f  (  m  ) =   ̀ c a n e n d u p b e i n g u s e d t o e x e c u t e t h e b i n a r y m e r g e : T h e i n c r e a s e i n m e r g e  

p o t e n t i a l r e g i s t e r e d b y   M 

d u r i n g s u c h a n   m  s i z e d p h a s e i s o n l y   O  (  m  ) w h e r e a s t h e r e s o u r c e c o n s u m p t i o n i s 2  m  l g  m 

T h e f a c t t h a t r e s o u r c e c o n s u m p t i o n i s m u c h g r e a t e r t h a n t h e i n c r e a s e i n m e r g e p o t e n t i a l r e g i s t e r e d b y   M 

d u r i n g  

s u c h p h a s e s t u r n s o u t t o b e a f u n d a m e n t a l i n e c i e n c y , a s w i l l b e s e e n f r o m o u r a n a l y s i s b e l o w a n d i n t h e f o l l o w i n g t w o  

s e c t i o n s . T h i s i n e c i e n c y i s p r e c i s e l y w h a t w e e x p l o i t t o p r o d u c e a   n e m e s i s   s e q u e n c e o f a l l o c a t i o n p h a s e s r e s u l t i n g  

i n s u b - o p t i m a l r e s o u r c e c o n s u m p t i o n f o r t h e a l g o r i t h m .  

W e d o n o t m e n t i o n d e t a i l s r e g a r d i n g d a t a s t r u c t u r e s u s e d t o m a i n t a i n t h e s e t s   S 

 ̀

o f r u n s a s s o c i a t e d w i t h l e v e l s  

d u r i n g   M 

s i n c e w e a s s u m e , c o n s e r v a t i v e l y , t h a t t h e s e t s o f r u n s c a n b e m a i n t a i n e d w i t h o u t a n y c o s t .  

5 . 7 . 2 L o w e r B o u n d o n R e s o u r c e C o n s u m p t i o n  

W e w i l l c o n s t r u c t a s e q u e n c e o f a l l o c a t i o n p h a s e s t h a t f o r c e s s u b - o p t i m a l r e s o u r c e c o n s u m p t i o n f o r t h e m e m o r y -  

a d a p t i v e s o r t i n g a l g o r i t h m o b t a i n e d b y a p p l y i n g t h e p r e v i o u s s e c t i o n ' s m e m o r y - a d a p t i v e a l g o r i t h m   M 

t o o u r  

m e m o r y - a d a p t i v e m e r g e s o r t f r a m e w o r k . W e w i l l e x p r e s s t h e n e m e s i s s e q u e n c e c o n s t r u c t i o n i n t e r m s o f   f  (  m  ) a n d  

  1 

(   ̀ ) s o t h a t i t i s a p p l i c a b l e t o b o t h t h e l i n e a r a n d s u b l i n e a r v a r i a n t s o f t h e m e r g i n g s c h e m e .  

F o r c o n v e n i e n c e , w e a s s u m e t h a t i n c a s e o f t h e l i n e a r v a r i a n t o f   M 

,  m 

m a x 

= 2 

 ̀

m a x 

+ 1 w h e r e a s i n c a s e o f t h e  

s u b l i n e a r v a r i a n t o f   M 

, w e a s s u m e t h a t   m 

m a x 

= 2 

 ̀

m a x 

+ 1 . W e u s e a s i m p l e t e c h n i q u e t o c o n s t r u c t o u r n e m e s i s  

a l l o c a t i o n s e q u e n c e . W e r s t i n t r o d u c e s o m e t e r m i n o l o g y t h a t i s a p p l i c a b l e t o t h e n e m e s i s a l l o c a t i o n s e q u e n c e w e  

c o n s t r u c t f o r t h e a l g o r i t h m   M 

D e n i t i o n 2 7   W e u s e     (  n 

; r ; m   ) t o d e n o t e t h e a l l o c a t i o n s e q u e n c e   m 

; m 

; : : : ; m  

s a t i s f y i n g t h e f o l l o w i n g c o n d i -  

t i o n s :  

1 m 

  m  f o r 1     i    f 

2 . B e g i n n i n g w i t h t h e a l l o c a t i o n p h a s e   m 

, t h e a l g o r i t h m   M 

c o m p l e t e s t h e m e r g e o f   r  r u n s t o t a l l y c o n s i s t i n g o f  

b l o c k s o f i t e m s p r e c i s e l y a t t h e e n d o f t h e a l l o c a t i o n s e q u e n c e     (  n 

; r ; m   )

W e u s e (  n 

; r ; m   ) t o d e n o t e t h e r e s o u r c e c o n s u m p t i o n c o r r e s p o n d i n g t o t h e a l l o c a t i o n s e q u e n c e     (  n 

; r ; m   )

B e l o w w e s h o w h o w t o r e c u r s i v e l y c o n s t r u c t t h e n e m e s i s s e q u e n c e     (  n 

;  m 

m a x 

  1  ;  m 

m a x 

) . W e p r o v e a l o w e r b o u n d  

o n (  n 

;  m 

m a x 

  1  ;  m 

m a x 

) a s s u m i n g t h a t a l l t h e   m 

m a x 

  1 r u n s b e i n g m e r g e d a r e o f l e n g t h   n 

=  (  m 

m a x 

  1 ) b l o c k s .  

1 0 1 

Page 115: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 115/203

R e c u r s i v e F o r m u l a t i o n  

W e u s e t h e n o t a t i o n    

   

t o m e a n t h e c o n c a t e n a t i o n o f t h e t w o s e q u e n c e s    

a n d   

. W e a l s o u s e t h e n o t a t i o n  

 

t o m e a n    

   

p    1 

. O u r c o n s t r u c t i o n o n l y u s e s   r  ' s o f t h e f o r m 2  

 ̀

( r e s p e c t i v e l y 2  

) i n t h e l i n e a r ( r e s p e c t i v e l y  

s u b l i n e a r ) v a r i a n t . I n t h e d e n i t i o n b e l o w , w e u s e ^  r  t o d e n o t e   f 

  1 

(  f  (  r  ) ) . W e h a v e ^  r  =  r =  2 i n t h e l i n e a r v a r i a n t a n d  

 ̂r  = 

r  i n t h e s u b l i n e a r v a r i a n t , f o r t h e   r  ' s w e c o n s i d e r . O u r r e c u r s i v e c o n s t r u c t i o n o f t h e n e m e s i s a l l o c a t i o n s e q u e n c e  

  (  n 

;  m 

m a x 

  1  ;  m 

m a x 

) i s a s f o l l o w s :  

1 . B a s e C a s e . W e d e n e  

  (  n 

;  2  ; m  ) =  m 

= m 

T h u s (  n 

;  2  ; m  ) = 2  n 

l o g  m  , b y d e n i t i o n .  

2 . R e c u r s i o n . W e d e n e  

  (  n 

; r ; m   ) =   

  

 ̂r 

;   ̂r ;   ̂r  + 1 

 

 ̂r 

   

 

 ̂r 

; m 

 

T h u s w e h a v e  

(  n 

; r ; m   ) = 

 ̂r 

 

  

 ̂r 

;   ̂r ;   ̂r  + 1 

 

+  

 

 ̂r 

; m 

 

I t i s e a s y t o p r o v e i n d u c t i v e l y t h a t     (  n 

; r ; m   ) c o n s t r u c t e d a s a b o v e m e e t s t h e r e q u i r e m e n t s m e n t i o n e d i n t h e  

d e n i t i o n a b o v e . W e w i l l n o w p r o v e l o w e r b o u n d s o n t h e r e s o u r c e c o n s u m p t i o n o f t h e m e m o r y - a d a p t i v e m e r g i n g  

a l g o r i t h m b y s o l v i n g f o r (  n 

;  m 

m a x 

  1  ;  m 

m a x 

)

L e m m a 2 6   I n t h e l i n e a r v a r i a n t o f t h e m e m o r y - a d a p t i v e e x t e r n a l m e m o r y a l g o r i t h m ,  

(  n 

;  m 

m a x 

  1  ;  m 

m a x 

) = (  n 

( l g  m 

m a x 

)  ; 

w h e r e a s i n c a s e o f t h e s u b l i n e a r v a r i a n t ,  

(  n 

;  m 

m a x 

  1  ;  m 

m a x 

) = (  n 

( l g  m 

m a x 

) ( l g l g   m 

m a x 

) ) 

P r o o f  : I n c a s e o f t h e l i n e a r v e r s i o n o f t h e a l g o r i t h m , w e h a v e  

(  n 

; r ; r   + 1 ) = 2 (  n 

=  2  ; r =  2  ; r =  2 + 1 ) + (  n 

;  2  ; r  + 1 ) 

1 0 2 

Page 116: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 116/203

U s i n g t h e b a s e c a s e a n d s u p p o s i n g i n d u c t i v e l y t h a t (  n 

0 0 

; r 

; r 

+ 1 )    n 

0 0 

( l g (  r 

+ 1 ) )  

f o r  n 

0 0 

  n 

,  r 

< r  , w e h a v e  

(  n 

; r ; r   + 1 )    2 (  n 

=  2 ) ( l g (  r =  2 + 1 ) )  

+ 2  n 

l g (  r  + 1 ) 

  n 

( l g (  r  + 1 )    1 ) 

+ 2  n 

l g (  r  + 1 ) 

  n 

( l g (  r  + 1 ) )  

  2  n 

l g (  r  + 1 ) + 2  n 

l g (  r  + 1 ) 

  n 

( l g (  r  + 1 ) )  

T h u s (  n 

;  m 

m a x 

  1  ;  m 

m a x 

)    n 

( l g  m 

m a x 

i n c a s e o f t h e l i n e a r v a r i a n t .  

I n c a s e o f t h e s u b l i n e a r v a r i a n t t h e r e c u r r e n c e f o r (  n 

; r ; r   + 1 ) u n f o l d s a s  

(  n 

; r ; r   + 1 ) =  

r  (  n 

r ; 

r ; 

r  + 1 ) + (  n 

r ; r  + 1 ) 

R e c a l l t h a t i n t h e s u b l i n e a r v a r i a n t w e a s s u m e t h a t t h e   r  ' s a r e s u c h t h a t l g l g   r  i s i n t e g r a l . W e t r a n s f o r m t h e s e c o n d a n d  

t h i r d v a r i a b l e s o f (  n 

; r ; r  

+ 1 ) b y d e n i n g t h e f u n c t i o n (  n 

;  l g l g   r ;  l g l g   r 

) t o b e i d e n t i c a l t o (  n 

; r ; r  

+ 1 ) , w h e r e  

l g l g   r  a n d l g l g   r 

a r e b o t h i n t e g r a l . T h u s (  n 

; r ; r   + 1 ) = (  n 

; k ; k   ) , w h e r e   k  = l g l g   r  a n d w e b o u n d (  n 

; r ; r   + 1 ) 

a s f o l l o w s .  

(  n 

; k ; k   )    2 

k    1 

(  n 

=  2 

k    1 

; k    1  ; k    1 ) + (  n 

; k    1  ; k  ) 

k    1 

X   

i  = 1 

(  n 

=  2 

; i ; i  ) + (  n 

;  0  ; k  ) 

U s i n g t h e b a s e c a s e a n d i n d u c t i v e l y a s s u m i n g t h a t (  n 

0 0 

; k 

; k 

)    n 

0 0 

  1 

f o r  n 

0 0 

  n 

a n d  k 

  k  , w e h a v e  

(  n 

; k ; k   )    n 

=  2 

k    1 

X   

i  = 1 

i  2 

+ 2  n 

  2 

  n 

k  2 

k    1 

T h u s w e h a v e (  n 

;  m 

m a x 

  1  ;  m 

m a x 

)    n 

( l g l g   m 

m a x 

) ( l g   m 

m a x 

)  =  2 w i t h r e s p e c t t o t h e s u b l i n e a r v a r i a n t .  

U s i n g t h e a b o v e l e m m a i n c o n j u n c t i o n w i t h L e m m a 2 5 , w e h a v e t h e f o l l o w i n g t h e o r e m r e g a r d i n g r e s o u r c e c o n -  

s u m p t i o n o f t h e m e m o r y - a d a p t i v e e x t e r n a l m e m o r y s o r t i n g a l g o r i t h m b a s e d u p o n t e c h n i q u e s o f P C L 9 3 a ] .  

T h e o r e m 1 1   W h i l e s o r t i n g a l e o f   n  b l o c k s , t h e m e m o r y - a d a p t i v e e x t e r n a l m e m o r y s o r t i n g a l g o r i t h m s b a s e d u p o n  

t h e l i n e a r a n d s u b l i n e a r v a r i a n t s o f t h e m e m o r y - a d a p t i v e e x t e r n a l m e m o r y m e r g i n g s u b r o u t i n e   M 

h a v e r e s o u r c e  

c o n s u m p t i o n o f   (  n  ( l g  n  ) ( l g   m 

m a x 

) )  a n d  (  n  ( l g  n  ) ( l g l g   m 

m a x 

) )  r e s p e c t i v e l y .  

B y T h e o r e m 1 1 a n d C o r o l l a r y 2 , t h e a b o v e a p p r o a c h t o m e m o r y - a d a p t i v e s o r t i n g i s d y n a m i c a l l y n o n o p t i m a l .  

1 0 3 

Page 117: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 117/203

5 . 8 D y n a m i c a l l y O p t i m a l M e m o r y - A d a p t i v e S o r t -    

i n g   

I n t h i s s e c t i o n w e p r e s e n t a n e w m e m o r y - a d a p t i v e m e r g i n g s u b r o u t i n e   M A M e r g e   t h a t c a n b e u s e d a s   M  i n t h e  

f r a m e w o r k o f S e c t i o n 5 . 5 . 2 t o o b t a i n a d y n a m i c a l l y o p t i m a l s o r t i n g a l g o r i t h m .  

T h r o u g h o u t t h i s s e c t i o n , w e u s e     t o d e n o t e t h e n u m b e r    

M A M e r g e  

o f r u n s t h a t e a c h a p p l i c a t i o n o f   M A M e r g e  

m e r g e s t o g e t h e r . T h e v a l u e o f     i s a p p r o p r i a t e l y c h o s e n t o b e (  m 

m a x 

) e x c e p t p o s s i b l y f o r t h e n a l a p p l i c a t i o n i n  

w h i c h c a s e i t c a n b e a s s m a l l a s 2 . T h e n o v e l t y o f   M A M e r g e   l i e s i n t h e d a t a s t r u c t u r e s a n d t e c h n i q u e s i t u s e s t o  

r e o r g a n i z e t h e o r i g i n a l m e r g e c o m p u t a t i o n a d a p t i v e l y s o a s t o e n s u r e t h a t i n \ t y p i c a l " a l l o c a t i o n p h a s e s , t h e r e s o u r c e  

c o n s u m p t i o n o f   M A M e r g e   i s w i t h i n a c o n s t a n t f a c t o r o f t h e i n c r e a s e i n m e r g e p o t e n t i a l i t r e g i s t e r s , a n d , d u r i n g a l l  

o t h e r a l l o c a t i o n p h a s e s , t h e t o t a l n u m b e r o f I / O o p e r a t i o n s i t i n c u r s i s l i n e a r i n t h e t o t a l n u m b e r o f b l o c k s o u t p u t  

b y  M A M e r g e  

T h e o r e m 1 2   S u p p o s e t h a t M A M e r g e i s u s e d t o m e r g e t o g e t h e r a s e t o f     i n p u t r u n s t o t a l l y c o m p r i s i n g   n 

b l o c k s .  

C o n s i d e r a n y t i m e   t  d u r i n g t h e e x e c u t i o n o f M A M e r g e , u p t o a n d i n c l u d i n g t h e t i m e M A M e r g e n i s h e s e x e c u t i o n .  

T h e n t h e r e s o u r c e c o n s u m p t i o n o f M A M e r g e d u r i n g t h e a l l o c a t i o n s e q u e n c e u p t o t i m e   t  i s  O  ( (  t  ) +  n 

l g  m 

m a x 

)  , w h e r e  

(  t  )  i s t h e p o t e n t i a l o f t h e m e r g e a t t i m e   t  . I n t h e c a s e     = (  m 

m a x 

)  , w e h a v e   O  ( (  t  ) +  n 

l g  m 

m a x 

) =  O  (  n 

l g    ) 

T h e n a l a p p l i c a t i o n o f   M A M e r g e   m a y m e r g e o n l y a s m a l l n u m b e r   o  (  m 

m a x 

) o f r u n s . T h i s a p p l i c a t i o n o f   M A M e r g e  

m a y i n c u r a r e s o u r c e c o n s u m p t i o n o f   O  (  n 

l g  m 

m a x 

) a s o p p o s e d t o   O  (  n 

l g    ) . H o w e v e r , w e c a n s h o w t h a t o u r s o r t i n g  

a l g o r i t h m r e m a i n s d y n a m i c a l l y o p t i m a l .  

A s k e t c h o f t h e a b o v e t h e o r e m g i v e s a \ h i g h l e v e l " i d e a o f t h e t e c h n i q u e u s e d b y   M A M e r g e   t o t i e i t s r e s o u r c e  

c o n s u m p t i o n a t a n y t i m e t o t h e p o t e n t i a l o f i t s m e r g e a t t h a t t i m e . I n o r d e r t o s k e t c h t h e p r o o f o f T h e o r e m 1 2 , w e  

d e n e \ o p t i m a l " a n d \ n o n o p t i m a l p h a s e s " .  

D e n i t i o n 2 8   A n a l l o c a t i o n p h a s e o f s i z e   m  , w h e r e    

m o d e l  

  m    m 

m a x 

, i n w h i c h t h e p o t e n t i a l o f t h e m e r g e b e i n g  

c a r r i e d o u t b y   M A M e r g e   i n c r e a s e s b y a n a d d i t i v e a m o u n t o f (  m  l g  m  ) i s a n   o p t i m a l p h a s e   . E v e r y o t h e r a l l o c a t i o n  

p h a s e i s s a i d t o b e a   n o n o p t i m a l p h a s e .  

T h e n o v e l a s p e c t s o f  M A M e r g e   a r e t h e t e c h n i q u e s a n d d a t a s t r u c t u r e s i t e m p l o y s t o e n s u r e t h a t a t y p i c a l a l l o c a t i o n  

p h a s e i s a n o p t i m a l p h a s e . I n a t y p i c a l a l l o c a t i o n p h a s e o f s i z e   m  ,  M A M e r g e   c a n e c i e n t l y a c c e s s t h e p h y s i c a l  

s e q u e n c e s o f   m 

= ( 

m  ) a p p r o p r i a t e r u n s   r 

; r 

; r 

; : : : ; r  

s u c h t h a t  

1 u  = 

S  

1    i    m 

, a n d  

2 . F o r 1     i    m 

, w e h a v e    p  (  r 

) =  j  u  j  =  m 

j  u 

j  =  m 

 p  (  r 

)

1 0 4 

Page 118: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 118/203

W h e n e v e r t h e s e c o n d i t i o n s a r e s a t i s e d ,   M A M e r g e   c a n u s e t h e 2  m  I / O o p e r a t i o n s o f t h e p h a s e t o a p p e n d (  m B  ) 

n e w i t e m s t o t h e p h y s i c a l s e q u e n c e o f r u n   r 

, w h e r e e a c h a p p e n d e d i t e m b e l o n g s t o t h e p h y s i c a l s e q u e n c e o f o n e o f  

t h e r u n s   r 

; r 

; : : : ; r  

. B y d e n i t i o n , t h e i n c r e a s e i n t h e p o t e n t i a l o f t h e m e r g e d u r i n g s u c h a n a l l o c a t i o n p h a s e  

i s  

 

m B 

l g 

 

 p  (  r 

 p  (  r 

 

= (  m  l g  m  ) , a n d t h u s t h e p h a s e i s o p t i m a l . T h e r e s o u r c e c o n s u m p t i o n 2  m  l g  m  i n c u r r e d  

d u r i n g a n o p t i m a l p h a s e o f s i z e   m  c a n b e c h a r g e d t o t h e p o t e n t i a l i n c r e a s e (  m  l g  m  ) r e g i s t e r e d b y   M A M e r g e   d u r i n g  

t h a t p h a s e . S i n c e t h e p o t e n t i a l o f t h e m e r g e c a n n e v e r e x c e e d   n 

l g    , t h e n e t r e s o u r c e c o n s u m p t i o n d u r i n g a l l o p t i m a l  

p h a s e s i s n o m o r e t h a n   O  (  n 

l g    )

O n t h e o t h e r h a n d , t h e t e c h n i q u e s u s e d b y   M A M e r g e   a l s o e n s u r e t h a t t h e t o t a l n u m b e r o f I / O o p e r a t i o n s o b t a i n e d  

b y s u m m i n g t h e I / O o p e r a t i o n s o v e r a l l n o n o p t i m a l p h a s e s i s   O  (  n 

) . S i n c e t h e m a x i m u m r e s o u r c e c o n s u m p t i o n o f  

a n I / O o p e r a t i o n i s l g   m 

m a x 

, t h e r e s o u r c e c o n s u m p t i o n d u r i n g a l l t h e n o n o p t i m a l p h a s e s o f   M A M e r g e   r e m a i n s  

O  (  n 

l g  m 

m a x 

) . T h i s c o n c l u d e s t h e s k e t c h o f t h e p r o o f o f T h e o r e m 1 2 .  

5 . 8 . 1 O v e r v i e w  

E a c h a p p l i c a t i o n o f   M A M e r g e  , e x c e p t p o s s i b l y t h e n a l a p p l i c a t i o n , m e r g e s t o g e t h e r     = 2 

d  l g l g (  m 

m a x 

=  

l e v e l  

)  e 

r u n s  

f r o m   Q  a s d e s c r i b e d i n S e c t i o n 5 . 5 . 2 , w h e r e    

l e v e l  

i s a c o n s t a n t t o b e d e t e r m i n e d l a t e r .   M A M e r g e   p a r t i t i o n s t h e s e t  

o f p o s s i b l e s i z e s o f a l l o c a t i o n p h a s e s i n t o \ a l l o c a t i o n l e v e l s " .  

D e n i t i o n 2 9   A n a l l o c a t i o n p h a s e o f s i z e   s  i s s a i d t o b e a t a l l o c a t i o n l e v e l  l e v e l  (  s  ) =  d  l g l g (   s =  

l e v e l  

)  e  ; o r a l t e r n a t i v e l y ,  

d u r i n g a l l o c a t i o n p h a s e s o f s i z e   s  , t h e ( o n g o i n g ) a l l o c a t i o n l e v e l i s s a i d t o b e   l e v e l  (  s  ) . I n o u r s c h e m e , w e r e q u i r e t h a t  

t h e i n t e g r a l c o n s t a n t    

m o d e l  

d e n e d i n D e n i t i o n 1 9 b e l a r g e e n o u g h f o r   l e v e l  (   

m o d e l  

) t o b e 1 . W e u s e    ̀

m a x 

t o d e n o t e  

t h e i n t e g e r   l e v e l  (  m 

m a x 

)

B y d e n i t i o n , e a c h a l l o c a t i o n p h a s e i s a t o n e o f t h e a l l o c a t i o n l e v e l s    ̀ , w h e r e    ̀ 2 f  1  ;  2  ; : : : ; `  

m a x 

T h e b a s i c s t r a t e g y e m p l o y e d b y   M A M e r g e   i s t o d y n a m i c a l l y m a i n t a i n a n a s s o c i a t i o n o f a m e r g e o p e r a t i o n \ a p -  

p r o p r i a t e f o r l e v e l    ̀ " w i t h e a c h a l l o c a t i o n l e v e l    ̀ a n d t o g e n e r a t e (  m  ) b l o c k s o u t p u t b y t h a t m e r g e o p e r a t i o n d u r i n g  

a n a l l o c a t i o n p h a s e o f s i z e   m  a t l e v e l    ̀

I n t h e c a s e w h e n t h e f o r m a t i o n o f t h e o u t p u t r u n o f t h a t m e r g e o p e r a -  

t i o n i s l o g i c a l l y c o m p l e t e d b e f o r e (  m  ) b l o c k s c a n b e o u t p u t ,   M A M e r g e   e n d s u p g e n e r a t i n g l e s s t h a n (  m  ) b l o c k s  

d u r i n g t h a t p h a s e . W h e n e v e r t h e f o r m a t i o n o f t h e o u t p u t r u n o f t h e m e r g e o p e r a t i o n a s s o c i a t e d w i t h l e v e l    ̀ g e t s  

l o g i c a l l y c o m p l e t e d ,   M A M e r g e   h a s t o r e o r g a n i z e t h e g l o b a l m e r g e c o m p u t a t i o n s o a s t o n d a n e w m e r g e o p e r a t i o n  

\ a p p r o p r i a t e f o r l e v e l    ̀ "

A n e x c e p t i o n a l c a s e i s w h e n   ` >  m a x l e v e l  , w h e r e   m a x l e v e l   i s a v a r i a b l e m a i n t a i n e d b y   M A M e r g e  

a s d e s c r i b e d b e l o w .  

1 0 5 

Page 119: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 119/203

D e n i t i o n 3 0   A m e r g e o p e r a t i o n i s s a i d t o b e   a p p r o p r i a t e f o r l e v e l    ̀ i f t h e r a n k    p  (  x ; t  ) o f a n e l e m e n t   x  a p p e n d e d  

a t t i m e   t  t o t h e p h y s i c a l s e q u e n c e o f t h e o u t p u t r u n o f t h a t m e r g e o p e r a t i o n i s s u c h t h a t  

 p  (  x ; t  )    2 

 ̀   1 

   p  (  x ; t    1 ) 

P u t a n o t h e r w a y , i f   x  l i e s i n t h e p h y s i c a l s e q u e n c e o f r u n   r 

a t t i m e   t    1 a n d i n t h e p h y s i c a l s e q u e n c e o f t h e o u t p u t  

r u n  r  o f t h e m e r g e o p e r a t i o n a t t i m e   t  , t h e n w e h a v e    p  (  r  )    2 

 ̀   1 

   p  (  r 

)

E v e r y a l l o c a t i o n p h a s e i n w h i c h   M A M e r g e   o u t p u t s (  m  ) b l o c k s o f a m e r g e o p e r a t i o n a p p r o p r i a t e f o r l e v e l    ̀ i s 

a n o p t i m a l p h a s e , b y d e n i t i o n . A l l o c a t i o n p h a s e s s p e n t b y   M A M e r g e   i n r e o r g a n i z i n g t h e g l o b a l m e r g e s o a s t o n d  

m e r g e o p e r a t i o n s f o r l e v e l s n o t c u r r e n t l y a s s o c i a t e d w i t h a p p r o p r i a t e m e r g e s m a y b e n o n o p t i m a l . A n a l l o c a t i o n p h a s e  

o f s i z e   m  a t l e v e l    ̀ c a n a l s o b e n o n o p t i m a l i f t h e f o r m a t i o n o f t h e o u t p u t r u n o f t h e m e r g e o p e r a t i o n a p p r o p r i a t e f o r  

l e v e l    ̀ g e t s c o m p l e t e d d u r i n g t h a t p h a s e . A n o t h e r s o u r c e o f p o s s i b l y n o n o p t i m a l p h a s e s a r e p h a s e s a t a n y a l l o c a t i o n  

l e v e l   ` >  m a x l e v e l  , w h e r e   m a x l e v e l   i s a s p e c i a l v a r i a b l e m a i n t a i n e d b y   M A M e r g e  . T h e n u m b e r o f n o n o p t i m a l p h a s e s  

i s s m a l l e n o u g h t h a t t h e n u m b e r o f I / O o p e r a t i o n s s u m m e d o v e r a l l n o n o p t i m a l p h a s e s i s   O  (  n 

) , w h e r e   n 

i s t h e  

n u m b e r o f b l o c k s o u t p u t b y   M A M e r g e  

I n S e c t i o n 5 . 8 . 2 w e p r e s e n t t h e r e c u r s i v e l y d e n e d d a t a s t r u c t u r e o f a \ r u n - r e c o r d " t h a t p l a y s a c e n t r a l r o l e i n  

t h e m a n n e r i n w h i c h   M A M e r g e   d y n a m i c a l l y r e o r g a n i z e s i t s m e r g e c o m p u t a t i o n . I n S e c t i o n 5 . 8 . 3 , w e d e s c r i b e t h e  

p r e p r o c e s s i n g s t a g e o f   M A M e r g e   a n d s o m e o t h e r p r e l i m i n a r i e s o f   M A M e r g e  . I n S e c t i o n 5 . 8 . 4 , w e p r e s e n t a d a t a  

s t r u c t u r e c a l l e d l e v e l - r e c o r d t h a t s t o r e s , f o r e a c h l e v e l    ̀ , t h e m e r g e o p e r a t i o n a p p r o p r i a t e f o r l e v e l    ̀ . I n S e c t i o n 5 . 8 . 5 ,  

w e m e n t i o n t h e i n v a r i a n t s p e r t a i n i n g t o r u n - r e c o r d s a n d l e v e l - r e c o r d s t h a t   M A M e r g e   m a i n t a i n s . I n S e c t i o n 5 . 8 . 6 ,  

w e d e s c r i b e t h e s i m p l e p r o c e d u r e e x e c u t e d b y   M A M e r g e   d u r i n g a p h a s e a t a l l o c a t i o n l e v e l    ̀ w h e n t h e r e d o e s e x i s t  

a n a p p r o p r i a t e m e r g e o p e r a t i o n f o r l e v e l    ̀ . I n S e c t i o n 5 . 8 . 7 , w e p r e s e n t t h e   d o w n l o a d   ( ) o p e r a t i o n u s e d t o n d n e w  

a p p r o p r i a t e m e r g e o p e r a t i o n s f o r l e v e l s t h a t a r e c u r r e n t l y n o t a s s o c i a t e d w i t h a n y m e r g e o p e r a t i o n . I n S e c t i o n 5 . 8 . 8 ,  

w e s e w t o g e t h e r o u r d a t a s t r u c t u r e s a n d t e c h n i q u e s t o o b t a i n t h e m e m o r y - a d a p t i v e m e r g i n g a l g o r i t h m   M A M e r g e  

W e a n a l y z e   M A M e r g e  ' s r e s o u r c e c o n s u m p t i o n i n S e c t i o n 5 . 9 .  

5 . 8 . 2 R u n - R e c o r d s  

W e a s s o c i a t e a \ r u n - r e c o r d " , d e n e d b e l o w , w i t h e v e r y r u n f o r m e d i n c o u r s e o f o u r m e r g e s o r t a l g o r i t h m . E a c h r u n -  

r e c o r d c o n t a i n s a p o i n t e r t o t h e s t a r t a n d e n d o f i t s r u n ' s p h y s i c a l s e q u e n c e o n d i s k . T h e q u e u e   Q  o f r u n s d e n e d i n  

S e c t i o n 5 . 5 . 2 i s , i n f a c t , i m p l e m e n t e d a s a q u e u e o f r u n - r e c o r d s .  

A t a n y t i m e t h e \ s t a t e " o f   M A M e r g e   c o n s i s t s o f a s e t o f m e r g e o p e r a t i o n s t h a t c a n c o l l e c t i v e l y b e v i e w e d a s  

a n a d a p t i v e r e - o r g a n i z a t i o n o f t h e o r i g i n a l     - w a y m e r g e t h a t   M A M e r g e   s e t s o u t t o c o m p u t e . L i n k e d i m p l i c i t l y t o  

e a c h s u c h m e r g e o p e r a t i o n i n t h e s t a t e o f   M A M e r g e   i s a  r u n - r e c o r d   d e n e d b e l o w : C o n s i d e r , f o r e x a m p l e , m e r g i n g  

a s e t   P  o f r u n s   r 

; r 

; : : : ; r  

p    1 

, w h e r e    p  =  j  P  j  , i n t o t h e r u n   r  a n d s u p p o s e t h a t    p  = 2 

 ̀

f o r a n o n - n e g a t i v e i n t e g e r  

1 0 6 

Page 120: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 120/203

 ̀ . I n o u r s c h e m e , w e e n s u r e t h a t t h e n u m b e r o f r u n s i n a l l m e r g e o p e r a t i o n s i n   M A M e r g e  ' s s t a t e i s a l w a y s o f t h e  

f o r m 2  

, w h e r e   x  i s a n o n - n e g a t i v e i n t e g e r . A l g o r i t h m   M A M e r g e   m a i n t a i n s a r u n - r e c o r d   r r  a s s o c i a t e d w i t h t h e  

o u t p u t r u n   r  . R u n - r e c o r d   r r  c o n t a i n s p o i n t e r s t o t h e l e a d i n g a n d t r a i l i n g d i s k b l o c k s o f r u n   r  , i f a n y , a n d t o a l i s t  

o f t h e r u n - r e c o r d s   r r 

a s s o c i a t e d w i t h t h e r u n s   r 

2  P  . T h u s w h e n e v e r w e w i s h t o w o r k o n t h e m e r g e o p e r a t i o n  

w h o s e o u t p u t i s r u n   r  , w e c a n d o s o b y u s i n g t h e r u n - r e c o r d s   r r 

t o g e t p o i n t e r s t o b l o c k s o f t h e r u n s   r 

W e 

a p p e n d t h e m e r g e o u t p u t t o t h e t r a i l i n g d i s k b l o c k o f r u n   r  p o i n t e d t o b y   r r  . I n g e n e r a l , t h e r u n s   r 

2  P  c a n 

t h e m s e l v e s b e r u n s t h a t c o r r e s p o n d t o t h e o u t p u t s o f s o m e o t h e r m e r g e o p e r a t i o n s . M o r e i m p o r t a n t l y , t h e d e s i g n o f  

a l g o r i t h m   M A M e r g e   e a s i l y h a n d l e s s i t u a t i o n s i n w h i c h t h e f o r m a t i o n o f a r u n   r 

2  P  m a y n o t b e l o g i c a l l y c o m p l e t e ,  

i n t h e s e n s e o f D e n i t i o n 2 4 . A l g o r i t h m   M A M e r g e   h a s t h e e x i b i l i t y o f i m p l e m e n t i n g t h e    p  - w a y m e r g e l i n k e d t o  

r r  b y r e c u r s i v e l y s p l i t t i n g i t i n t o  

 p  - w a y m e r g e o p e r a t i o n s : T h e r u n - r e c o r d   r r  s t o r e s a p o i n t e r t o a l i s t o f  

 p  r u n -  

r e c o r d s   r r 

;  r r 

; : : : ;  r r 

p    1 

a s s o c i a t e d w i t h t h e r u n s   r 

; r 

; : : : ; r  

p    1 

s u c h t h a t r u n   r  i s l o g i c a l l y t h e o u t p u t o f t h e  

 p  - w a y m e r g e o f r u n s   r 

; r 

; : : : ; r  

p    1 

, a n d e a c h r u n   r 

i s l o g i c a l l y t h e o u t p u t o f t h e  

 p  - w a y m e r g e o f t h e r u n s  

; r 

p  + 1 

; : : : ; r  

(  i  + 1 ) 

  1 

B e l o w w e g i v e a p r e c i s e d e n i t i o n o f t h e e l d s t h a t f o r m a r u n - r e c o r d . I t i s u s e f u l t o s e p a r a t e t h e l o g i c a l n o t i o n  

o f a r u n f r o m t h e w a y i t m a y a c t u a l l y e x i s t o n d i s k a t a n y t i m e .  

D e n i t i o n 3 1   I n o u r s c h e m e , t h e p h y s i c a l s e q u e n c e   q  (  r ; t  ) a t a n y t i m e   t  o f a r u n   r  i s s t o r e d i n a b l o c k e d m a n n e r o n  

d i s k .  

B e f o r e d e n i n g t h e r e c u r s i v e r u n - r e c o r d d a t a s t r u c t u r e , w e d e n e t h e v a r i o u s e l d s o f a r u n - r e c o r d .  

D e n i t i o n 3 2   T h e e l d s o f a r u n - r e c o r d a s s o c i a t e d w i t h a r u n   r 

a r e a s f o l l o w s :  

1 b e g i n   : A t a n y t i m e   t  , t h e   b e g i n   e l d p o i n t s t o t h e l e a d i n g e l e m e n t o f t h e p h y s i c a l s e q u e n c e   q  (  r 

; t  ) , a s s u m i n g  

q  (  r 

; t  ) i s n o n - e m p t y , o n d i s k .  

2 e n d  : A t a n y t i m e   t  , t h e   e n d  e l d p o i n t s t o t h e t r a i l i n g e l e m e n t o f t h e p h y s i c a l s e q u e n c e   q  (  r 

; t  ) , a s s u m i n g   q  (  r 

; t  ) 

i s n o n - e m p t y , o n d i s k .  

3 O r d e r  : A n i n t e g e r e l d .  

4 i n p u t s   : T h e   i n p u t s   e l d p o i n t s t o t h e d i s k l o c a t i o n o f t h e l e a d i n g r u n - r e c o r d o f a l i s t o f   O r d e r   r u n - r e c o r d s  

s t o r e d i n a b l o c k e d m a n n e r o n d i s k . T h e   i n p u t s   e l d i m p l i c i t l y r e p r e s e n t s t h i s b l o c k e d l i s t o f   O r d e r   r u n - r e c o r d s  

s o w e s o m e t i m e s r e f e r t o t h e p o i n t e r   i n p u t s   a s a l i s t o f r u n - r e c o r d s . T h i s l i s t o f r u n - r e c o r d s m a y a c t u a l l y e x i s t  

a s a s u b - l i s t o f a l a r g e r b l o c k e d l i s t o f r u n - r e c o r d s o n d i s k .  

5 a g  : T h e   a g  e l d r e c o r d s w h e t h e r o r n o t t h e f o r m a t i o n o f r u n   r 

i s l o g i c a l l y c o m p l e t e , a s i n D e n i t i o n 2 4 .  

A c c o r d i n g l y ,   a g  i s s e t t o   D o n e   o r  N o t D o n e   r e s p e c t i v e l y . T h e   a g  e l d o f t h e r u n - r e c o r d a s s o c i a t e d w i t h a n y  

r u n i n p u t t o   M A M e r g e   i s i n i t i a l i z e d t o   D o n e  

1 0 7 

Page 121: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 121/203

6 s p l i t t e r s   : T h e   s p l i t t e r s   e l d p o i n t s t o t h e d i s k l o c a t i o n o f t h e l e a d i n g r u n - r e c o r d o f a l i s t o f  

O r d e r   r u n - r e c o r d s  

s t o r e d i n a b l o c k e d m a n n e r o n d i s k . T h e   s p l i t t e r s   p o i n t e r i m p l i c i t l y r e p r e s e n t s t h e b l o c k e d l i s t o f  

O r d e r  

r u n - r e c o r d s .  

E a c h r u n - r e c o r d o c c u p i e s o n l y   O  ( 1 ) a m o u n t o f s p a c e , w h i c h i s p r o p o r t i o n a l t o   O  ( 1  = B  ) d i s k b l o c k s .  

D e n i t i o n 3 3   I f r u n   r  i s o n e o f t h e     i n p u t r u n s o f   M A M e r g e  , t h e n i n t h e r u n - r e c o r d   r r  a s s o c i a t e d w i t h   r  , w e 

h a v e   r r  O r d e r   = 1 a n d   r r  i n p u t s   =  r r  s p l i t t e r s   =  n i l  . O n t h e o t h e r h a n d s u p p o s e t h a t r u n   r  i s l o g i c a l l y t h e r u n  

c o r r e s p o n d i n g t o t h e o u t p u t o f t h e m e r g e o f t h e r u n s   r 

, w h e r e 0     i     p    1 a n d    p  = 2 

 ̀

f o r a n o n - n e g a t i v e i n t e g e r    ̀ , 

a n d  r r 

i s t h e r e c u r s i v e l y d e n e d r u n - r e c o r d a s s o c i a t e d w i t h r u n   r 

. T h e n g i v e n a r u n - r e c o r d   r r  a t a n y t i m e , w e s a y  

r r  = 

_  

f  r r 

;  r r 

; : : : ;  r r 

p    1 

i f a n d o n l y i f t h e f o l l o w i n g c o n d i t i o n s a r e s a t i s e d :  

1 r r  O r d e r   =   p 

2 . T h e l i s t   r r  i n p u t s   c o n t a i n s p r e c i s e l y t h e    p  r u n - r e c o r d s   r r 

;  r r 

; : : : ;  r r 

p    1 

3 . T h e l i s t   r r  s p l i t t e r s   c o n t a i n s  

 p  r u n - r e c o r d s   r r 

, w h e r e 0     j   

 p    1 , s u c h t h a t   r r 

W  

f  r r 

;  r r 

p  + 1 

; : : : ;  r r 

(  j  + 1 ) 

p    1 

W e s a y t h a t t h e c o m p u t a t i o n a s s o c i a t e d w i t h r u n - r e c o r d   r r  i s t h e c o m p u t a t i o n i n v o l v e d i n m e r g i n g t h e r u n s a s s o c i a t e d  

w i t h t h e   r r  O r d e r   r u n - r e c o r d s i n   r r  i n p u t s   t o p r o d u c e b l o c k s a p p e n d e d t o t h e p h y s i c a l s e q u e n c e o f r u n   r  a s s o c i a t e d  

w i t h   r r 

A l t h o u g h t h e d e n i t i o n o f a r u n - r e c o r d i s r e c u r s i v e , w e d o n o t e m p l o y r e c u r s i o n t o c o n s t r u c t a r u n - r e c o r d   r r  s u c h  

t h a t   r r  = 

W  

f  r r 

;  r r 

; : : : ;   r r 

p    1 

g  , g i v e n t h e r u n - r e c o r d s   r r 

D e n i t i o n 3 4   G i v e n a b l o c k e d l i s t   L 

o f   p  = 2 

 ̀

r u n - r e c o r d s   r r 

;  r r 

; : : : ;   r r 

p    1 

, w h e r e    ̀ i s a n o n - n e g a t i v e i n t e g e r ,  

t h e c o n s t r u c t i o n o f a r u n - r e c o r d   r r  s a t i s f y i n g t h e c o n d i t i o n   r r  = 

W  

f  r r 

j  0    j     p    1  g  i s c a l l e d a   c o n s t r u c t   (  r r  ; L 

o p e r a t i o n .  

T h e  c o n s t r u c t  (  r r  ; L 

) o p e r a t i o n c a n b e i m p l e m e n t e d b y s u c c e s s i v e l y c o n s t r u c t i n g a s e q u e n c e o f    ̀ b l o c k e d l i s t s   L 

o f r u n - r e c o r d s , f o r 0     i     ̀   1 a n d t h e n s e t t i n g   r r  i n p u t s   t o b e t h e l i s t   L 

a n d  r r  s p l i t t e r s   t o b e t h e l i s t   L 

 ̀   1 

I n 

g e n e r a l , t h e b l o c k e d l i s t s   L 

a r e c o n s t r u c t e d s o a s t o s a t i s f y t h e t h e f o l l o w i n g c o n d i t i o n s :  

1 . L i s t   L 

i s a b l o c k e d l i s t c o n t a i n i n g    p =  2 

r u n - r e c o r d s , w h i c h w e d e n o t e   r r  (  i ; j  ) , w h e r e 0     j     p =  2 

  1

1 0 8 

Page 122: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 122/203

2 . T h e   j  t h r u n - r e c o r d   r r  (  i ; j  ) i n l i s t   L 

, w h e r e 0     i     ̀   1 a n d 0     j     p =  2 

  1 , s a t i s e s   r r  (  i ; j  )  O r d e r   = 2 

a n d 

t h e l i s t   r r  (  i ; j  )  i n p u t s   c o n s i s t s o f t h e 2  

r u n - r e c o r d s   r r 

j x 

;  r r 

j x  + 1 

; : : : ;   r r 

(  j  + 1 )  x    1 

, o f l i s t   L 

, w h e r e   x  = 2 

3 . C o n s i d e r a r u n - r e c o r d   r r  (  i ; j  ) , w h e r e 1     i     ̀   1 a n d 0     j     p =  2 

  1 , f r o m a n y l i s t o t h e r t h a n l i s t   L 

L e t  x  d e n o t e 2  

. T h e n , t h e  

x  = 2 

i    1 

r u n - r e c o r d s i n t h e l i s t   r r  (  i ; j  )  s p l i t t e r s   a r e p r e c i s e l y t h e r u n - r e c o r d s  

r r  (  i    1  ; j 

x  )  ;  r r  (  i    1  ; j 

x  + 1 )  ; : : : ;   r r  (  j  + 1 ) 

x    1 , o f l i s t   L 

i    1 

. E a c h r u n - r e c o r d i n l i s t   L 

h a s i t s   s p l i t t e r s  

e l d s e t t o   n i l 

4 . T h e e l d s   r r  i n p u t s   a n d  r r  s p l i t t e r s   a r e s e t s o t h a t   r r  i n p u t s   r e p r e s e n t s l i s t   L 

a n d  r r  s p l i t t e r s   r e p r e s e n t s l i s t  

 ̀   1 

5 . T h e   a g  e l d s o f a l l r u n - r e c o r d s o f t h e l i s t s   L 

; L 

; : : : ; L  

 ̀   1 

a n d t h e r u n - r e c o r d   r r  a r e s a i d t o   N o t D o n e  ; t h e  

b e g i n   a n d  e n d  e l d s o f t h e s e r u n - r e c o r d s a r e s e t t o   n i l  i n d i c a t i n g t h a t t h e i r r e s p e c t i v e p h y s i c a l s e q u e n c e s a t  

t h a t t i m e a r e a l l e m p t y .  

I t c a n b e i n d u c t i v e l y s h o w n t h a t t h e a b o v e c o n d i t i o n s i m p l y f o r 0     i     ̀   1 a n d 0     j    x    1 t h a t  

r r  (  i ; j  ) = 

_  

f  r r 

j x 

;  r r 

j x  + 1 

; : : : ;  r r 

(  j  + 1 )  x    1 

w h e r e   x  = 2 

. T h i s m e a n s t h a t   r r  = 

W  

f  r r 

j  0    k     p    1  g  , a s d e s i r e d .  

I f t h e l i s t s   L 

a r e c o n s t r u c t e d i n a s c e n d i n g o r d e r o f   i  , t h e n a l l t h e r u n - r e c o r d s o f t h e b l o c k e d l i s t   L 

c a n b e  

c o n s t r u c t e d i n a s i n g l e t r a v e r s a l o f l i s t   L 

i    1 

f o r  i >  0 a n d l i s t   L 

f o r  i  = 0 : F o r   i >  0 , S t e p 2 a b o v e i s i m p l e m e n t e d  

b y s e t t i n g   r r  (  i ; j  )  i n p u t s   t o b e e q u a l t o t h e ( v a l u e o f ) t h e e l d   r r  (  i    1  ; j  2 

i    1 

)  i n p u t s   a n d  r r  (  i ; j  )  s p l i t t e r s   t o s t o r e  

t h e d i s k l o c a t i o n o f t h e r u n - r e c o r d   r r  (  i    1  ; j  2 

i    1 

) . T h e f o l l o w i n g l e m m a f o l l o w s f r o m t h e f a c t t h a t t h e t o t a l n u m b e r  

o f r u n - r e c o r d s s u m m e d o v e r a l l t h e l i s t s   L 

a n d l i s t   L 

i s  O  (   p  ) a n d t h a t c o n s t r u c t i n g e a c h l i s t   L 

r e q u i r e s n o m o r e  

t h a n   O  ( 1 ) b l o c k s o f i n t e r n a l m e m o r y .  

L e m m a 2 7   T h e t o t a l n u m b e r o f I / O o p e r a t i o n s i n c u r r e d b y a c o n s t r u c t  (  r r  ; L 

)  o p e r a t i o n , w h e r e   L 

i s a b l o c k e d  

l i s t o f    p  r u n - r e c o r d s , i s   O  (   p = B   + l g l g    p  ) =  O  (   p  )  . T h e t o t a l n u m b e r o f m e m o r y b l o c k s r e q u i r e d t o i m p l e m e n t  

c o n s t r u c t  (  r r  ; L 

)  i s  O  ( 1 ) 

A n o t h e r u s e f u l o b s e r v a t i o n i s e x p r e s s e d b y t h e f o l l o w i n g l e m m a .  

L e m m a 2 8   T h e t o t a l n u m b e r o f n e w r u n - r e c o r d s c r e a t e d b y c o n s t r u c t  (  r r  ; L 

)  , w h e r e   L 

c o n t a i n s    p  r u n - r e c o r d s i s  

O  (   p  ) 

1 0 9 

Page 123: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 123/203

D u r i n g t h e p r e p r o c e s s i n g s t a g e o f   M A M e r g e  , w e e x e c u t e a   c o n s t r u c t   (  r r  ; L 

0  ) o p e r a t i o n i n w h i c h t h e n u m b e r    p 

o f r u n - r e c o r d s i n   L 

0  i s n o t o f t h e f o r m 2  

 ̀

b u t r a t h e r o f t h e f o r m   w  2 

 ̀

, w h e r e   w  i s a n o n - n e g a t i v e i n t e g e r l e s s t h a n  

 ̀

. I n t h i s c a s e t h e a b o v e p r o c e d u r e c a n b e m o d i e d s o t h a t t h e n u m b e r o f r u n - r e c o r d s i n l i s t   L 

 ̀   1 

i s  w  , i n s t e a d o f  

 p 

. H o w e v e r , t h e c o n d i t i o n t h a t   r r  = 

W  

f  r r 

j  r r 

2  L 

0  g  r e m a i n s s a t i s e d .  

C o r o l l a r y 4   T h e t o t a l n u m b e r o f I / O o p e r a t i o n s i n c u r r e d b y t h e c o n s t r u c t  (  r r  ; L 

0  )  o p e r a t i o n d e s c r i b e d i n t h e a b o v e  

p a r a g r a p h , i n w h i c h   L 

0  i s a b l o c k e d l i s t o f    p 

=  w  2 

 ̀

r u n - r e c o r d s a n d   w  i s a p o s i t i v e i n t e g e r l e s s t h a n   2 

 ̀

, i s n o  

m o r e t h a n   O  (   p 

= B  + l g l g    p 

)  , w h i c h i s   O  (   p 

)  . T h e t o t a l n u m b e r o f m e m o r y b l o c k s r e q u i r e d i n t h e i m p l e m e n t a t i o n i s  

O  ( 1 ) 

5 . 8 . 3 P r e p r o c e s s i n g  

H a v i n g d e n e d r u n - r e c o r d s a n d t h e   c o n s t r u c t   ( ) o p e r a t i o n , w e n o w d e s c r i b e t h e p r e p r o c e s s i n g c a r r i e d o u t b y   M A M e r g e  

b e f o r e i t s t a r t s m e r g i n g . F i r s t w e i n t r o d u c e s o m e t e r m i n o l o g y t h a t w e w i l l b e u s i n g t h r o u g h o u t t h e n e x t t w o s e c t i o n s .  

D e n i t i o n 3 5   T h e n u m b e r o f r u n s m e r g e d b y a n a p p l i c a t i o n o f  M A M e r g e   i s g i v e n b y  

  = m i n  

d  l g l g (  m 

m a x 

=  

l e v e l  

)  e 

;  j Q j 

w h e r e   j Q j  i s t h e n u m b e r o f r u n s i n l i s t   Q  a t t h e b e g i n n i n g o f t h a t a p p l i c a t i o n o f   M A M e r g e  . W e u s e    ̀

m a x 

t o d e n o t e  

t h e i n t e g e r   d  l g l g     e  , a n d     t o d e n o t e t h e i n t e g e r 2  

 ̀

m a x 

T h e v a l u e o f     f o r e a c h a p p l i c a t i o n o f   M A M e r g e  , i n o u r f r a m e w o r k i s s u c h t h a t , e x c e p t p e r h a p s i n t h e n a l  

a p p l i c a t i o n o f   M A M e r g e  , w e h a v e    ̀

m a x 

=   ̀

m a x 

=  d  l g l g (  m 

m a x 

=  

l e v e l  

)  e  a n d    =   

D u r i n g t h e n a l a p p l i c a t i o n o f   M A M e r g e  , i t i s p o s s i b l e t h a t   <   , i n w h i c h c a s e , i t i s c o n v e n i e n t t o i n t r o d u c e  

s o m e d u m m y  

r u n - r e c o r d s t o t h e l i s t o f r u n - r e c o r d s c o r r e s p o n d i n g t o r u n s b e i n g m e r g e d . A d d i n g d u m m y r u n - r e c o r d s  

e n a b l e s u s t o m a k e t h e c o n v e n i e n t a s s u m p t i o n t h a t t h a t t h e n u m b e r o f r u n - r e c o r d s i n t h e l i s t   r r 

i n p u t s   o f a n y  

r u n - r e c o r d   r r 

i s a l w a y s o f t h e f o r m 2  

 ̀

f o r i n t e g r a l    ̀ I f  <   , o n e p o s s i b i l i t y i s t o a d d         d u m m y r u n - r e c o r d s ,  

b u t t h i s c a n b e e x t r e m e l y i n e c i e n t s i n c e     c a n b e a s h i g h a s (   

) . S o w e r s t a d d e n o u g h d u m m y r u n - r e c o r d s  

t o o b t a i n a t o t a l o f   w  

1  =  2 

r u n - r e c o r d s , w h e r e   w  i s a n i n t e g e r n o l a r g e r t h a n    

1  =  2 

. T h e n a f t e r r u n n i n g t h e m o d i e d  

v e r s i o n o f t h e   c o n s t r u c t  ( ) o p e r a t i o n a l l u d e d t o i n C o r o l l a r y 4 , w e a d d s o m e m o r e d u m m y r u n - r e c o r d s a p p r o p r i a t e l y  

t o e n s u r e t h a t , a f t e r p r e p r o c e s s i n g , t h e n u m b e r o f r u n - r e c o r d s i n t h e l i s t   r r 

i n p u t s   o f a n y r u n - r e c o r d   r r 

i s o f t h e  

f o r m 2  

 ̀

w h i l e m a i n t a i n i n g t h e c o n d i t i o n t h a t t h e n u m b e r o f d u m m y r u n - r e c o r d s a d d e d i s   O  (    )

W e e x e c u t e t h e f o l l o w i n g s t e p s d u r i n g t h e p r e p r o c e s s i n g s t a g e o f   M A M e r g e   i n o u r f r a m e w o r k .  

W e d e n e t h e r u n a s s o c i a t e d w i t h a d u m m y r u n - r e c o r d i n S e c t i o n 5 . 9 .  

1 1 0 

Page 124: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 124/203

1 . C o p y t h e     l e a d i n g r u n - r e c o r d s f r o m   j Q j  i n t o a n e w b l o c k e d l i s t   L  o f r u n - r e c o r d s a n d r e m o v e t h e s e r u n - r e c o r d s  

f r o m   Q 

2 . A p p e n d a t m o s t    

1  =  2 

  1 d u m m y r u n - r e c o r d s t o t h e e n d o f  L  s o t h a t t h e n u m b e r o f r u n - r e c o r d s i n   L  i s  w  

1  =  2 

f o r a n o n - n e g a t i v e i n t e g e r   w 

3 . E x e c u t e a m o d i e d v e r s i o n o f t h e   c o n s t r u c t  (  r r 

; L  ) o p e r a t i o n ( a l l u d e d t o i n C o r o l l a r y 4 ) o n t h e b l o c k e d l i s t   L 

c o n t a i n i n g   w  

1  =  2 

r u n - r e c o r d s . T h e b l o c k e d l i s t   r r 

s p l i t t e r s   , d e n o t e d   L 

, c o n t a i n s   w  r u n - r e c o r d s .  

4 . D i s c a r d r u n - r e c o r d   r r 

a n d a p p e n d l e s s t h a n    

1  =  2 

d u m m y r u n - r e c o r d s t o   L 

s o t h a t   L 

n o w c o n t a i n s   w 

r u n -  

r e c o r d s , w h e r e   w 

i s t h e s m a l l e s t i n t e g e r s u c h t h a t   w 

  w  a n d  w 

= 2 

   

1  =  2 

f o r a n i n t e g r a l   x 

5 . E x e c u t e a   c o n s t r u c t  (  r r  ; L 

) o p e r a t i o n o n t h e b l o c k e d l i s t   L 

c o n t a i n i n g   w 

r u n - r e c o r d s .  

T h e r u n - r e c o r d   r r  c o n s t r u c t e d i n S t e p 5 h a s   r r  i n p u t s   p o i n t i n g t o a b l o c k e d l i s t o f   w 

r u n - r e c o r d s   r r 

, w h e r e  

0    j    w 

  1 . W i t h o n e p o s s i b l e e x c e p t i o n , t h e b l o c k e d l i s t   r r 

i n p u t s   o f e a c h n o n - d u m m y r u n - r e c o r d   r r 

o f l i s t  

r r  i n p u t s   c o n t a i n s a u n i q u e s e t o f    

1  =  2 

r u n - r e c o r d s f r o m t h e s e t o f     r u n - r e c o r d s a s s o c i a t e d w i t h r u n s   M A M e r g e   s e t s  

o u t t o m e r g e ; o n e n o n - d u m m y r u n - r e c o r d o f l i s t   r r  i n p u t s   m a y p o s s i b l y c o n t a i n t h e d u m m y r u n - r e c o r d s i n t r o d u c e d  

i n S t e p 2 . T h e u n i o n o f t h e s e t s r e p r e s e n t e d b y t h e l i s t s   r r 

i n p u t s   i n c l u d e s t h e     r u n - r e c o r d s c o r r e s p o n d i n g t o r u n s  

i n p u t t o   M A M e r g e   a n d t h u s , t h e r u n a s s o c i a t e d r u n - r e c o r d   r r  i s l o g i c a l l y t h e r u n c o r r e s p o n d i n g t o a m e r g e o f t h e    

i n p u t r u n s .  

L e m m a 2 7 a n d C o r o l l a r y 4 a b o v e i m p l y t h e f o l l o w i n g l e m m a .  

L e m m a 2 9   T h e t o t a l n u m b e r o f I / O o p e r a t i o n s i n c u r r e d d u r i n g t h e p r e p r o c e s s i n g s t a g e i s n o m o r e t h a n   O  (  = B  + 

 ̀

m a x 

)  , w h i c h i s   O  (    )  . T h e t o t a l n u m b e r o f m e m o r y b l o c k s r e q u i r e d t o i m p l e m e n t t h e p r e p r o c e s s i n g i s   O  ( 1 )  . T h e t o t a l  

n u m b e r o f n e w r u n - r e c o r d s c r e a t e d d u r i n g t h e p r e p r o c e s s i n g s t a g e , i n c l u d i n g d u m m y r u n - r e c o r d s i s   O  (   

1  =  2 

) =  O  (    ) 

T h e f o l l o w i n g d e n i t i o n s r e f e r t o v a r i a b l e s m a i n t a i n e d a n d u s e d b y   M A M e r g e  

D e n i t i o n 3 6   T h e a l g o r i t h m   M A M e r g e   m a i n t a i n s a v a r i a b l e   r r 

g l o b a l  

s t o r i n g a s p e c i a l r u n - r e c o r d . A t t h e e n d o f  

S t e p 5 a b o v e , w e i n i t i a l i z e   r r 

g l o b a l  

t o t h e r u n - r e c o r d   r r  r e s u l t i n g f r o m t h e e x e c u t i o n o f t h e   c o n s t r u c t   (  r r  ; L 

) o p e r a t i o n .  

W e u s e   W 

t o p 

t o d e n o t e t h e n u m b e r o f n o n - d u m m y r u n - r e c o r d s i n t h e l i s t   r r 

g l o b a l  

i n p u t s   i m m e d i a t e l y a f t e r S t e p 5 o f  

t h e p r e p r o c e s s i n g c o m p l e t e s .  

T h r o u g h o u t   M A M e r g e  ' s e x e c u t i o n , t h e v a r i a b l e   r r 

g l o b a l  

s t o r e s t h e r u n - r e c o r d w h o s e r u n i s l o g i c a l l y t h e m e r g e o f  

a l l t h e     r u n s i n p u t t o   M A M e r g e  

1 1 1 

Page 125: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 125/203

5 . 8 . 4 L e v e l - r e c o r d D a t a S t r u c t u r e  

W e n o w d e s c r i b e t h e \ l e v e l - r e c o r d " d a t a s t r u c t u r e t h a t a s s o c i a t e s w i t h e a c h l e v e l    ̀ , w h e r e 1      ̀    ̀

m a x 

, a m e r g e  

o p e r a t i o n a p p r o p r i a t e f o r l e v e l    ̀ . A l e v e l - r e c o r d s t o r e s a p o i n t e r t o a r u n - r e c o r d t o g e t h e r w i t h s o m e s u p p l e m e n t a r y  

i n f o r m a t i o n .  

D e n i t i o n 3 7   E v e r y a l l o c a t i o n l e v e l    ̀ , w h e r e 1      ̀    ̀

m a x 

, i s a s s o c i a t e d w i t h i t s   l e v e l - r e c o r d   , d e n o t e d   l r     ̀ ] . L e v e l -  

r e c o r d   l r     ̀ ] i s e i t h e r   n i l  o r i t c o m p r i s e s o f t h e f o l l o w i n g t h r e e e l d s :  

1 r r  : T h e   r r  e l d s t o r e s t h e l o c a t i o n o f a r u n - r e c o r d w h i c h c a n b e v i e w e d a s a r e p o s i t o r y o f c o m p u t a t i o n t h a t  

m a y c a r r i e d o u t a t l e v e l    ̀

2 c u r r e n t   : T h e   c u r r e n t   e l d s t o r e s a n o n - n e g a t i v e i n t e g e r .  

3 a c t i v e   : T h e   a c t i v e   e l d i s a p o i n t e r t o a r u n - r e c o r d w h i c h w e c a l l t h e   a c t i v e r u n - r e c o r d   o f l e v e l    ̀ a n d d e n o t e b y  

r r 

 ̀

, i n s h o r t . T h e m e r g e o p e r a t i o n a s s o c i a t e d w i t h r u n - r e c o r d   r r 

 ̀

i s a l w a y s a m e r g e o p e r a t i o n a p p r o p r i a t e f o r  

l e v e l    ̀

L e v e l - r e c o r d s   l r  1 ] t h r o u g h   l r     ̀

m a x 

] a r e s t o r e d i n a b l o c k e d l i s t s o t h e y o c c u p y   O  (   ̀

m a x 

= B  + 1 ) d i s k b l o c k s i n t o t a l .  

B y \ c o m p u t a t i o n a s s o c i a t e d w i t h l e v e l    ̀ " w e r e f e r t o t h e m e r g e o p e r a t i o n a s s o c i a t e d w i t h r u n - r e c o r d   r r 

 ̀

I m m e d i a t e l y u p o n c o m p l e t i o n o f t h e p r e p r o c e s s i n g o f   M A M e r g e  , a l l l e v e l - r e c o r d s e x c e p t   l r     ̀

m a x 

] a r e i n i t i a l i z e d t o  

n i l  . L e v e l r e c o r d   l r     ̀

m a x 

] i s i n i t i a l i z e d a s f o l l o w s : I t s   r r  e l d i s s e t t o r u n - r e c o r d   r r 

g l o b a l  

, i t s   c u r r e n t   e l d i s s e t t o 0  

a n d i t s   a c t i v e   e l d i s s e t t o t h e s a m e v a l u e a s   r r 

g l o b a l  

i n p u t s   ( w h i c h p o i n t s t o t h e r s t r u n - r e c o r d i n t h e b l o c k e d l i s t  

i m p l i c i t l y r e p r e s e n t e d b y   r r 

g l o b a l  

i n p u t s   ) 

T h e f o l l o w i n g d e n i t i o n r e f e r s t o a v a r i a b l e m a i n t a i n e d a n d u s e d b y   M A M e r g e  

D e n i t i o n 3 8   T h r o u g h o u t i t s o p e r a t i o n ,   M A M e r g e   m a i n t a i n s a s p e c i a l v a r i a b l e   m a x l e v e l   i n i t i a l i z e d t o    ̀

m a x 

T h e v a l u e o f  m a x l e v e l   i s a l w a y s s u c h t h a t   l r    m a x l e v e l  ]  r r  =  r r 

g l o b a l  

5 . 8 . 5 I n v a r i a n t s f o r r u n - r e c o r d s a n d l e v e l - r e c o r d s  

W e n o w p r e s e n t t h e i n v a r i a n t s p e r t a i n i n g t o r u n - r e c o r d s a n d l e v e l - r e c o r d s m a i n t a i n e d b y   M A M e r g e  . T h e i n v a r i a n t s  

h o l d i m m e d i a t e l y a f t e r p r e p r o c e s s i n g i s c o m p l e t e d a n d a f t e r e a c h   l l m e r g e   ( ) a n d   d o w n l o a d   ( ) o p e r a t i o n d u r i n g  

M A M e r g e  ' s e x e c u t i o n .  

I n t h e i n v a r i a n t s s p e c i e d b e l o w , w e u s e t h e f o l l o w i n g v a r i a b l e s a n d s h o r t e n e d n a m e s .  

D e n i t i o n 3 9   B y   ̀ , w e d e n o t e a n i n t e g e r s u c h t h a t 1      ̀    ̀

m a x 

. W e u s e   c u r r e n t   t o d e n o t e t h e e l d   l r     ̀ ]  c u r r e n t  

o f l e v e l - r e c o r d   l r     ̀ ] ,  r r  t o d e n o t e   l r     ̀ ]  r r  ,  m  t o d e n o t e   l r     ̀ ]  r r  O r d e r  , a n d   a c t i v e   t o d e n o t e   l r     ̀ ]  a c t i v e   B y  r r 

, w h e r e  

0    i    m    1 , w e d e n o t e t h e   i  t h r u n - r e c o r d i n t h e l i s t   r r  i n p u t s   o f  m  r u n - r e c o r d s .  

I n c a s e o f t h e i n v a r i a n t s b e l o w t h a t r e f e r t o l e v e l - r e c o r d   l r     ̀ ] , i t i s o b v i o u s l y a s s u m e d t h a t   l r     ̀ ] i s n o t   n i l 

1 1 2 

Page 126: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 126/203

I n v a r i a n t s  

1 1    m a x l e v e l      ̀

m a x 

2 . T h e r u n a s s o c i a t e d w i t h r u n - r e c o r d   r r 

g l o b a l  

i s a l w a y s t h e r u n c o r r e s p o n d i n g t o t h e o u t p u t o f t h e m e r g e o f    

r u n s i n p u t t o   M A M e r g e  

3 . I f   m a x l e v e l   <  ̀    ̀

m a x 

, t h e n l e v e l - r e c o r d   l r     ̀ ] =  n i l 

4 l r    m a x l e v e l  ]  r r  s t o r e s t h e l o c a t i o n o f r u n - r e c o r d   r r 

g l o b a l  

5 r r  a g  i s s e t t o   N o t D o n e  

6 . W e h a v e 0     c u r r e n t     m  . F o r t h e c a s e    ̀ =   ̀

m a x 

c u r r e n t   62 f  W 

t o p 

;  W 

t o p 

+ 1  ; : : : ; m     1  g 

7 . I f   c u r r e n t   < m  t h e n t h e r u n - r e c o r d   r r 

 ̀

p o i n t e d t o b y   a c t i v e   i s t h e   c u r r e n t   - t h r u n - r e c o r d   r r 

c u r r e n t  

i n t h e l i s t  

r r  i n p u t s   , o t h e r w i s e r u n - r e c o r d   r r 

 ̀

i s t h e r u n - r e c o r d   r r  i t s e l f .  

8 . I f    ̀ =  m a x l e v e l  , t h e n   m  = 2 

, w h e r e   x  i s a n i n t e g e r n o l a r g e r t h a n    ̀   1

9 . I f   ` <  m a x l e v e l  , t h e n   m  = 2 

 ̀   1 

1 0 . E a c h o n e o f t h e   m    c u r r e n t   r u n - r e c o r d s   r r 

, w h e r e   c u r r e n t     i    m    1 , h a s   r r 

a g  s e t t o   N o t D o n e   a n d 

r r 

O r d e r   s e t t o 2  

 ̀   1 

. I n t h e s p e c i c c a s e o f    ̀ =  m a x l e v e l   =   ̀

m a x 

, t h i s i n v a r i a n t h o l d s f o r t h e n o n - d u m m y  

r u n - r e c o r d s   r r 

, w h e r e   c u r r e n t     i    W 

t o p 

  1 o f t h e l i s t   r r  i n p u t s  

1 1 . C o n s i d e r t h e o r d e r e d l i s t   S 

 ̀

o f r u n - r e c o r d s o b t a i n e d a s f o l l o w s : F i r s t c o n c a t e n a t e t o g e t h e r t h e l i s t s   r r 

i n p u t s  

o f t h e r u n - r e c o r d s   r r 

, w h e r e   c u r r e n t     i    m    1 , i n i n c r e a s i n g o r d e r o f   i  t o o b t a i n t h e l i s t   S 

. T h e n l i s t   S 

 ̀

i s o b t a i n e d b y a p p e n d i n g t h e o r d e r e d l i s t   r r 

;  r r 

; : : : ;   r r 

c u r r e n t    1 

o f r u n - r e c o r d s t o t h e t a i l o f l i s t   S 

. L e t t h e  

e l e m e n t s , i n o r d e r , o f l i s t   S 

 ̀

b e  s 

; s 

; : : : ; s  

j  S 

 ̀

, w h e r e   j  S 

 ̀

j  d e n o t e s t h e n u m b e r o f r u n - r e c o r d s i n   S 

 ̀

( a ) A t m o s t    ̀   1 r u n - r e c o r d s o f   S 

 ̀

e i t h e r h a v e t h e i r   a g  e l d s e t t o   N o t D o n e  

( b ) C o n s i d e r a r u n - r e c o r d   s  2  S 

 ̀

, w i t h   s a g  =  N o t D o n e  . T h e n t h e r e i s p r e c i s e l y o n e l e v e l    ̀

, w h e r e 0   <  ̀

<  ̀ , 

s u c h t h a t   l r     ̀

]  r r  p o i n t s t o   s 

( c ) C o n s i d e r a n y p a i r   s 

a n d  s 

o f e l e m e n t s o f l i s t   S 

 ̀

s u c h t h a t   s 

a g  =  s 

a g  =  N o t D o n e   a n d  i 

< i 

w i t h   l r     ̀

]  r r  p o i n t i n g t o   s 

a n d  l r     ̀

]  r r  p o i n t i n g t o   s 

. T h e n    ̀

<  ̀

W e p r e s e n t a c o u p l e o f u s e f u l o b s e r v a t i o n s a s l e m m a s b a s e d u p o n t h e a b o v e i n v a r i a n t s , u s i n g t h e s a m e n o t a t i o n .  

1 1 3 

Page 127: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 127/203

L e m m a 3 0   U n l e s s    ̀ =  m a x l e v e l a n d c u r r e n t   =  m  , g i v e n l e v e l - r e c o r d l r      ̀ ]  , w e c a n o b t a i n a r u n - r e c o r d r r  

u s i n g  

a s i n g l e I / O o p e r a t i o n , w h e r e r r  

i s s u c h t h a t r r  

a g  =  N o t D o n e a n d t h e m e r g e o p e r a t i o n a s s o c i a t e d w i t h r r  

i s 

a p p r o p r i a t e f o r l e v e l    ̀

P r o o f  : T h e i n v a r i a n t s 5 , 6 , 7 , 1 0 a n d 9 t o g e t h e r i m p l y t h a t t h e a c t i v e r u n - r e c o r d   r r 

 ̀

o f l e v e l    ̀ h a s  r r 

 ̀

O r d e r   = 2 

 ̀   1 

u n l e s s    ̀ =  m a x l e v e l   a n d  c u r r e n t   =  m  . B y d e n i t i o n o f r u n - r e c o r d s a n d D e n i t i o n 3 0 , t h e m e r g e o p e r a t i o n a l i a t e d  

w i t h   r r 

 ̀

i s a p p r o p r i a t e f o r l e v e l    ̀ , u n l e s s    ̀ =  m a x l e v e l   a n d  c u r r e n t   =  m  . S i n c e l e v e l - r e c o r d   l r     ̀ ]  a c t i v e   i s a p o i n t e r  

t o  r r 

 ̀

, t h e l e m m a i s t r u e .  

W h e n t h e a l l o c a t i o n l e v e l i s    ̀ ,  M A M e r g e   c a r r i e s o u t c o m p u t a t i o n p r o d u c i n g b l o c k s b e l o n g i n g t o t h e r u n a s s o c i a t e d  

w i t h t h e a c t i v e r u n - r e c o r d   r r 

 ̀

o f l e v e l    ̀ b y m e r g i n g t h e r u n s a s s o c i a t e d w i t h t h e r u n - r e c o r d s i n t h e l i s t   r r 

 ̀

i n p u t s   : 

L e m m a 3 0 e n s u r e s u s t h a t t h i s a m o u n t s t o m a k i n g o p t i m a l u t i l i z a t i o n o f r e s o u r c e s . H o w e v e r , a s w i l l b e s e e n l a t e r , i t  

i s p o s s i b l e f o r a r u n - r e c o r d   r r 

i n t h e l i s t   r r 

 ̀

i n p u t s   t o h a v e i t s   a g  e l d s e t t o   N o t D o n e  , m e a n i n g t h a t t h e f o r m a t i o n  

o f t h e r u n a s s o c i a t e d w i t h   r r 

i s n o t l o g i c a l l y c o m p l e t e : T h i s i s a p o t e n t i a l p r o b l e m s i n c e i t m e a n s t h a t i n o r d e r t o  

p r o d u c e b l o c k s o f t h e r u n a s s o c i a t e d w i t h   r r 

 ̀

,  M A M e r g e   w o u l d i n h e r e n t l y h a v e t o a l s o c a r r y o u t t h e m e r g e l i n k e d t o  

e a c h s u c h r u n - r e c o r d   r r 

a n d s o p r o d u c i n g b l o c k s o f t h e r u n a s s o c i a t e d t o   r r 

 ̀

m a y r e q u i r e   M A M e r g e   t o h a v e m o r e  

m e m o r y t h a n o r i g i n a l l y e x p e c t e d . H o w e v e r t h e i n v a r i a n t s 1 1 a a n d 1 1 b a v e r t t h i s p o t e n t i a l p r o b l e m . I n v a r i a n t 1 1 a  

i m p l i e s t h a t t h e r e a r e a t m o s t    ̀   1 r u n - r e c o r d s i n l i s t   r r 

 ̀

i n p u t s   w i t h t h e i r   a g  e l d s e t t o   N o t D o n e   a n d i n v a r i a n t 1 1 b  

i m p l i e s t h a t t h e t o t a l n u m b e r o f e x t r a r u n - r e c o r d s n e c e s s i t a t e d b y t h e s e r u n - r e c o r d s i s n o m o r e t h a n   O 

 

 ̀   1 

 

. T h i s  

n u m b e r i s w i t h i n a c o n s t a n t f a c t o r o f t h e n u m b e r 2  

 ̀   1 

o f r u n - r e c o r d s o r i g i n a l l y e x p e c t e d t o b e i n v o l v e d i n t h e m e r g e  

p r o d u c i n g b l o c k s o f t h e r u n a s s o c i a t e d w i t h   r r 

 ̀

, t h u s a v e r t i n g t h e p o t e n t i a l p r o b l e m .  

I t i s e a s y t o p r o v e t h a t t h e a b o v e i n v a r i a n t s a r e a l l t r u e i m m e d i a t e l y a f t e r t h e p r e p r o c e s s i n g c o m p u t a t i o n a n d  

i n i t i a l i z a t i o n o f l e v e l - r e c o r d s i s c o m p l e t e d .  

5 . 8 . 6 L o w - l e v e l M e r g e C o m p u t a t i o n  

W e n o w d e s c r i b e t h e p r o c e d u r e   l l m e r g e   (  r r  ) u s e d b y   M A M e r g e   t o c a r r y o u t t h e m e r g e c o m p u t a t i o n a l i a t e d t o  

r u n - r e c o r d   r r  . W h e n e v e r t h e a l l o c a t i o n l e v e l i s    ̀   m a x l e v e l  , a n d l e v e l - r e c o r d   l r     ̀ ] i s n o t   n i l  ,  M A M e r g e   e x e c u t e s t h e  

p r o c e d u r e   l l m e r g e   (  r r 

 ̀

) d e s c r i b e d b e l o w , p r o d u c i n g b l o c k s o f t h e r u n a s s o c i a t e d w i t h t h e a c t i v e r u n - r e c o r d   r r 

 ̀

o f l e v e l  

 ̀ . L e m m a 3 0 e n s u r e s u s t h a t   r r 

 ̀

i s a l i a t e d t o a m e r g e o p e r a t i o n a p p r o p r i a t e f o r l e v e l    ̀ a n d s o l e v e l    ̀ a l l o c a t i o n  

p h a s e s a r e o p t i m a l , u n l e s s p o s s i b l y w h e n    ̀ =  m a x l e v e l   a n d  l r     ̀ ]  c u r r e n t   =  l r     ̀ ]  r r  O r d e r  

W h e n e v e r t h e a l l o c a t i o n l e v e l    ̀ i s g r e a t e r t h a n   m a x l e v e l   o r w h e n    ̀ =  m a x l e v e l   a n d  l r     ̀ ]  c u r r e n t   = 2 

 ̀   1 

,  M A M e r g e  

e x e c u t e s t h e p r o c e d u r e   l l m e r g e   (  r r 

g l o b a l  

) : B y i n v a r i a n t s 4 a n d 8 , s u c h a p h a s e c a n b e n o n o p t i m a l e v e n i f (  m B  ) 

e l e m e n t s a r e a p p e n d e d t o t h e p h y s i c a l s e q u e n c e o f t h e r u n a s s o c i a t e d w i t h   r r 

g l o b a l  

d u r i n g t h a t p h a s e . H o w e v e r ,  

1 1 4 

Page 128: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 128/203

w e a r g u e i n S e c t i o n 5 . 9 t h a t t h e t o t a l a m o u n t o f r e s o u r c e c o n s u m p t i o n o v e r a l l e x e c u t i o n s o f   l l m e r g e   (  r r 

g l o b a l  

) i s 

O  (  n 

0 0 

l g  m 

m a x 

) , w h e r e   n 

0 0 

i s t h e s u m o f t h e n u m b e r o f d i s k b l o c k s o f a l l t h e     r u n s m e r g e d b y   M A M e r g e  

I n v a r i a n t s f o r   l l m e r g e   ( ) 

I n o u r d e s c r i p t i o n o f t h e p r o c e d u r e   l l m e r g e   ( ) , w e u s e   r r  t o d e n o t e t h e r u n - r e c o r d p a s s e d a s a n a r g u m e n t t o   l l m e r g e   ( )

W e e n s u r e t h a t t h e f o l l o w i n g i n v a r i a n t s a r e a l w a y s s a t i s e d w h e n e v e r   M A M e r g e   e x e c u t e s p r o c e d u r e   l l m e r g e   (  r r  ) a n d  

t h e a l l o c a t i o n l e v e l i s    ̀ : 

1 r r  a g  =  N o t D o n e  

2 . I f    ̀   m a x l e v e l  , t h e n  

( a )  r r  =  r r 

 ̀

, t h e a c t i v e r u n - r e c o r d o f l e v e l    ̀

( b ) D u r i n g t h e l e v e l    ̀ a l l o c a t i o n p h a s e a t t h e i n s t a n t w h e n   M A M e r g e   m a k e s t h e c a l l t o e x e c u t e p r o c e d u r e  

l l m e r g e   (  r r  ) , t h e f o l l o w i n g c o n d i t i o n i s s a t i s e d : E i t h e r t h e n u m b e r   l e f t   o f I / O o p e r a t i o n s i n t h e o n g o i n g  

a l l o c a t i o n p h a s e i s s u c h t h a t   l e f t      

l l m 

  2 

 ̀   1 

, w h e r e    

l l m 

i s a p o s i t i v e c o n s t a n t d e n e d b e l o w , o r , t h e  

i m m e d i a t e l y f o l l o w i n g a l l o c a t i o n p h a s e  

1 0 

o f s i z e   n e x t   i s a t l e v e l   l e v e l  (  n e x t  ) =   ̀

( c ) T h e l e v e l - r e c o r d s   l r  1 ] t h r o u g h   l r     ̀ ] a r e a l r e a d y i n m e m o r y a t t h e t i m e t h e c a l l t o e x e c u t e   l l m e r g e   (  r r  ) i s 

m a d e .  

3 . I f   ` >  m a x l e v e l  , t h e n  

( a )  r r  =  r r 

g l o b a l  

( b ) D u r i n g t h e l e v e l    ̀ a l l o c a t i o n p h a s e , a t t h e i n s t a n t w h e n   M A M e r g e   m a k e s t h e c a l l t o e x e c u t e p r o c e d u r e  

l l m e r g e   (  r r  ) , t h e f o l l o w i n g c o n d i t i o n i s s a t i s e d : E i t h e r t h e n u m b e r   l e f t   o f I / O o p e r a t i o n s i n t h e o n g o i n g  

a l l o c a t i o n p h a s e i s s u c h t h a t   l e f t      

l l m 

  2 

m a x l e v e l  

, w h e r e    

l l m 

i s a p o s i t i v e c o n s t a n t d e n e d b e l o w , o r t h e  

i m m e d i a t e l y f o l l o w i n g a l l o c a t i o n p h a s e o f s i z e   n e x t   i s a t a l l o c a t i o n l e v e l   l e v e l  (  n e x t  )  >  m a x l e v e l  

( c ) T h e l e v e l - r e c o r d s   l r  1 ] t h r o u g h   l r    m a x l e v e l  ] a r e a l r e a d y i n m e m o r y a t t h e t i m e t h e c a l l t o e x e c u t e  

l l m e r g e   (  r r  ) i s m a d e .  

4 . W h e n t h e e x e c u t i o n o f  l l m e r g e   (  r r  ) i s c o m p l e t e d , t h e   a g  e l d o f r u n - r e c o r d   r r  i s s e t t o   D o n e   i f a n d o n l y i f t h e  

f o r m a t i o n o f t h e r u n a s s o c i a t e d w i t h   r r  i s l o g i c a l l y c o m p l e t e , a s i n D e n i t i o n 2 4 .  

T h e f o l l o w i n g d e n i t i o n i s u s e d d u r i n g o u r d i s c u s s i o n o n   l l m e r g e   ( )

1 0 

A s m e n t i o n e d b e f o r e , i t i s p o s s i b l e t o m o d i f y o u r s t r a t e g y t o m a k e d o w i t h o u t t h e i n f o r m a t i o n  

c o r r e s p o n d i n g t o   n e x t   w i t h n o l o s s o f e c i e n c y , a s y m p t o t i c a l l y .  

1 1 5 

Page 129: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 129/203

Page 130: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 130/203

L e m m a 3 1   T h e m a x i m u m n u m b e r   z  (  k  )  o f r u n - r e c o r d s t o u c h e d d u r i n g t h e e x e c u t i o n o f l l m e r g e   (  r r  )  i s n o m o r e t h a n  

 

k    1 

 

P r o o f  : W e r s t c o n s i d e r t h e c a s e w h e n   k  =   ̀   m a x l e v e l   a n d  r r  =  r r 

 ̀

. I n t h i s c a s e , b y i n v a r i a n t s 8 a n d 1 0 o f  

S e c t i o n 5 . 8 . 5 , w e k n o w t h a t t h e n u m b e r o f r u n - r e c o r d s i n l i s t   r r  i n p u t s   i s 2 

k    1 

a n d a l l t h e s e a r e t o u c h e d . W e w i l l  

c o n s i d e r r u n - r e c o r d s o t h e r t h a n t h o s e i n l i s t   r r  i n p u t s   t h a t g e t t o u c h e d . F o r a g i v e n t o u c h e d r u n - r e c o r d t o c a u s e  

m o r e r u n - r e c o r d s t o b e t o u c h e d , t h a t r u n - r e c o r d n e c e s s a r i l y m u s t h a v e a   a g  e l d v a l u e o f   N o t D o n e  

W e s a y t h a t a r u n - r e c o r d   r r 

b e l o n g s t o l e v e l    ̀

i f  r r 

i s e i t h e r i n t h e   i n p u t s   l i s t o f t h e r u n - r e c o r d   l r     ̀

]  r r  o r i n  

t h e  i n p u t s   l i s t o f s o m e r u n - r e c o r d i n t h e   i n p u t s   l i s t o f t h e r u n - r e c o r d   l r     ̀

]  r r 

A s a r e s u l t o f i n v a r i a n t 1 1 o f S e c t i o n 5 . 8 . 5 a n d t h e f a c t t h a t a n y r u n - r e c o r d n o t i n c l u d e d i n l i s t   r r  i n p u t s   i s t o u c h e d  

o n l y i f i t l i e s i n a d e p l e t e d r u n - r e c o r d ' s   i n p u t s   l i s t , e a c h r u n - r e c o r d t o u c h e d b y   l l m e r g e   (  r r  ) m u s t b e l o n g t o a l e v e l  

 ̀

< k  =   ̀ . B y i n v a r i a n t s 1 0 a n d 9 o f S e c t i o n 5 . 8 . 5 , t h e m a x i m u m n u m b e r o f r u n - r e c o r d s b e l o n g i n g t o t o l e v e l    ̀

i s 

 ̀

. H e n c e t h e m a x i m u m n u m b e r   z  (  k  ) o f r u n - r e c o r d s t o u c h e d b y   l l m e r g e   (  r r  ) w h e n   k  =   ̀ i s 

k    1 

k    1 

X   

 ̀

= 1 

 ̀

=  O 

  

k    1 

 

I n t h e c a s e w h e n   k  =  m a x l e v e l   + 1 a n d   r r  i s  r r 

g l o b a l  

, e v e r y t o u c h e d r u n - r e c o r d b e l o n g s t o a l e v e l    ̀

< k  s o t h e  

m a x i m u m n u m b e r   z  (  k  ) o f t o u c h e d r u n - r e c o r d s i s n o m o r e t h a n  

k    1 

X   

 ̀

= 1 

 ̀

=  O 

  

k    1 

 

H e n c e t h e l e m m a i s p r o v e d .  

T h e f o l l o w i n g l e m m a c a n b e e a s i l y p r o v e d .  

L e m m a 3 2   I f t h e r u n - r e c o r d r r i s n o t t h e r u n - r e c o r d r r  

g l o b a l  

, t h e n w e h a v e   y  (  k  )    2 

k    1 

, w h e r e   y  (  k  )  i s t h e s m a l l e s t  

p o s s i b l e n u m b e r o f r u n - r e c o r d s t h a t l l m e r g e   (  r r  )  t o u c h e s .  

I f t h e r u n s b e i n g m e r g e d d u r i n g   l l m e r g e   (  r r  ) a r e l o n g e n o u g h , t h e m e r g i n g p a r t o f   l l m e r g e   (  r r  ) c a n p r o c e e d f o r  

a n i n d e n i t e l y l o n g t i m e , u n l e s s w e   p r e e m p t l l m e r g e  (  r r  ) . T h e n e e d t o p r e e m p t s t e m s f r o m t h e f a c t t h a t i f t h e  

a l l o c a t i o n l e v e l c h a n g e s t o    ̀

  m a x l e v e l  ,  M A M e r g e   w o u l d t h e n e x e c u t e   l l m e r g e   (  r r 

 ̀

0  ) , w h e r e   r r 

 ̀

0  i s t h e a c t i v e r u n -  

r e c o r d o f l e v e l    ̀

. I n o r d e r t o b e a b l e t o r e s u m e a m e r g e o p e r a t i o n a t s o m e l a t e r s t a g e , d u r i n g t h e s t a t e - s a v i n g p a r t  

1 1 7 

Page 131: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 131/203

o f  l l m e r g e   (  r r  ) w e c o m m i t p a r t i a l l y e m p t y b u e r b l o c k s o f p h y s i c a l s e q u e n c e s b e i n g m e r g e d , u p d a t e d t o u c h e d r u n -  

r e c o r d s a n d p e r t i n e n t u p d a t e d l e v e l - r e c o r d s b a c k t o d i s k : T r a n s f e r r i n g t h e s e t o d i s k o b v i o u s l y r e q u i r e s I / O o p e r a t i o n s  

s o  l l m e r g e   (  r r  ) r e s e r v e s a c e r t a i n n u m b e r o f I / O o p e r a t i o n s f r o m i t s t o t a l n u m b e r ,    

l l m 

  2 

k    1 

, o f I / O o p e r a t i o n s ,  

s p e c i c a l l y f o r t h i s p u r p o s e . W e n o w d e s c r i b e t h e s t a t e - s a v i n g p a r t o f   l l m e r g e   (  r r  ) a n d d e t e r m i n e h o w m a n y I / O  

o p e r a t i o n s i t r e q u i r e s .  

D u r i n g i t s s t a t e - s a v i n g p a r t ,   l l m e r g e   (  r r  ) e x e c u t e s t h e f o l l o w i n g s t e p s :  

1 . T h e   a g  e l d o f a n y r u n - r e c o r d   r r 

s u c h t h a t   r r 

i s e i t h e r   r r  o r a t o u c h e d r u n - r e c o r d , i s s e t t o   D o n e   i f i t w a s  

p r e v i o u s l y   N o t D o n e   a n d t h e f o r m a t i o n o f t h e r u n a s s o c i a t e d w i t h   r r 

i s l o g i c a l l y c o m p l e t e , a s i n D e n i t i o n 2 4 .  

( B y v i r t u e o f i n v a r i a n t 4 o f S e c t i o n 5 . 8 . 6 , i t i s e n o u g h t o s e t   r r 

a g  =  D o n e   w h e n e v e r , a f t e r r e c u r s i v e l y  

d e t e r m i n i n g t h e v a l u e s o f t h e   a g  e l d s o f a l l t h e r u n - r e c o r d s i n l i s t   r r 

i n p u t s   , i t i s f o u n d t h a t t h e y a l l h a v e  

t h e i r   a g  e l d s s e t t o   D o n e  

1 1 

2 . I f a t o u c h e d r u n - r e c o r d w h o s e   a g  e l d c h a n g e s v a l u e f r o m   N o t D o n e   t o  D o n e   i s t h e r u n - r e c o r d w h o s e l o c a t i o n  

i s s t o r e d i n   l r     ̀

]  r r  o r  l r     ̀

]  a c t i v e   , f o r s o m e    ̀

s u c h t h a t 1      ̀

  m i n  f  ` ;  m a x l e v e l  g  , w e n e e d t o a c c o r d i n g l y  

u p d a t e t h e l e v e l - r e c o r d   l r     ̀

] i n o r d e r t o e n s u r e t h a t t h e i n v a r i a n t s o f S e c t i o n 5 . 8 . 5 r e m a i n t r u e : I t i s n o t h a r d  

t o s e e t h a t t h e s e i n v a r i a n t s c a n b e m a i n t a i n e d e a s i l y f o r a l l r e l e v a n t    ̀

s

3 . W r i t e o u t t o d i s k t h e i n t e r n a l m e m o r y b l o c k s t h a t b u e r t h e p h y s i c a l s e q u e n c e s b e i n g m e r g e d . W r i t e  

o u t a l l t o u c h e d r u n - r e c o r d s a n d t h e r u n - r e c o r d   r r  b a c k t o d i s k . W r i t e o u t t h e l e v e l - r e c o r d s   l r  1 ] t h r o u g h  

l r  m i n   f  ` ;  m a x l e v e l  g  ] b a c k t o d i s k .  

T h e s t a t e - s a v i n g p a r t b a s i c a l l y e n s u r e s t h a t t h e f o l l o w i n g l e m m a i s t r u e .  

L e m m a 3 3   T h e i n v a r i a n t s o f S e c t i o n 5 . 8 . 5 a n d t h e i n v a r i a n t 4 o f S e c t i o n 5 . 8 . 6 r e m a i n s t r u e a f t e r t h e e x e c u t i o n o f  

l l m e r g e   (  r r  )  i s c o m p l e t e d .  

B y L e m m a 3 1 , s i n c e   l l m e r g e   (  r r  ) h a s a t m o s t o n e i n t e r n a l m e m o r y b l o c k c o r r e s p o n d i n g t o e a c h t o u c h e d r u n - r e c o r d ,  

w e h a v e t h e f o l l o w i n g l e m m a .  

L e m m a 3 4   T h e r e e x i s t s a c o n s t a n t    

s a v e  

s u c h t h a t t h e t o t a l n u m b e r o f I / O o p e r a t i o n s r e q u i r e d t o i m p l e m e n t  

l l m e r g e   (  r r  )  ' s s t a t e - s a v i n g p a r t , i n w h i c h t o u c h e d r u n - r e c o r d s , p e r t i n e n t l e v e l - r e c o r d s a n d p a r t i a l l y l l e d b l o c k s o f  

p h y s i c a l s e q u e n c e s a r e w r i t t e n t o d i s k , i s n o m o r e t h a n    

s a v e  

  2 

k    1 

1 1 

D u m m y r u n - r e c o r d s i n t r o d u c e d i n t h e p r e p r o c e s s i n g s t a g e a r e a l l t o b e t r e a t e d a s r u n - r e c o r d s  

w i t h t h e i r     a g   e l d s s e t t o   D o n e  . 

1 1 8 

Page 132: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 132/203

I n o r d e r t o c o m p l e t e t h e d e s c r i p t i o n o f   l l m e r g e   (  r r  ) , w e n e e d t o d e n e t h e c o n s t a n t    

l l m 

u s e d i n i n v a r i a n t s 2 b a n d  

3 b . A s m e n t i o n e d a b o v e    

l l m 

  2 

k    1 

s h o u l d t a k e i n t o a c c o u n t t h e    

s a v e  

  2 

k    1 

r e q u i r e d t o c o m p l e t e t h e s t a t e - s a v i n g  

p a r t o f   l l m e r g e   (  r r  ) . A d d i t i o n a l l y ,    

l l m 

s h o u l d a l s o b e l a r g e e n o u g h f o r a u s e f u l a m o u n t o f \ w o r k " t o g e t d o n e d u r i n g  

t h e m e r g i n g p a r t o f   l l m e r g e   (  r r  ) . B e l o w w e q u a n t i f y t h e n o t i o n o f u s e f u l a m o u n t o f w o r k .  

D e n i t i o n 4 2   C o n s i d e r t h e p h y s i c a l s e q u e n c e   q  (  r ; t  ) o f t h e r u n   r  a s s o c i a t e d w i t h r u n - r e c o r d   r r  a t t i m e   t   j u s t b e f o r e  

t h e e x e c u t i o n o f   l l m e r g e   (  r r  ) b e g i n s . W e c a l l a p a r t i c u l a r e x e c u t i o n o f   l l m e r g e   (  r r  ) a  g o o d c a l l   i f a t l e a s t 2  

k    1 

  B 

i t e m s a r e a p p e n d e d t o t h e p h y s i c a l s e q u e n c e   q  (  r ; t  ) d u r i n g t h a t e x e c u t i o n o f   l l m e r g e   (  r r  ) . A n y e x e c u t i o n o f  l l m e r g e   (  r r  ) 

t h a t i s n o t a g o o d c a l l i s a   b a d c a l l  

W e c o n s i d e r t h e w o r k i n v o l v e d i n a p p e n d i n g 2  

k    1 

  B  i t e m s t o t h e p h y s i c a l s e q u e n c e o f t h e r u n a s s o c i a t e d w i t h  

l l m e r g e   (  r r  ) a u s e f u l a m o u n t o f w o r k d u r i n g t h e m e r g i n g p a r t o f   l l m e r g e   (  r r  ) . T h e f o l l o w i n g l e m m a b o u n d s t h e t o t a l  

n u m b e r o f I / O o p e r a t i o n s i n c u r r e d i n c a r r y i n g o u t t h i s u s e f u l a m o u n t o f w o r k .  

L e m m a 3 5   L e t  q 

m a x 

b e t h e t o t a l n u m b e r o f i t e m s t h a t n e e d t o b e a p p e n d e d t o t h e p h y s i c a l s e q u e n c e o f t h e r u n  

r  a s s o c i a t e d w i t h r u n - r e c o r d r r f o r t h e f o r m a t i o n o f   r  t o b e l o g i c a l l y c o m p l e t e . T h e n t h e t o t a l n u m b e r o f I / O  

o p e r a t i o n s i n c u r r e d b y t h e t h e m e r g i n g p a r t o f l l m e r g e  (  r r  )  t o c a r r y o u t e n o u g h m e r g i n g c o m p u t a t i o n t o a p p e n d  

m i n  f  2 

k    1 

  B ; q 

m a x 

g  i t e m s t o t h e p h y s i c a l s e q u e n c e o f r u n   r  i s n o m o r e t h a n    

l o a d  

  2 

k    1 

, w h e r e    

l o a d  

i s a s m a l l  

p o s i t i v e c o n s t a n t .  

S k e t c h o f P r o o f  : S u p p o s e t h a t t h e m e r g i n g t e c h n i q u e u s e d d u r i n g t h e m e r g i n g p a r t i s t h e \ s t a n d a r d " e x t e r n a l m e m o r y  

j  T  j  - w a y m e r g e t e c h n i q u e , w h e r e   T  i s t h e s e t d e n e d i n t h e d e s c r i p t i o n o f t h e m e r g i n g p a r t . T h e l e m m a t h e n f o l l o w s  

f r o m t h e f a c t t h a t t h e r e a r e a t m o s t   O 

 

k    1 

 

t o u c h e d r u n - r e c o r d s d u r i n g   l l m e r g e   (  r r  ) a n d a f t e r i n c u r r i n g   O  ( 1 ) I / O  

o p e r a t i o n s c o r r e s p o n d i n g t o e a c h t o u c h e d r u n - r e c o r d a s \ s t a r t - u p o v e r h e a d " , t h e m e r g i n g p r o c e s s r e s u l t s i n 1 b l o c k  

o f i t e m s b e i n g a p p e n d e d t o t h e p h y s i c a l s e q u e n c e o f r u n   r  e v e r y   O  ( 1 ) I / O o p e r a t i o n s .  

T h e e x e c u t i o n o f   l l m e r g e   (  r r  ) r e q u i r e s o n e i n t e r n a l m e m o r y b l o c k t o b u e r t h e p h y s i c a l s e q u e n c e c o r r e s p o n d i n g t o  

e a c h t o u c h e d r u n - r e c o r d a n d   O  ( 1  = B  ) i n t e r n a l m e m o r y b l o c k s t o s t o r e e a c h t o u c h e d r u n - r e c o r d o r e a c h l e v e l - r e c o r d  

l o a d e d b y   l l m e r g e   (  r r  ) . T h u s b y L e m m a 3 5 , w e h a v e t h e f o l l o w i n g l e m m a .  

L e m m a 3 6   T h e t o t a l n u m b e r o f i n t e r n a l m e m o r y b l o c k s r e q u i r e d b y l l m e r g e  (  r r  )  i s n o m o r e t h a n  

 

l o a d  

  2 

k    1 

W e n o w d e n e t h e c o n s t a n t    

l l m 

u s e d i n i n v a r i a n t s 2 b a n d 3 b .  

1 1 9 

Page 133: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 133/203

D e n i t i o n 4 3   W e d e n e t h e c o n s t a n t    

l l m 

t o b e    

l o a d  

+   

s a v e  

, w h e r e    

l o a d  

a n d   

s a v e  

a r e r e s p e c t i v e l y d e n e d i n  

L e m m a 3 4 a n d L e m m a 3 5 . W e d e n e t h e c o n s t a n t    

l l m 

t o b e    

l l m 

+    s u c h t h a t f o r 1      ̀    ̀

m a x 

, t h e t o t a l n u m b e r  

o f I / O o p e r a t i o n s r e q u i r e d t o l o a d t h e l e v e l - r e c o r d s   l r  1 ] t h r o u g h   l r     ̀ ] i s n o m o r e t h a n       2 

 ̀   1 

a n d    i s a s s m a l l a s  

p o s s i b l e .  

T h e d e n i t i o n o f    

l l m 

i s f o r m i n o r t e c h n i c a l r e a s o n s . S u p p o s e t h a t t h e i n v a r i a n t s m e n t i o n e d e a r l i e r a r e s a t i s e d  

a t t h e t i m e   M A M e r g e   m a k e s t h e c a l l t o e x e c u t e   l l m e r g e   (  r r  ) a t a l l o c a t i o n l e v e l    ̀ . T h e n t h e c o m p l e t e d e s c r i p t i o n o f  

l l m e r g e   (  r r  ) , b a s e d u p o n t h e m e r g i n g a n d s t a t e - s a v i n g p a r t s , d e s c r i b e d a b o v e i s a s f o l l o w s .  

1 . E x e c u t e t h e m e r g i n g p a r t u n t i l a t i m e   t  s u c h t h a t a t l e a s t o n e o f t h e f o l l o w i n g c o n d i t i o n s i s v i o l a t e d :  

( a ) I f   k  =  ` <  m a x l e v e l  + 1 , t h e n e i t h e r t h e n u m b e r   l e f t   o f I / O o p e r a t i o n s i n t h e o n g o i n g a l l o c a t i o n p h a s e i s s u c h  

t h a t   l e f t      

s a v e  

  2 

 ̀   1 

o r t h e i m m e d i a t e l y f o l l o w i n g a l l o c a t i o n p h a s e o f s i z e   n e x t   i s a t l e v e l   l e v e l  (  n e x t  ) =   ̀

I f  k  =  m a x l e v e l   + 1 , t h e n e i t h e r t h e n u m b e r   l e f t   o f I / O o p e r a t i o n s i n t h e o n g o i n g a l l o c a t i o n p h a s e i s s u c h  

t h a t   l e f t      

s a v e  

  2 

k    1 

o r t h e i m m e d i a t e l y f o l l o w i n g a l l o c a t i o n p h a s e o f s i z e   n e x t   i s a t l e v e l   l e v e l  (  n e x t  )  > 

m a x l e v e l  

( b ) T h e f o r m a t i o n o f t h e r u n a s s o c i a t e d w i t h r u n - r e c o r d   r r  i s n o t l o g i c a l l y c o m p l e t e a t t i m e   t 

2 . E x e c u t e t h e s t a t e - s a v i n g p a r t d e s c r i b e d a b o v e .  

T h e n u m b e r o f I / O o p e r a t i o n s d u r i n g t h e m e r g i n g p a r t c a n b e m o r e t h a n  

 

k    1 

 

: C o m p u t a t i o n c o r r e s p o n d i n g  

t o t h e m e r g i n g p a r t i s n o t i n t e r r u p t e d s o l o n g a s t h e c o n d i t i o n s i n s t e p 1 a a n d 1 b a b o v e a r e s a t i s e d . T h u s t h e  

n u m b e r o f b l o c k s a p p e n d e d t o t h e p h y s i c a l s e q u e n c e o f t h e r u n a s s o c i a t e d w i t h   r r  c a n a l s o e x c e e d   O 

 

k    1 

 

. T h e  

o n l y s i t u a t i o n t h a t c a u s e s t h e e x e c u t i o n o f   l l m e r g e   (  r r  ) t o b e a b a d c a l l i s w h e n t h e c o n d i t i o n i n s t e p 1 b i s v i o l a t e d  

d u r i n g t h e e x e c u t i o n o f   l l m e r g e   (  r r  ) : A s a r e s u l t o f i n v a r i a n t s 2 b a n d 3 b o f S e c t i o n 5 . 8 . 6 a n d t h e d e n i t i o n o f    

l l m 

, t h e  

e x e c u t i o n o f   l l m e r g e   (  r r  ) c a n n e v e r e n d u p b e i n g a b a d c a l l o n a c c o u n t o f v i o l a t i o n c o n d i t i o n 1 a d u r i n g t h e e x e c u t i o n  

o f  l l m e r g e   (  r r  ) . W e h a v e t h e f o l l o w i n g l e m m a s r e g a r d i n g g o o d a n d b a d   l l m e r g e   (  r r  ) c a l l s r e l a t i n g t h e n u m b e r o f I / O  

o p e r a t i o n s i n c u r r e d b y   l l m e r g e   (  r r  ) a n d t h e n u m b e r o f b l o c k s a p p e n d e d t o t h e p h y s i c a l s e q u e n c e o f t h e r u n a s s o c i a t e d  

w i t h r u n - r e c o r d   r r 

L e m m a 3 7   S u p p o s e t h a t t h e e x e c u t i o n o f l l m e r g e  (  r r  )  i s a g o o d c a l l i n w h i c h   g  i t e m s a r e a p p e n d e d t o t h e p h y s i c a l  

s e q u e n c e o f t h e r u n a s s o c i a t e d w i t h r r . T h e n t h e t o t a l n u m b e r o f I / O o p e r a t i o n s i n c u r r e d b y t h e e x e c u t i o n o f  

l l m e r g e   (  r r  )  i s  O  (  g = B  ) 

1 2 0 

Page 134: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 134/203

S k e t c h o f P r o o f   : A f t e r t h e m e r g i n g p r o c e s s h a s l o a d e d i n t o m e m o r y t h e l e a d i n g   B  i t e m s o f t h e r u n s b e i n g m e r g e d ,  

r o u g h l y s p e a k i n g , e a c h t i m e a b l o c k i s b r o u g h t i n t o m e m o r y t h e r e i s a c o r r e s p o n d i n g b l o c k b e i n g w r i t t e n t o t h e  

o u t p u t r u n . T h e t o t a l n u m b e r o f t o u c h e d r u n - r e c o r d s i s   O 

 

k    1 

 

. T h e t o t a l n u m b e r o f I / O o p e r a t i o n s r e q u i r e d  

t o a p p e n d 2  

k    1 

  B  i t e m s t o t h e c o n c e r n e d p h y s i c a l s e q u e n c e i s   O 

 

k    1 

 

, b y L e m m a 3 5 . S i n c e t h e   l l m e r g e   (  r r  ) i n 

q u e s t i o n i s a g o o d c a l l , w e h a v e   g    2 

k    1 

  B  . H e n c e t h e l e m m a f o l l o w s .  

T h e f o l l o w i n g l e m m a f o l l o w s d i r e c t l y f r o m L e m m a 3 5 .  

L e m m a 3 8   S u p p o s e t h a t t h e e x e c u t i o n o f l l m e r g e   (  r r  )  i s a b a d c a l l . T h e n t h e t o t a l n u m b e r o f I / O o p e r a t i o n s i n c u r r e d  

b y t h e e x e c u t i o n o f l l m e r g e  (  r r  )  i s  O 

 

k    1 

 

I n o r d e r t o t e s t t h a t t h e c o n d i t i o n o f s t e p 1 b a b o v e r e m a i n s t r u e , a t a n y t i m e d u r i n g i t s e x e c u t i o n ,   l l m e r g e   (  r r  ) 

n e e d s t o m a i n t a i n t h e i n v a r i a n t t h a t t h e   a g  e l d o f   r r  i s  D o n e   i f a n d o n l y i f t h e f o r m a t i o n o f t h e r u n a s s o c i a t e d  

w i t h   r r  i s l o g i c a l l y c o m p l e t e : B y v i r t u e o f S t e p 1 o f t h e s t a t e - s a v i n g p a r t a n d t h e f a c t t h a t a l l t o u c h e d r u n - r e c o r d s  

r e s i d e i n i n t e r n a l m e m o r y a t t h e t i m e t h e f o r m a t i o n o f t h e r u n a s s o c i a t e d w i t h   r r  d o e s b e c o m e l o g i c a l l y c o m p l e t e ,  

t h i s i n v a r i a n t c a n b e a c h i e v e d e a s i l y b y   l l m e r g e   (  r r  )

5 . 8 . 7 D o w n l o a d i n g W o r k f o r A d a p t i v i t y  

I f  l r     ̀ ] i s n o t   n i l  , w h e n e v e r t h e a l l o c a t i o n l e v e l i s    ̀ ,  M A M e r g e   e x e c u t e s t h e m e r g i n g o p e r a t i o n a l i a t e d w i t h   r r 

 ̀

I f 

M A M e r g e  ' s a l l o c a t i o n l e v e l r e m a i n s    ̀ o r s m a l l e r f o r e x t e n d e d p e r i o d s o f t i m e ,  M A M e r g e   r u n s o u t o f a l l t h e ( 2  

 ̀   1 

) - 

w a y m e r g i n g w o r k a s s o c i a t e d w i t h   l r     ̀ ] a n d l e v e l - r e c o r d   l r     ̀ ] b e c o m e s   n i l  . W h e n t h e l e v e l - r e c o r d   l r     ̀ ] b e c o m e s   n i l  , 

w e n e e d t o a s s o c i a t e l e v e l    ̀ w i t h \ f r e s h " a p p r o p r i a t e m e r g i n g w o r k . W e r e f e r t o t h e p r o c e s s o f e s t a b l i s h i n g s u c h a n  

a s s o c i a t i o n a \ d o w n l o a d i n g " p r o c e s s s i n c e i t r e q u i r e s \ s t e a l i n g " s o m e o f t h e m e r g i n g w o r k a s s o c i a t e d w i t h a h i g h e r  

a l l o c a t i o n l e v e l    ̀

>  ̀ . O n c e t h e n e w a s s o c i a t i o n o f l e v e l    ̀ w i t h s u c h a m e r g e o p e r a t i o n i s m a d e , t h e r u n - r e c o r d   r r 

 ̀

i s o n c e m o r e a l i a t e d t o a m e r g e o p e r a t i o n w h i c h i s a p p r o p r i a t e f o r l e v e l    ̀ , a n d w h i c h c a n b e e x e c u t e d w h e n t h e  

a l l o c a t i o n l e v e l n e x t b e c o m e s    ̀

L o a d i n g W o r k D o w n O n e L e v e l  

W e n o w c o n s i d e r w h a t e x a c t l y c o n s t i t u t e s d o w n l o a d i n g w o r k f r o m l e v e l    ̀ + 1 t o l e v e l    ̀ , a s s u m i n g   l r     ̀ ] i s  n i l  b u t 

l r     ̀ + 1 ] i s n o t . I f   m  = 2 

 ̀

, d o w n l o a d i n g w o r k f r o m l e v e l    ̀ + 1 t o l e v e l    ̀ i n v o l v e s r e o r g a n i z i n g t h e   m  - w a y m e r g e  

a l i a t e d w i t h t h e a c t i v e r u n - r e c o r d   r r 

 ̀ + 1 

o f l e v e l    ̀ + 1 i n t o a  

m  - w a y m e r g e o f  

m  - w a y r u n s e a c h t h e o u t p u t o f a  

m  - w a y m e r g e . W e u s e t h e p r o c e d u r e   c o n s t r u c t  ( ) i n o r d e r t o b r i n g a b o u t s u c h a r e o r g a n i z a t i o n .  

1 2 1 

Page 135: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 135/203

A s s u m i n g t h a t l e v e l - r e c o r d   l r     ̀ + 1 ] i s n o t   n i l  a n d l e v e l - r e c o r d   l r     ̀ ] i s  n i l  , w e u s e t h e p r o c e d u r e   l o a d l e v e l  (   ̀ ) , 

d e s c r i b e d b e l o w , t o d o w n l o a d t h e a c t i v e r u n - r e c o r d   r r 

 ̀ + 1 

f r o m   l r     ̀ + 1 ] t o   l r     ̀ ] , a p p r o p r i a t e l y u p d a t i n g   l r     ̀ + 1 ] i n  

t h e p r o c e s s .  

1 . L e t   r r 

n e w 

b e a n e w r u n - r e c o r d .  

2 . I f    ̀ + 1 =  m a x l e v e l   a n d  l r     ̀ + 1 ]  c u r r e n t   =  l r     ̀ + 1 ]  r r  O r d e r   <  2 

 ̀

, t h e n  

( a ) S e t   r r 

n e w 

t o b e t h e r u n - r e c o r d   l r     ̀ + 1 ]  r r 

3 . E l s e  

( a ) L e t   m  = 2 

 ̀

a n d l e t   L 

b e t h e b l o c k e d l i s t c o n t a i n i n g  

m  r u n - r e c o r d s , i m p l i c i t l y r e p r e s e n t e d b y t h e  

e l d   r r 

 ̀ + 1 

s p l i t t e r s   o f t h e a c t i v e r u n - r e c o r d   r r 

 ̀ + 1 

o f l e v e l    ̀ + 1

( b ) D i s c a r d t h e r u n - r e c o r d   r r 

 ̀ + 1 

, e x e c u t e   c o n s t r u c t  (  r r 

n e w 

; L 

) t o a p p r o p r i a t e l y i n i t i a l i z e r u n - r e c o r d   r r 

n e w 

a n d l e t   r r 

n e w 

n o w t a k e t h e p l a c e o f t h e o l d r u n - r e c o r d   r r 

 ̀ + 1 

o n d i s k .  

4 . S e t   l r     ̀ ]  r r  t o s t o r e t h e d i s k l o c a t i o n o f r u n - r e c o r d   r r 

n e w 

, s e t   l r     ̀ ]  c u r r e n t   = 0 a n d s e t  l r     ̀ ]  a c t i v e   =  r r 

n e w 

i n p u t s  

s o i t p o i n t s t o t h e r s t r u n - r e c o r d o f t h e l i s t r e p r e s e n t e d b y   r r 

n e w 

i n p u t s  

5 . I f   l r     ̀ + 1 ]  c u r r e n t     l r     ̀ + 1 ]  r r  O r d e r     1 t h e n  

( a ) I f    ̀ + 1 =   ̀

m a x 

a n d  l r     ̀ + 1 ]  c u r r e n t   =  W 

t o p 

  1 , t h e n  

i . S e t   l r     ̀ + 1 ]  c u r r e n t   t o t h e v a l u e   l r     ̀ + 1 ]  r r  O r d e r  

i i . S e t   l r     ̀ + 1 ]  a c t i v e   t o s t o r e t h e l o c a t i o n o f r u n - r e c o r d   l r     ̀ + 1 ]  r r 

( b ) O t h e r w i s e , i n c r e m e n t t h e v a l u e o f   l r     ̀ + 1 ]  c u r r e n t   b y 1 . T h e n , i f   l r     ̀ + 1 ]  c u r r e n t   <  l r     ̀ + 1 ]  r r  O r d e r     1 , 

s e t  l r     ̀ + 1 ]  a c t i v e   t o s t o r e t h e l o c a t i o n o f t h e   l r     ̀ + 1 ]  c u r r e n t   - t h r u n - r e c o r d o f l i s t   l r     ̀ + 1 ]  r r  i n p u t s   ; e l s e  

s e t  l r     ̀ + 1 ]  a c t i v e   t o s t o r e t h e l o c a t i o n o f r u n - r e c o r d   l r     ̀ + 1 ]  r r 

6 . E l s e ( t h a t i s ,   l r     ̀ + 1 ]  c u r r e n t   =  l r     ̀ + 1 ]  r r  O r d e r  ) 

( a ) S e t   l r     ̀ + 1 ] t o   n i l 

( b ) I f   m a x l e v e l   =   ̀ + 1 , s e t   m a x l e v e l   t o   ̀ a n d s e t   r r 

g l o b a l  

t o b e t h e r u n - r e c o r d p o i n t e d b y   l r    m a x l e v e l  ]  r r 

T h e f o l l o w i n g l e m m a f o l l o w s f r o m L e m m a 3 0 , L e m m a 2 7 a n d t h e o b s e r v a t i o n t h a t t h e l i s t i n v o l v e d i n t h e  

c o n s t r u c t  ( ) o p e r a t i o n o f S t e p 3 b c o n t a i n s  

m  r u n - r e c o r d s .  

1 2 2 

Page 136: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 136/203

L e m m a 3 9   S u p p o s e t h a t   m  = 2 

 ̀

, l r     ̀ ] =  n i l a n d l r     ̀ + 1 ]  6=  n i l , w h e r e   1    ` <  m a x l e v e l , a t s o m e t i m e d u r i n g o u r  

a l g o r i t h m . T h e n t h e e x e c u t i o n o f p r o c e d u r e l o a d l e v e l  (   ̀ )  d e s c r i b e d a b o v e t a k e s n o m o r e t h a n   O  ( 

m  )  I / O o p e r a t i o n s  

a n d c a n b e i m p l e m e n t e d u s i n g   O  ( 1 )  b l o c k s o f i n t e r n a l m e m o r y .  

T h e s i g n i c a n c e o f t h e u p p e r b o u n d o n i n t e r n a l m e m o r y a b o v e i s t h a t p r o c e d u r e   l o a d l e v e l  (   ̀ ) c a n b e e x e c u t e d  

o v e r   O  ( 

m = B  + 1 ) I / O o p e r a t i o n s p o s s i b l y s p a n n i n g s e v e r a l a r b i t r a r y a l l o c a t i o n p h a s e s , s i n c e t h e c o n s t a n t    

m o d e l  

w i l l b e s e t t o a v a l u e l a r g e r t h a n t h e n u m b e r o f b l o c k s r e q u i r e d i n   l o a d l e v e l  (   ̀ ) f o r a n y    ̀

I n  M A M e r g e  , t h e o n l y t i m e n e w r u n - r e c o r d s a r e c r e a t e d i s d u r i n g   l o a d l e v e l  ( ) o p e r a t i o n s . U s i n g L e m m a 2 8 a n d  

t h e f a c t t h a t t h e l i s t   L 

p a s s e d a s a r g u m e n t t o   c o n s t r u c t  ( ) d u r i n g   l o a d l e v e l  ( ) c o n t a i n s  

m  r u n - r e c o r d s , w e h a v e  

t h e f o l l o w i n g l e m m a .  

L e m m a 4 0   S u p p o s e t h a t   m  = 2 

 ̀

, l r     ̀ ] =  n i l a n d l r     ̀ + 1 ]  6=  n i l , w h e r e   1    ` <  m a x l e v e l , a t s o m e t i m e d u r i n g o u r  

a l g o r i t h m . T h e n t h e t o t a l n u m b e r o f n e w r u n - r e c o r d s c r e a t e d d u r i n g l o a d l e v e l  (   ̀ )  i s n o m o r e t h a n   O  ( 

m  ) 

W e a l s o m a k e t h e c r u c i a l o b s e r v a t i o n t h a t   l o a d l e v e l  (   ̀ ) m a i n t a i n s t h e i n v a r i a n t s p r o p o s e d i n S e c t i o n 5 . 8 . 5 .  

L e m m a 4 1   T h e i n v a r i a n t s o f S e c t i o n 5 . 8 . 5 r e m a i n t r u e a f t e r t h e e x e c u t i o n o f l o a d l e v e l  (   ̀ ) 

P r o o f  : S i n c e   l r     ̀ ] =  n i l  a n d s i n c e   l r     ̀ + 1 ] s a t i s e s i n v a r i a n t 1 1 a p r i o r t o   l o a d l e v e l  (   ̀ ) , t h e l i s t   S 

 ̀ + 1 

d e n e d i n  

i n v a r i a n t 1 1 c o n t a i n s a t m o s t    ̀   1 r u n - r e c o r d s w i t h   a g  e l d s s e t t o   N o t D o n e  

F i r s t w e w i l l p r o v e t h a t   l r     ̀ ] s a t i s e s a l l t h e i n v a r i a n t s a f t e r t h e e x e c u t i o n o f   l o a d l e v e l  (   ̀ ) . C o n s i d e r t h e a c -  

t i v e r u n - r e c o r d   r r 

 ̀ + 1 

o f l e v e l    ̀ + 1 j u s t b e f o r e   l o a d l e v e l  (   ̀ ) i s e x e c u t e d . I n t h e c a s e w h e n    ̀ + 1 =  m a x l e v e l   a n d 

l r     ̀ + 1 ]  c u r r e n t   =  l r     ̀ + 1 ]  r r  O r d e r   <  2 

 ̀

,  r r 

 ̀ + 1 

h a p p e n s t o b e t h e r u n - r e c o r d p o i n t e d b y   l r     ̀ + 1 ]  r r  . I n v a r i a n t 8  

i m p l i e s t h a t   r r 

 ̀ + 1 

O r d e r   = 2 

f o r a n i n t e g e r   x  s u c h t h a t   x     ̀   1 . T h u s , t h e a s s i g n m e n t m a k i n g   l r     ̀ ]  r r  s t o r e  

t h e l o c a t i o n o f t h e r u n - r e c o r d   r r 

 ̀ + 1 

, t h e o t h e r a s s i g n m e n t s i n S t e p 4 , a n d t h e f a c t t h a t   m a x l e v e l   d e c r e a s e s t o  

 ̀ , e n s u r e t h a t   l r     ̀ ] s a t i s e s t h e i n v a r i a n t s a f t e r t h e e x e c u t i o n o f   l o a d l e v e l  (   ̀ ) . W h e n a n y o n e o f t h e c o n d i t i o n s  

 ̀ + 1 =  m a x l e v e l   a n d  l r     ̀ + 1 ]  c u r r e n t   =  l r     ̀ + 1 ]  r r  O r d e r   <  2 

 ̀

a r e n o t s a t i s e d , t h e r u n - r e c o r d   r r 

 ̀ + 1 

n e c e s s a r -  

i l y h a s   r r 

 ̀ + 1 

O r d e r   = 2 

 ̀

. I n S t e p 3 b , w e r e p l a c e t h i s r u n - r e c o r d o n d i s k w i t h a n a p p r o p r i a t e l y c o n s t r u c t e d n e w  

r u n - r e c o r d   r r 

n e w 

w i t h   r r 

n e w 

O r d e r   = 2 

 ̀   1 

. T h u s , t h e a s s i g n m e n t m a k i n g   l r     ̀ ]  r r  s t o r e t h e l o c a t i o n o f t h i s n e w l y  

c o n s t r u c t e d r u n - r e c o r d a n d t h e o t h e r a s s i g n m e n t s i n S t e p 4 e n s u r e t h a t   l r     ̀ ] s a t i s e s t h e i n v a r i a n t s a f t e r t h e e x e c u t i o n  

o f  l o a d l e v e l  (   ̀ )

W e w i l l p r o v e t h a t   l r     ̀ + 1 ] s a t i s e s t h e i n v a r i a n t s a f t e r t h e e x e c u t i o n o f   l o a d l e v e l  (   ̀ ) . I f   l r     ̀ + 1 ]  c u r r e n t   w a s 

l r     ̀ + 1 ]  O r d e r   p r i o r t o   l o a d l e v e l  (   ̀ ) , t h e n   l r     ̀ + 1 ] b e c o m e s   n i l  t r i v i a l l y s a t i s f y i n g a l l i n v a r i a n t s . S t e p 5 e n s u r e s t h a t  

i n v a r i a n t s 6 a n d 7 r e m a i n t r u e e v e n a f t e r   l o a d l e v e l  (   ̀ ) . I n t h e c a s e w h e n   l r     ̀ + 1 ] i s n o t   n i l  a f t e r t h e e x e c u t i o n o f  

1 2 3 

Page 137: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 137/203

l o a d l e v e l  ( ) , w e n o w c o n s i d e r t h e p a r t s o f i n v a r i a n t 1 1 . A f t e r t h e e x e c u t i o n o f   l o a d l e v e l  (   ̀ ) , t h e s e t o f r u n - r e c o r d s i n l i s t  

 ̀ + 1 

h a s a t m o s t o n e r u n - r e c o r d w i t h   a g  s e t t o   N o t D o n e m o r e   t h a n j u s t b e f o r e   l o a d l e v e l  (   ̀ ) . B u t s i n c e t h e m a x i m u m  

n u m b e r o f r u n - r e c o r d s i n   S 

 ̀ + 1 

p r i o r t o   l o a d l e v e l  (   ̀ ) i s   ̀   1 , i n v a r i a n t 1 1 a r e m a i n s t r u e e v e n a f t e r   l o a d l e v e l  (   ̀ ) . T h e  

i n v a r i a n t 1 1 b r e m a i n s t r u e o f   S 

 ̀ + 1 

e v e n a f t e r   l o a d l e v e l  (   ̀ ) b e c a u s e t h e o n l y c h a n g e a m o n g l e v e l - r e c o r d s o f l e v e l s l o w e r  

t h a n    ̀ + 1 i s t h a t   l r     ̀ ]  r r  n o w s t o r e s t h e l o c a t i o n o f t h e r u n - r e c o r d   r r 

n e w 

w h i c h l i e s i n t h e l i s t   l r     ̀ + 1 ]  i n p u t s   . T h e  

i n v a r i a n t 1 1 c r e m a i n s t r u e o f o r d e r e d l i s t   S 

 ̀ + 1 

a f t e r   l o a d l e v e l  (   ̀ ) s i n c e t h e l a s t e l e m e n t o f   S 

 ̀ + 1 

i s t h e r u n - r e c o r d  

p o i n t e d b y   l r     ̀ ]  r r  , w h i c h i s a t t h e h i g h e s t l e v e l l o w e r t h a n l e v e l    ̀ + 1

I n c a s e   m a x l e v e l   d e c r e a s e s d u r i n g   l o a d l e v e l  ( ) , t h e r u n a s s o c i a t e d t o t h e r u n - r e c o r d p o i n t e d b y   l r    m a x l e v e l  ]  r r 

i s l o g i c a l l y t h e s a m e a s t h e o n e a s s o c i a t e d w i t h t h e r u n - r e c o r d p o i n t e d b y t h e   l r    m a x l e v e l  ]  r r  w i t h t h e o l d v a l u e o f  

m a x l e v e l  , s o i n v a r i a n t 4 r e m a i n s t r u e .  

I t c a n b e e a s i l y v e r i e d t h a t t h e o t h e r i n v a r i a n t s r e m a i n t r u e a f t e r t h e e x e c u t i o n o f   l o a d l e v e l  (   ̀ ) a s w e l l . T h u s t h e  

l e m m a i s p r o v e d .  

L o a d i n g W o r k D o w n S e v e r a l L e v e l s  

C o n s i d e r t h e p r o b l e m o f d o w n l o a d i n g w o r k t o l e v e l   k  w h e n s e v e r a l l e v e l s   k ; k  + 1  ;    ;  ̀ h a v e l e v e l - r e c o r d s s e t t o   n i l 

a n d o n l y t h e l e v e l - r e c o r d   l r     ̀ + 1 ] o f l e v e l    ̀ + 1 i s n o t   n i l  . I n s u c h a s i t u a t i o n ,   M A M e r g e   h a s t o d o w n l o a d w o r k t o  

l e v e l   k  f r o m l e v e l    ̀ + 1 a n d i t d o e s s o u s i n g t h e p r o c e d u r e   d o w n l o a d   (  k  ) d e s c r i b e d b e l o w .  

1 . T r a v e r s e t h e ( b l o c k e d ) l i s t o f l e v e l - r e c o r d s b e g i n n i n g w i t h   l r    k  + 1 ] u n t i l a l e v e l - r e c o r d   l r     ̀ + 1 ] s u c h t h a t  

l r     ̀ + 1 ]  6=  n i l  i s f o u n d .  

2 . E x e c u t e   l o a d l e v e l  (  i  ) f o r   i  g o i n g f r o m    ̀ d o w n t o   k 

T h u s , d u r i n g t h e e x e c u t i o n o f   d o w n l o a d   (  k  ) ,  M A M e r g e   e n d s u p d o w n l o a d i n g w o r k t o t h e o t h e r l e v e l s   k  + 1  ;    ;  ̀ t h a t  

h a d t h e i r l e v e l - r e c o r d s s e t t o   n i l  a s w e l l .  

D e n i t i o n 4 4   W e s a y t h a t t h e e x e c u t i o n o f   d o w n l o a d   (  k  )  l o a d s   l e v e l s   k  t h r o u g h    ̀ , w h e r e    ̀ i s a s d e n e d a b o v e . T h e  

h i g h e s t l e v e l   l o a d e d   b y  d o w n l o a d   (  k  ) i s l e v e l    ̀

U s i n g L e m m a 3 9 a n d t h e i n v a r i a n t s o f S e c t i o n 5 . 8 . 5 , w e h a v e t h e f o l l o w i n g l e m m a r e g a r d i n g r e s o u r c e c o n s u m p t i o n  

d u r i n g t h e e x e c u t i o n o f   d o w n l o a d   (  k  )

L e m m a 4 2   S u p p o s e   m  = 2 

 ̀

w h e r e    ̀ i s t h e h i g h e s t l e v e l t h a t i s l o a d e d b y d o w n l o a d   (  k  )  . T h e t o t a l n u m b e r o f I / O  

o p e r a t i o n s i n v o l v e d i n r s t t r a v e r s i n g t h e l i s t o f l e v e l - r e c o r d s l r   1 ]  t h r o u g h l r     k  ]  a n d t h e n e x e c u t i n g d o w n l o a d   (  k  )  i s 

O  ( 

m  )  . T h e d o w n l o a d  (  k  )  o p e r a t i o n c a n b e i m p l e m e n t e d s u c h t h a t i t r e q u i r e s n o m o r e t h a n   O  ( 1 )  i n t e r n a l m e m o r y  

b l o c k s .  

1 2 4 

Page 138: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 138/203

Page 139: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 139/203

5 . 8 . 8 P u t t i n g   d o w n l o a d   ( ) a n d   l l m e r g e   ( ) T o g e t h e r  

W e d e s c r i b e h o w t o c o m b i n e t h e   d o w n l o a d   ( ) p r o c e d u r e , u s e d t o d y n a m i c a l l y r e o r g a n i z e m e r g i n g c o m p u t a t i o n , a n d t h e  

l l m e r g e   ( ) p r o c e d u r e , u s e d t o m e r g e p h y s i c a l s e q u e n c e s i n a p p r o p r i a t e m e r g e o p e r a t i o n s , t o g e t h e r w i t h t h e r u n - r e c o r d  

a n d l e v e l - r e c o r d d a t a s t r u c t u r e s t o r e a l i z e t h e m e m o r y - a d a p t i v e m e r g i n g r o u t i n e   M A M e r g e   t h a t m e r g e s t o g e t h e r    

r u n s . B y u s i n g   M A M e r g e   i n o u r f r a m e w o r k o f S e c t i o n 5 . 5 . 2 a s d e s c r i b e d a t t h e b e g i n n i n g o f S e c t i o n 5 . 8 , w e o b t a i n  

a m e m o r y - a d a p t i v e m e r g e s o r t .  

I n o r d e r t o c o m p l e t e t h e d e s c r i p t i o n o f o u r m e m o r y - a d a p t i v e s o r t i n g a l g o r i t h m w e n e e d t o d e n e t h e c o n s t a n t  

 

l e v e l  

u s e d i n o u r d e n i t i o n o f a l l o c a t i o n l e v e l s , a n d t h e c o n s t a n t    

m o d e l  

i n t h e c o n t e x t o f o u r m e m o r y - a d a p t i v e  

m e r g e s o r t .  

D e n i t i o n 4 5   T h e c o n s t a n t    

l e v e l  

i s d e n e d t o b e    

l e v e l  

= (   

l l m 

+   

d l 

)  =  2 . T h e c o n s t a n t    

m o d e l  

i s d e n e d t o b e  

 

m o d e l  

=  d  2   

l e v e l  

I f  m  i s o f t h e f o r m 2  

 ̀

, w h e r e 1      ̀    ̀

m a x 

, t h e n t h e n u m b e r 2   

l e v e l  

m  o f I / O o p e r a t i o n s i n a l e v e l    ̀ a l l o c a t i o n  

p h a s e o f s i z e    

l e v e l  

m  i s l a r g e e n o u g h t o r s t a c c o m m o d a t e    

d l 

m  I / O o p e r a t i o n s ( c o r r e s p o n d i n g t o t h e s e q u e n c e o f  

d o w n l o a d   ( ) o p e r a t i o n s i n L e m m a 4 3 ) \ l o a d i n g " l e v e l    ̀ a n d t h e n p e r m i t t h e s m a l l e s t n u m b e r    

l l m 

m  o f I / O o p e r a t i o n s  

i n v o l v e d i n a g o o d   l l m e r g e   (  r r  ) c a l l , w h e r e   r r  =  r r 

 ̀

, t h e a c t i v e r u n - r e c o r d o f l e v e l    ̀ . T h e s m a l l e s t s i z e    

m o d e l  

o f a n  

a l l o c a t i o n p h a s e i s s u c h a s t o p e r m i t a b i n a r y m e r g e d u r i n g a p h a s e o f t h a t s i z e .  

N e x t w e d e n e s o m e u s e f u l a b b r e v i a t i o n s u s e d i n o u r d e s c r i p t i o n o f   M A M e r g e  

D e n i t i o n 4 6   W e u s e t h e s y m b o l  c l e v e l   t o m e a n t h e c u r r e n t a l l o c a t i o n l e v e l  l e v e l  (  m e m  ) . I f    ̀   m a x l e v e l  , w e d e n e  

t h e p r e d i c a t e   e n o u g h   (   ̀ ) t o b e t r u e w h e n e v e r t h e i n v a r i a n t 2 b o f S e c t i o n 5 . 8 . 6 i s s a t i s e d a n d f a l s e o t h e r w i s e . I f  

` >  m a x l e v e l  , w e d e n e t h e p r e d i c a t e   e n o u g h   (   ̀ ) t o b e t r u e w h e n e v e r t h e i n v a r i a n t 3 b o f S e c t i o n 5 . 8 . 6 i s s a t i s e d a n d  

f a l s e o t h e r w i s e .  

A l g o r i t h m   M A M e r g e  

T h e a l g o r i t h m   M A M e r g e   c a n b e s u m m a r i z e d a s f o l l o w s :  

1 . I f t h e a l l o c a t i o n l e v e l i s    ̀   m a x l e v e l   a n d t h e r e i s w o r k a s s o c i a t e d w i t h l e v e l    ̀ ( m e a n i n g   l r     ̀ ]  6=  n i l  ) , t h e n  

e x e c u t e   l l m e r g e   (  r r  ) . I f   ` >  m a x l e v e l  , e x e c u t e   l l m e r g e   (  r r 

g l o b a l  

)

2 . I f t h e a l l o c a t i o n l e v e l i s    ̀ a n d  l r     ̀ ] =  n i l  , t h e n d o w n l o a d s o m e w o r k t o l e v e l    ̀ b y e x e c u t i n g   d o w n l o a d   (   ̀ )

A m o r e p r e c i s e d e s c r i p t i o n i s a s f o l l o w s :  

1 2 6 

Page 140: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 140/203

1 . E x e c u t e t h e p r e p r o c e s s i n g s t a g e o f S e c t i o n 5 . 8 . 3 a n d t h e n t h e i n i t i a l i z a t i o n o f l e v e l - r e c o r d s a s i n d i c a t e d i n  

S e c t i o n 5 . 8 . 4 .  

2 . U n t i l   r r 

g l o b a l  

a g  6=  D o n e  , d o :  

( a ) L e t  

 ̂

 ̀ = m i n  f  c l e v e l  ;  m a x l e v e l  g 

( b ) L o a d l e v e l - r e c o r d s i n a b l o c k e d m a n n e r b e g i n n i n g w i t h   l r  1 ] u n t i l   l r   

 ̂

 ̀ ] i n t o m e m o r y . .  

( c ) I f   c l e v e l   >  m a x l e v e l   t h e n  

i . E x e c u t e   l l m e r g e   (  r r 

g l o b a l  

)

i i . W h e n t h e c a l l   l l m e r g e   (  r r 

g l o b a l  

) r e t u r n s c o n t r o l , i f   r r 

g l o b a l  

a g  =  D o n e  , t h e n   M A M e r g e   i s c o m p l e t e d .  

i i i . I f t h e c a l l   l l m e r g e   (  r r 

g l o b a l  

) r e t u r n s c o n t r o l a t a t i m e w h e n t h e a l l o c a t i o n l e v e l   l e v e l  (  n e x t  ) o f t h e  

f o l l o w i n g p h a s e i s   m a x l e v e l   o r s m a l l e r , t h e n r e l i n q u i s h t h e r e m a i n i n g p o r t i o n o f t h e c u r r e n t p h a s e ,  

w h o s e a l l o c a t i o n l e v e l m u s t n e c e s s a r i l y b e g r e a t e r t h a n   m a x l e v e l  . O t h e r w i s e p r o c e e d i m m e d i a t e l y t o  

t h e f o l l o w i n g s t e p  

i v . G o T o S t e p 2 a .  

( d ) W h e n e x e c u t i o n r e a c h e s t h i s p o i n t , w e h a v e   c l e v e l     m a x l e v e l   a n d w e n e e d t o c o n s i d e r t h e t w o c a s e s  

l r    c l e v e l  ] =  n i l  a n d  l r    c l e v e l  ]  6=  n i l 

i . I f (  l r    c l e v e l  ] =  n i l  ) , t h e n  

A . I f   c l e v e l   =  m a x l e v e l  , t h e n   M A M e r g e   i s c o m p l e t e d ; o t h e r w i s e e x e c u t e   d o w n l o a d   (  c l e v e l  )

B . W h e n t h e c a l l  d o w n l o a d   ( ) r e t u r n s c o n t r o l , t h e l e v e l o f a l l o c a t i o n   c l e v e l   m a y h a v e c h a n g e d s i n c e  

t h e t i m e t h e c a l l i s m a d e . I f   e n o u g h   (  c l e v e l  ) i s f a l s e f o r t h e n e w v a l u e o f   c l e v e l  , t h e n r e l i n q u i s h t h e  

r e m a i n i n g p o r t i o n o f t h e a l l o c a t i o n p h a s e o n g o i n g w h e n   d o w n l o a d   ( ) r e t u r n s . I f   e n o u g h   (  c l e v e l  ) i s 

t r u e , t h e n p r o c e e d i m m e d i a t e l y t o t h e f o l l o w i n g s t e p .  

C . G o T o S t e p 2 a .  

i i . E l s e  

A . W h i l e   e n o u g h   (  c l e v e l  ) A N D   l r    c l e v e l  ]  6=  N I L  , e x e c u t e   l l m e r g e   (  r r 

c l e v e l  

) , w h e r e   r r 

c l e v e l  

i s t h e a c t i v e  

r u n - r e c o r d o f l e v e l   c l e v e l  

B . W h e n t h e l a s t c a l l   l l m e r g e   (  r r 

c l e v e l  

) o f t h e w h i l e l o o p r e t u r n s , i f   e n o u g h   (  c l e v e l  ) i s f a l s e , t h e n  

r e l i n q u i s h t h e r e m a i n i n g p o r t i o n o f t h e o n g o i n g a l l o c a t i o n p h a s e ; o t h e r w i s e p r o c e e d i m m e d i a t e l y  

t o t h e f o l l o w i n g s t e p .  

C . G o T o S t e p 2 a .  

1 2 7 

Page 141: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 141/203

R e l i n q u i s h e d I / O O p e r a t i o n s  

S i n c e i n v a r i a n t 2 b ( r e s p e c t i v e l y i n v a r i a n t 3 b ) h a s t o b e m e t a t t h e t i m e t h e c a l l t o   l l m e r g e   (  r r 

 ̀

) ( r e s p e c t i v e l y  

l l m e r g e   (  r r 

g l o b a l  

) ) i s m a d e ,   M A M e r g e   s o m e t i m e s r e l i n q u i s h e s a p o r t i o n o f a n a l l o c a t i o n p h a s e . W e c o u n t t h e r e -  

l i n q u i s h e d I / O o p e r a t i o n s a m o n g I / O o p e r a t i o n s i n c u r r e d b y   M A M e r g e   b y u s i n g t h e f o l l o w i n g c h a r g i n g s c h e m e .  

D e n i t i o n 4 7   W h e n e v e r   M A M e r g e   r e l i n q u i s h e s p a r t o f a n a l l o c a t i o n i m m e d i a t e l y a f t e r e x e c u t i n g a   d o w n l o a d   ( ) 

o p e r a t i o n , w e c h a r g e t h e r e l i n q u i s h e d I / O o p e r a t i o n s t o t h a t p a r t i c u l a r   d o w n l o a d   ( ) o p e r a t i o n . W h e n e v e r   M A M e r g e  

r e l i n q u i s h e s p a r t o f a n a l l o c a t i o n i m m e d i a t e l y a f t e r e x e c u t i n g a n   l l m e r g e   ( ) o p e r a t i o n , w e c h a r g e t h e r e l i n q u i s h e d I / O  

o p e r a t i o n s t o t h a t p a r t i c u l a r   l l m e r g e   ( ) o p e r a t i o n .  

F i r s t w e a c c o u n t f o r I / O o p e r a t i o n s c h a r g e d t o   d o w n l o a d   ( ) o p e r a t i o n s b y u s i n g t h e n o t i o n o f   ` ; d  - s e q u e n c e s , w h i c h  

a r e s e q u e n c e s o f   d  c o n s e c u t i v e   d o w n l o a d   ( ) o p e r a t i o n s , p o s s i b l y f o l l o w e d b y a r e l i n q u i s h o p e r a t i o n .  

D e n i t i o n 4 8   C o n s i d e r a s e q u e n c e o f   d  c o n s e c u t i v e   d o w n l o a d   (   ̀

) o p e r a t i o n s , w h e r e 0     i    d    1 a n d   d    1 , 

t h a t s a t i s f y t h e c o n d i t i o n s m e n t i o n e d i n L e m m a 4 3 . a n d l e t    ̀ b e a s d e n e d i n L e m m a 4 3 . W e c a l l t h e a b o v e  

s e q u e n c e o f   d  d o w n l o a d   ( ) o p e r a t i o n s a n   ` ; d  - s e q u e n c e i f t h e r s t t i m e   M A M e r g e   e i t h e r r e l i n q u i s h e s I / O o p e r a t i o n s  

( i n S t e p 2 ( d ) i B a b o v e ) o r e x e c u t e s a n   l l m e r g e   ( ) o p e r a t i o n a f t e r i t e x e c u t e s   d o w n l o a d   (   ̀

) i s o n l y i m m e d i a t e l y a f t e r  

i t e x e c u t e s   d o w n l o a d   (   ̀

d    1 

)

W e m a k e a c r u c i a l o b s e r v a t i o n r e g a r d i n g   ` ; d  - s e q u e n c e s .  

L e m m a 4 6   C o n s i d e r a n y   ` ; d  - s e q u e n c e d o w n l o a d   (   ̀

)  ; : : : ;  d o w n l o a d   (   ̀

d    1 

)  a n d l e t   m  = 2 

 ̀

. I f , a t a n y t i m e a f t e r  

d o w n l o a d   (   ̀

)  b e g i n s a n d b e f o r e d o w n l o a d   (   ̀

d    1 

)  e n d s , M A M e r g e i s s u b j e c t e d t o a n a l l o c a t i o n p h a s e o f s i z e   m 

s u c h  

t h a t l e v e l  (  m 

)     ̀ , t h e n t h e e x e c u t i o n o f d o w n l o a d   (   ̀

d    1 

)  i s i m m e d i a t e l y f o l l o w e d ( t h a t i s , w i t h o u t r e l i n q u i s h i n g  

a n y I / O s ) b y t h e e x e c u t i o n o f l l m e r g e  (  r r  )  , w h e r e    ̀

=  l e v e l  (  m 

)  a n d r r i s t h e a c t i v e r u n - r e c o r d r r  

 ̀

o f l e v e l    ̀

i f 

 ̀

  m a x l e v e l a n d t h e r u n - r e c o r d r r  

g l o b a l  

o t h e r w i s e .  

P r o o f  : F r o m L e m m a 4 3 , w e k n o w t h a t t h e t o t a l n u m b e r o f I / O o p e r a t i o n s r e q u i r e d o v e r t h e e n t i r e   ` ; d  - s e q u e n c e  

i s n o m o r e t h a n    

d l 

m  . S u p p o s e t h a t a f t e r   d o w n l o a d   (   ̀

) b e g i n s e x e c u t i o n a n d b e f o r e   d o w n l o a d   (   ̀

d    1 

) c o m p l e t e s  

e x e c u t i o n ,   M A M u l t i p l y   g e t s a n a l l o c a t i o n p h a s e o f s i z e   m 

w h e r e   m 

i s a s d e n e d a b o v e . T h e n e v e n i f a l l    

d l 

I / O o p e r a t i o n s c o r r e s p o n d i n g t o t h e   ` ; d  - s e q u e n c e o c c u r r e d d u r i n g t h e p h a s e o f s i z e   m 

, t h a t p h a s e i s s t i l l l e f t w i t h  

 

l l m 

 

p e n d i n g I / O o p e r a t i o n s t h a t w o u l d c a u s e   e n o u g h   (  l e v e l  (  m 

) ) t o e v a l u a t e t o t r u e : T h i s f o l l o w s f r o m t h e  

d e n i t i o n o f    

l e v e l  

a b o v e . F u r t h e r m o r e , b y d e n i t i o n o f   ` ; d  - s e q u e n c e , t h e   d  t h  d o w n l o a d   ( ) o p e r a t i o n   d o w n l o a d   (   ̀

d    1 

o f t h e   ` ; d  - s e q u e n c e c a n n o t b e i m m e d i a t e l y f o l l o w e d b y a n o t h e r   d o w n l o a d   ( ) o p e r a t i o n s o   l l m e r g e   (  r r  ) i s t h e n e x t  

o p e r a t i o n e x e c u t e d b y   M A M e r g e  . T h u s t h e l e m m a i s p r o v e d .  

1 2 8 

Page 142: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 142/203

Page 143: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 143/203

5 . 9 . 1 R e s o u r c e C o n s u m p t i o n o f   d o w n l o a d   ( ) c a l l s , b a d  

l l m e r g e   ( ) c a l l s a n d   l l m e r g e   (  r r 

g l o b a l  

) c a l l s  

B y d e n i t i o n , a l l o c a t i o n p h a s e s u t i l i z e d b y   M A M e r g e   f o r t h e e x e c u t i o n o f   d o w n l o a d   ( ) c a l l s , b a d   l l m e r g e   ( ) c a l l s ,  

a n d  l l m e r g e   (  r r 

g l o b a l  

) c a l l s , c a n b e n o n o p t i m a l p h a s e s . H e r e w e s h o w t h a t t h e n e t r e s o u r c e c o n s u m p t i o n o v e r a l l s u c h  

a c t i v i t y d u r i n g   M A M e r g e   i s n o m o r e t h a n   O  (  n 

l g  m 

m a x 

) , w h e r e   n 

i s t h e t o t a l n u m b e r o f b l o c k s i n t h e t h e     r u n s  

b e i n g m e r g e d b y   M A M e r g e  

R e s o u r c e c o n s u m p t i o n d u r i n g   d o w n l o a d   ( ) c o m p u t a t i o n  

A s w e n o t e d e a r l i e r ,   d o w n l o a d   ( ) c o m p u t a t i o n i s m e m o r y - o b l i v i o u s : S i n c e i t n e v e r r e q u i r e s m o r e t h a n    

m o d e l  

b l o c k s i t  

c a n b e c a r r i e d o u t d u r i n g a l l o c a t i o n p h a s e ( s ) a t a r b i t r a r y l e v e l s . E v e r y   ` ; d  - s e q u e n c e i n v o l v e s a   l o a d l e v e l  (   ̀ ) o p e r a t i o n .  

W e b o u n d t h e r e s o u r c e c o n s u m p t i o n o f a l l t h e   d o w n l o a d   ( ) o p e r a t i o n s t h a t o c c u r i n c o u r s e o f t h e a l g o r i t h m b y  

b o u n d i n g t h e m a x i m u m p o s s i b l e n u m b e r o f   l o a d l e v e l  (   ̀ ) o p e r a t i o n s i n c o u r s e o f t h e a l g o r i t h m , f o r 1      ̀    ̀

m a x 

  1 , 

a n d t h e n u s i n g L e m m a 4 7 .  

F i r s t w e m a k e a n o b s e r v a t i o n t h a t b o u n d s t h e m a x i m u m n u m b e r o f t i m e s l e v e l   ̀ c a n b e i n v o l v e d i n a   l o a d l e v e l  (   ̀   1 ) 

o p e r a t i o n a t a s t r e t c h , w i t h o u t t h e o c c u r r e n c e o f a   l o a d l e v e l  (   ̀ ) o p e r a t i o n .  

L e m m a 4 9   S u p p o s e t h a t   1    ` <  ̀

m a x 

. T h e n , i f    ̀ + 1  <  ̀

m a x 

, t h e m a x i m u m n u m b e r o f l o a d l e v e l  (   ̀ )  o p e r a t i o n s t h e  

l e v e l - r e c o r d l r      ̀ + 1 ]  c a n b e i n v o l v e d i n b e f o r e i t b e c o m e s n i l i s l r      ̀ + 1 ]  r r  O r d e r   + 1  i f   ̀ + 1  <  ̀

m a x 

; i f   ̀ + 1 =   ̀

m a x 

t h e m a x i m u m n u m b e r o f l o a d l e v e l  (   ̀ )  o p e r a t i o n s t h e l e v e l - r e c o r d l r      ̀ + 1 ]  c a n b e i n v o l v e d i n b e f o r e i t b e c o m e s n i l i s  

t o p 

+ 1 

S i n c e e a c h   ` ; d  - s e q u e n c e n e c e s s a r i l y i n c l u d e s a   l o a d l e v e l  (   ̀ ) o p e r a t i o n , w e h a v e t h e f o l l o w i n g l e m m a .  

L e m m a 5 0   C o n s i d e r a n y l e v e l   ̀

m a x 

  j  , w h e r e   1    j     ̀

m a x 

  1  . T h e t o t a l n u m b e r o f  ̀ 

m a x 

  j ; d  - s e q u e n c e s p o s s i b l e  

i n c o u r s e o f M A M e r g e i s n o m o r e t h a n  

 

 

 ̀

m a x 

  1 

 

+ 1 

 

Y  

i  = 2 

(   

1  =  2 

+ 1 ) 

w h e r e     = 2 

 ̀

m a x 

a n d t h e p r o d u c t  

Q  

a b o v e i s d e n e d t o b e   1  w h e n   j  = 1  . M o r e o v e r , t h e a b o v e q u a n t i t y i s a l w a y s  

O  (  =  

1  =  2 

P r o o f   : F i r s t l y , b y L e m m a 4 9 , t h e n u m b e r o f t i m e s   l o a d l e v e l  (   ̀

m a x 

  1 ) c a n b e c a l l e d i s  

 

=  2 

 ̀

m a x 

  1 

 

+ 1 , b y t h e  

d e n i t i o n o f t h e   l o a d l e v e l  ( ) p r o c e d u r e , f r o m i n v a r i a n t 6 o f S e c t i o n 5 . 8 . 5 a n d t h e f a c t t h a t t h e n u m b e r   W 

t o p 

o f 

n o n - d u m m y r u n - r e c o r d s i m m e d i a t e l y a f t e r t h e p r e p r o c e s s i n g s t a g e i s n o m o r e t h a n  

 

=  2 

 ̀

m a x 

  1 

 

1 3 0 

Page 144: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 144/203

B y i n v a r i a n t 9 o f S e c t i o n 5 . 8 . 5 , f o r a l l    ̀ s u c h t h a t 1      ̀    ̀

m a x 

  1 , w e h a v e   l r     ̀ ]  O r d e r   = 2 

 ̀   1 

W e p r o v e t h e l e m m a b y i n d u c t i o n o n   j  . F r o m L e m m a 4 9 a n d t h e o b s e r v a t i o n a b o v e , w e k n o w t h a t t h a t  

l o a d l e v e l  (   ̀

m a x 

  (  J  + 1 ) ) c a n b e c a l l e d a t m o s t 2  

 ̀

m a x 

  (  J  + 1 ) 

+ 1 =   

1  =  2 

J  + 1 

t i m e s e a c h t i m e a   l o a d l e v e l  (   ̀

m a x 

  J  ) 

o p e r a t i o n c o m p l e t e s . T h e f a c t t h a t t h e a b o v e e x p r e s s i o n i s   O  (  =  

1  =  2 

) a l s o f o l l o w s b y i n d u c t i o n o n   j  . I n f a c t w e c a n  

s h o w t h a t t h e a b o v e e x p r e s s i o n i s n o m o r e t h a n  

  

1 + 

 

1  =  2 

 

2   

 

1  =  2 

T h e l e m m a f o l l o w s f r o m t h e o b s e r v a t i o n t h a t e a c h    ̀

m a x 

  j ; d  - s e q u e n c e m u s t i n v o l v e a   l o a d l e v e l  (   ̀

m a x 

  j  ) o p e r a -  

t i o n .  

L e m m a 5 1   S u p p o s e t h a t a l l o c a t i o n l e v e l    ̀

m a x 

  j  , w h e r e   1    j     ̀

m a x 

  1  , i s c h a r g e d a l l t h e I / O o p e r a t i o n s c h a r g e d  

t o a n y    ̀

m a x 

  j ; d  - s e q u e n c e . T h e n t h e t o t a l n u m b e r o f I / O o p e r a t i o n s c h a r g e d t o l e v e l    ̀

m a x 

  j  , w h e r e   1    j     ̀

m a x 

  1  , 

i s n o m o r e t h a n   O 

 

=  

1  =  2 

j  + 1 

 

P r o o f  : C o n s i d e r a n y    ̀

m a x 

  j ; d  - s e q u e n c e , w h e r e   j    1 . B y L e m m a 5 0 , t h e m a x i m u m n u m b e r o f   ̀

m a x 

  j ; d  - s e q u e n c e s  

i s n o m o r e t h a n   O 

 

=  

1  =  2 

 

. S i n c e L e m m a 4 7 p r o v e s t h a t t h e m a x i m u m n u m b e r o f I / O o p e r a t i o n s t h a t c a n b e  

c h a r g e d t o a n y    ̀

m a x 

  j ; d  - s e q u e n c e i s   O 

 

 ̀

m a x 

  j    1 

 

=  O 

 

 

1  =  2 

j  + 1 

 

, t h e m a x i m u m n u m b e r o f I / O o p e r a t i o n s t h a t  

c a n b e c h a r g e d t o l e v e l    ̀

m a x 

  j  i s 

 

=  

1  =  2 

 

  O 

 

 

1  =  2 

j  + 1 

 

w h i c h i s   O 

 

=  

1  =  2 

j  + 1 

 

. H e n c e t h e l e m m a i s p r o v e d .  

W e n a l l y b o u n d t h e t o t a l n u m b e r o f I / O o p e r a t i o n s a n d t h e t o t a l a m o u n t o f r e s o u r c e c o n s u m p t i o n c h a r g e d t o  

a n y  d o w n l o a d   ( ) c a l l .  

T h e o r e m 1 3   T h e t o t a l n u m b e r o f I / O o p e r a t i o n s c h a r g e d t o a l l d o w n l o a d   ( )  c a l l s o p e r a t i o n i s   O  (    )  . T h e t o t a l  

r e s o u r c e c o n s u m p t i o n o v e r a l l t h e s e I / O o p e r a t i o n s i s   O  (    l g  m 

m a x 

P r o o f  : E a c h   d o w n l o a d   ( ) i s , b y d e n i t i o n , p a r t o f a n   ` ; d  - s e q u e n c e . S o i t i s e n o u g h t o b o u n d t h e I / O o p e r a t i o n s  

c h a r g e d t o   ` ; d  - s e q u e n c e s . T h e t o t a l n u m b e r o f I / O o p e r a t i o n s t o b e b o u n d e d i s t h e s u m o f t h e n u m b e r o f I / O  

o p e r a t i o n s c h a r g e d t o a n y l e v e l , o v e r a l l l e v e l s . U s i n g L e m m a 5 1 , t h i s n u m b e r i s  

0  

@  

 ̀

m a x 

  1 

X   

j  = 0 

 

 

1  =  2 

j  + 1 

1 3 1 

Page 145: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 145/203

w h i c h c a n b e s i m p l i e d a s  

  

 

  

1 + 

1 6 

2 5 6 

+    + 

 

1  =  4 

 

1  =  2 

 

T h e a b o v e e x p r e s s i o n i s   O  (    )

T h e b o u n d o n t h e t o t a l r e s o u r c e c o n s u m p t i o n i s o b t a i n e d b y a s s u m i n g t h a t t h e a m o u n t o f m e m o r y a v a i l a b l e  

d u r i n g a l l t h e   O  (    ) I / O o p e r a t i o n s c o u n t e d a b o v e i s   m 

m a x 

a n d u s i n g t h e d e n i t i o n o f r e s o u r c e c o n s u m p t i o n f o r  

m e m o r y - a d a p t i v e s o r t i n g .  

R e s o u r c e C o n s u m p t i o n d u r i n g b a d   l l m e r g e   ( ) c a l l s  

A b a d   l l m e r g e   ( ) c a l l c a n c o n s u m e a w h o l e l o t o f r e s o u r c e s w h i l e d o i n g v e r y l i t t l e \ w o r k " . S u c h a s i t u a t i o n o c c u r s  

w h e n a n   l l m e r g e   (  r r 

 ̀

) e x e c u t i o n i s p r e e m p t e d a t a t i m e w h e n v e r y f e w i t e m s r e m a i n t o b e a d d e d t o t h e p h y s i c a l  

s e q u e n c e o f t h e r u n a s s o c i a t e d w i t h   r r 

 ̀

: I f t h e l e v e l o f a l l o c a t i o n b e c o m e s    ̀ o n c e m o r e s o o n a f t e r t h i s p r e e m p t i o n ,  

 j u s t s e t t i n g u p t h e m e r g e o p e r a t i o n   l l m e r g e   (  r r 

 ̀

) c a n i n c u r   O  ( 2 

 ̀   1 

) I / O o p e r a t i o n s b e l o n g i n g t o a n a l l o c a t i o n p h a s e  

o f s i z e   O  ( 2 

 ̀

)

W e n o w b o u n d t h e t o t a l r e s o u r c e c o n s u m p t i o n o f a l l b a d   l l m e r g e   ( ) c a l l s o v e r t h e e x e c u t i o n o f   M A M e r g e   b y 

p r o v i n g t h a t t h e t o t a l n u m b e r o f I / O o p e r a t i o n s c h a r g e d t o b a d   l l m e r g e   ( ) c a l l s o v e r t h e e x e c u t i o n o f   M A M e r g e   i s 

O  (    ) . W e d o s o b y c h a r g i n g t h e   O  ( 2 

 ̀   1 

) I / O o p e r a t i o n s i n c u r r e d b y a b a d   l l m e r g e   (  r r 

 ̀

) c a l l t o t h e r u n - r e c o r d s i t  

t o u c h e s , a n d t h e n o b s e r v i n g o n t h e o n e h a n d t h a t n o r u n - r e c o r d c a n e v e r b e t o u c h e d b y m o r e t h a n o n e b a d   l l m e r g e   ( ) 

c a l l a n d o n t h e o t h e r t h a t t h e t o t a l n u m b e r o f r u n - r e c o r d s c r e a t e d d u r i n g   M A M e r g e   i s  O  (    )

B y i n v a r i a n t 4 o f S e c t i o n 5 . 8 . 6 a n d i n v a r i a n t s 8 a n d 9 o f S e c t i o n 5 . 8 . 5 , w e h a v e t h e f o l l o w i n g l e m m a .  

L e m m a 5 2   I f a n e x e c u t i o n o f l l m e r g e  (  r r 

g l o b a l  

)  i s a b a d c a l l , t h e n t h e a l g o r i t h m M A M e r g e t e r m i n a t e s a f t e r t h a t  

c a l l . T h e t o t a l n u m b e r o f I / O o p e r a t i o n s t h a t c a n b e c h a r g e d t o t h a t l l m e r g e  (  r r 

g l o b a l  

)  c a l l i s   O  (    ) 

O n a c c o u n t o f t h e a b o v e l e m m a w e n o w c o n s i d e r o n l y b a d   l l m e r g e   (  r r 

 ̀

) c a l l s e x e c u t e d w h e n t h e a l l o c a t i o n l e v e l  

i s   ̀ . W e u s e t h e f o l l o w i n g c h a r g i n g s c h e m e t o c o u n t t h e t o t a l n u m b e r o f I / O o p e r a t i o n s o v e r a l l s u c h b a d   l l m e r g e   ( ) 

c a l l s .  

D e n i t i o n 4 9   W e c h a r g e t h e t o t a l n u m b e r   O  ( 2 

 ̀   1 

) o f I / O o p e r a t i o n s c h a r g e d t o a b a d   l l m e r g e   (  r r 

 ̀

) c a l l ( s e e  

L e m m a 4 8 a n d L e m m a 3 8 ) t o t h e ( 2  

 ̀   1 

) r u n - r e c o r d s t o u c h e d ( s e e L e m m a 3 2 ) b y t h a t   l l m e r g e   (  r r 

 ̀

) c a l l .  

W e n o w m a k e a u s e f u l o b s e r v a t i o n r e g a r d i n g b a d   l l m e r g e   (  r r 

 ̀

) c a l l s .  

L e m m a 5 3   W h e n t h e e x e c u t i o n o f a b a d l l m e r g e  (  r r 

 ̀

)  c a l l c o m p l e t e s , w e h a v e r r  

 ̀

a g  =  D o n e .  

1 3 2 

Page 146: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 146/203

P r o o f  : T h i s f o l l o w s f r o m t h e d e n i t i o n o f t h e c o n s t a n t    

l l m 

i n D e n i t i o n 4 3 , c o n s t a n t    

l o a d  

i n L e m m a 3 5 , i n v a r i a n t s 2 b  

a n d 4 o f S e c t i o n 5 . 8 . 6 , a n d t h e f a c t t h a t t h e o n l y r e a s o n f o r   l l m e r g e   (  r r 

 ̀

) t o e n d u p b e i n g a b a d c a l l i s t h a t t h e  

f o r m a t i o n o f t h e r u n a s s o c i a t e d w i t h   r r 

 ̀

i s l o g i c a l l y c o m p l e t e .  

B a s e d u p o n L e m m a 5 3 , w e m a k e t h e f o l l o w i n g u s e f u l o b s e r v a t i o n .  

L e m m a 5 4   A n y r u n - r e c o r d c a n b e t o u c h e d b y a t m o s t o n e b a d l l m e r g e  ( )  c a l l .  

P r o o f  : C o n s i d e r a n y r u n - r e c o r d   r r 

o t h e r t h a n r u n - r e c o r d   r r 

g l o b a l  

. C o n s i d e r t h e r s t b a d   l l m e r g e   (  r r 

 ̀

) c a l l t h a t t o u c h e s  

r u n - r e c o r d   r r 

a n d l e t   t  d e n o t e t h e t i m e a t w h i c h t h a t   l l m e r g e   (  r r 

 ̀

) c a l l c o m p l e t e s i t s e x e c u t i o n . B y L e m m a 5 3 , w e  

h a v e   r r 

 ̀

a g  =  D o n e  , w h e n t h e e x e c u t i o n o f   l l m e r g e   (  r r 

 ̀

) c o m p l e t e s . S i n c e   r r 

i s t o u c h e d b y   l l m e r g e   (  r r 

 ̀

) , b y  

d e n i t i o n o f t h e m e r g i n g p a r t o f   l l m e r g e   ( ) , t h e r e m u s t e x i s t a \ p a t h "   r r 

 ̀

=  r r  ( 0 )  ;  r r  ( 1 )  ;  r r  ( 2 )  ; : : : ;  r r  (  d  ) =  r r 

s u c h  

t h a t   r r  (  i  ) i s i n l i s t   r r  (  i    1 )  i n p u t s   . I t c a n b e e p r o v e d v i a i n d u c t i o n o n t h e l e n g t h o f t h e p a t h t h a t n o   l l m e r g e   ( ) c a l l  

a f t e r t i m e   t  c a n t o u c h r u n - r e c o r d   r r 

. T h i s p r o v e s t h e l e m m a .  

F r o m t h e c h a r g i n g s c h e m e o f D e n i t i o n 4 9 , i t i s c l e a r t h a t w e c a n c h a r g e e a c h r u n - r e c o r d t o u c h e d b y a b a d  

l l m e r g e   ( ) c a l l a t m o s t   O  ( 1 ) I / O o p e r a t i o n s o f t h a t   l l m e r g e   ( ) c a l l a n d s o , b y L e m m a 5 4 a b o v e , t h e t o t a l n u m b e r  

o f I / O o p e r a t i o n s i n c u r r e d b y b a d   l l m e r g e   ( ) c a l l s t h r o u g h o u t t h e e x e c u t i o n o f   M A M e r g e   i s b o u n d e d b y t h e t o t a l  

n u m b e r o f r u n - r e c o r d s c r e a t e d d u r i n g   M A M e r g e  . B e l o w w e p r o v e t h a t t h e t o t a l n u m b e r o f r u n - r e c o r d s c r e a t e d d u r i n g  

M A M e r g e   i s  O  (    )

L e m m a 5 5   T h e t o t a l n u m b e r o f r u n - r e c o r d s c r e a t e d d u r i n g M A M e r g e i s   O  (    ) 

P r o o f  : T h e p r o o f f o l l o w s b y o b s e r v i n g t h a t t h e t o t a l n u m b e r   O  ( 

m  ) o f r u n - r e c o r d s c r e a t e d d u r i n g a n   ` ; d  - s e q u e n c e  

( L e m m a 4 4 ) i s r o u g h l y t h e s a m e a s t h e n u m b e r o f I / O o p e r a t i o n s i n c u r r e d b y t h e   ` ; d  - s e q u e n c e ( L e m m a 4 3 ) , w h e r e  

m  = 2 

 ̀

. H e n c e , u s i n g t h e s a m e t e c h n i q u e s a s i n L e m m a 5 0 , L e m m a 5 1 a n d T h e o r e m 1 3 , w e c a n a r g u e t h a t t h e t o t a l  

n u m b e r o f r u n - r e c o r d s c r e a t e d d u r i n g   M A M e r g e   i s n o m o r e t h a n   O  (    )

T h u s w e h a v e p r o v e d t h e f o l l o w i n g t h e o r e m .  

T h e o r e m 1 4   T h e t o t a l n u m b e r o f I / O o p e r a t i o n s t h a t c a n b e c h a r g e d t o b a d l l m e r g e  ( )  c a l l s m a d e d u r i n g t h e  

e x e c u t i o n o f M A M e r g e i s   O  (    )  . T h e t o t a l r e s o u r c e c o n s u m p t i o n t h a t c a n b e c h a r g e d t o b a d l l m e r g e  ( )  c a l l s m a d e  

t h r o u g h o u t M A M e r g e i s n o m o r e t h a n   O  (    l g  m 

m a x 

1 3 3 

Page 147: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 147/203

R e s o u r c e C o n s u m p t i o n o f   l l m e r g e   (  r r 

g l o b a l  

) c a l l s  

E a c h   l l m e r g e   (  r r 

g l o b a l  

) c a l l a p p e n d s b l o c k s o f i t e m s t o t h e p h y s i c a l s e q u e n c e o f t h e r u n a s s o c i a t e d w i t h t h e \ g l o b a l "  

r u n - r e c o r d . B y d e n i t i o n , w h e n   M A M e r g e   m e r g e s     r u n t o t a l l y c o n s i s t i n g o f   n 

b l o c k s , t h e n u m b e r o f b l o c k s i n  

t h e r u n a s s o c i a t e d w i t h   r r 

g l o b a l  

i s n o m o r e t h a n   n 

. B l o c k s a r e a p p e n d e d t o t h e p h y s i c a l s e q u e n c e c o r r e s p o n d i n g t o  

r r 

g l o b a l  

i n a n e c i e n t m a n n e r s u c h t h a t t h e t o t a l n u m b e r o f I / O s c h a r g e d t o   l l m e r g e   (  r r 

g l o b a l  

) c a l l s i s n o m o r e t h a n  

O  (  n 

)

W e h a v e t h e f o l l o w i n g t h e o r e m r e g a r d i n g t h e I / O o p e r a t i o n s i n c u r r e d b y   l l m e r g e   (  r r 

g l o b a l  

) c a l l s .  

T h e o r e m 1 5   S u p p o s e t h a t t h e     r u n s i n p u t t o M A M e r g e t o t a l l y c o n s i s t o f   n 

b l o c k s . T h e t o t a l n u m b e r o f I / O  

o p e r a t i o n s t h a t c a n b e c h a r g e d t o l l m e r g e  (  r r 

g l o b a l  

)  c a l l s m a d e d u r i n g t h e e x e c u t i o n o f M A M e r g e i s   O  (  n 

)  . T h e  

t o t a l r e s o u r c e c o n s u m p t i o n t h a t c a n b e c h a r g e d t o l l m e r g e  (  r r 

g l o b a l  

)  c a l l s m a d e d u r i n g t h e e x e c u t i o n o f M A M e r g e i s  

O  (  n 

l g  m 

m a x 

P r o o f  : B y L e m m a 5 2 , w e k n o w t h a t t h e r e c a n b e a t m o s t o n e b a d   l l m e r g e   (  r r 

g l o b a l  

) c a l l d u r i n g   M A M e r g e   a n d i t  

i n c u r s n o m o r e t h a n   O  (    ) I / O o p e r a t i o n s . B y L e m m a 4 8 a n d L e m m a 3 7 , w e k n o w t h a t i f a g o o d   l l m e r g e   (  r r 

g l o b a l  

c a l l a p p e n d s   g 

b l o c k s o f i t e m s t o t h e r u n a s s o c i a t e d w i t h   r r 

g l o b a l  

, t h e n t h a t   l l m e r g e   (  r r 

g l o b a l  

) c a l l c a n b e c h a r g e d a t  

m o s t   O  (  g 

) I / O o p e r a t i o n s . F r o m i n v a r i a n t 2 o f S e c t i o n 5 . 8 . 5 , w e k n o w t h a t t h e t o t a l n u m b e r o f b l o c k s t h a t c a n g e t  

a p p e n d e d t o t h e r u n a s s o c i a t e d w i t h   r r 

g l o b a l  

i s n o m o r e t h a n   n 

. T h e t h e o r e m f o l l o w s .  

5 . 9 . 2 P o t e n t i a l F u n c t i o n A r g u m e n t  

W e h a v e s h o w n t h a t t h e n u m b e r o f I / O o p e r a t i o n s c h a r g e d t o   d o w n l o a d   ( ) o p e r a t i o n s a n d b a d   l l m e r g e   ( ) c a l l s  

i s  O  (    ) =  O  (  n 

) w h e r e a s t h e n u m b e r o f I / O o p e r a t i o n s c h a r g e d t o   l l m e r g e   (  r r 

g l o b a l  

) c a l l s i s   O  (  n 

) . S i n c e t h e n e t  

n u m b e r o f I / O o p e r a t i o n s i n t h e s e a c t i v i t i e s i s s m a l l , e v e n i f w e a s s u m e c o n s e r v a t i v e l y t h a t t h r o u g h o u t t h e s e   O  (  n 

I / O o p e r a t i o n s t h e a l l o c a t i o n l e v e l w a s a t i t s m a x i m u m v a l u e    ̀

m a x 

, t h e n e t r e s o u r c e c o n s u m p t i o n o f t h e s e a c t i v i t i e s  

r e m a i n s   O  (  n 

l g  m 

m a x 

)

O n t h e o t h e r h a n d t h e n u m b e r o f I / O o p e r a t i o n s c h a r g e d t o g o o d   l l m e r g e   ( ) c a l l s i n g e n e r a l m a y b e s u p e r l i n e a r  

i n t h e n u m b e r o f b l o c k s   n 

o u t p u t b y   M A M e r g e  . T h e n u m b e r o f I / O o p e r a t i o n s c h a r g e d t o g o o d   l l m e r g e   ( ) c a l l s i n  

g e n e r a l m a y b e a s h i g h a s   O  (  n 

l g    ) , w h i c h m e a n s w e c a n n o t a d o p t t h e c o u n t i n g s t r a t e g y m e n t i o n e d i n t h e a b o v e  

p a r a g r a p h : A s s u m i n g t h a t t h e a l l o c a t i o n l e v e l t h r o u g h o u t t h e s e   O  (  n 

l g    ) I / O o p e r a t i o n s i s    ̀

m a x 

w o u l d l e a d t o a n  

O  (  n 

( l g    ) ( l g   m 

m a x 

) ) b o u n d o n r e s o u r c e c o n s u m p t i o n o f g o o d   l l m e r g e   ( ) c a l l s , w h i c h i s c l e a r l y n o t a c c e p t a b l e .  

I n o r d e r t o d e m o n s t r a t e t h a t t h e r e s o u r c e c o n s u m p t i o n o f g o o d   l l m e r g e   ( ) c a l l s i s b o u n d e d b y   O  (  n 

l g  m 

m a x 

) a s 

w e l l , w e u s e t h e n o t i o n o f m e r g e p o t e n t i a l d e n e d i n S e c t i o n 5 . 6 . I n f o r m a l l y s p e a k i n g , w h e n a g o o d   l l m e r g e   (  r r 

 ̀

) c a l l  

i s c h a r g e d   g 

I / O o p e r a t i o n s , i t s r e s o u r c e c o n s u m p t i o n i s   O  (  g 

  2 

 ̀

) ; b u t t h e g o o d   l l m e r g e   (  r r 

 ̀

) c a l l a l s o r a i s e s t h e r a n k  

1 3 4 

Page 148: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 148/203

o f e a c h o n e o f t h e (  g 

B  ) i t e m s i t a p p e n d s t o t h e p h y s i c a l s e q u e n c e o f t h e r u n a s s o c i a t e d w i t h   r r 

 ̀

b y a n a d d i t i v e  

v a l u e o f ( 2  

 ̀

) , s o t h a t t h e p o t e n t i a l o f t h e m e r g e i n c r e a s e s b y a n a m o u n t o f (  g 

  2 

 ̀

) . S i n c e t h e m a x i m u m v a l u e t h e  

p o t e n t i a l o f t h e m e r g e a s s u m e s i s   O  (  n 

l g  m 

m a x 

) , i t f o l l o w s t h a t t h e n e t r e s o u r c e c o n s u m p t i o n i s   O  (  n 

l g  m 

m a x 

)

W e n o w f o r m a l l y p r o v e o u r c l a i m s . E a c h o f t h e r u n - r e c o r d s o f t h e     r u n s i n p u t t o   M A M e r g e   h a v e a u n i q u e r u n  

a s s i g n e d t o t h e m . I t i s c o n v e n i e n t t o l o g i c a l l y a s s i g n s e t s c o n t a i n i n g \ d u m m y i n p u t r u n s " t o d u m m y r u n - r e c o r d s t h a t  

m a y p o s s i b l y b e i n t r o d u c e d i n c o u r s e o f o u r p r e p r o c e s s i n g . T h e a s s i g n m e n t o f s e t s c o n t a i n i n g d u m m y i n p u t r u n s t o  

d u m m y r u n - r e c o r d s i s   o n l y p e r f o r m e d f o r t h e s a k e o f a n a l y s i s   a n d d o e s n o t a l t e r t h e c o m p u t a t i o n i n a n y w a y .  

D e n i t i o n 5 0   L e t  U  d e n o t e t h e s e t o f     r u n s b e i n g m e r g e d b y   M A M e r g e  . F o r t h e s a k e o f c o n v e n i e n c e i n a n a l y s i s ,  

w e a s s i g n a   d u m m y s e t   t o e a c h d u m m y r u n - r e c o r d c r e a t e d d u r i n g   M A M e r g e  ' s p r e p r o c e s s i n g s t a g e . E a c h d u m m y s e t  

i s a a s e t o f o n e o r m o r e   d u m m y i n p u t r u n s  . E a c h d u m m y i n p u t r u n i s a r u n d i s t i n c t f r o m a n y o f t h e     r u n s o f   U 

a n d i s d e n e d t o s a t i s f y t h e f o l l o w i n g c o n d i t i o n s :  

1 . E a c h d u m m y i n p u t r u n i s c o n t a i n e d i n a t m o s t o n e d u m m y s e t .  

2 . T h e p h y s i c a l s e q u e n c e o f e a c h d u m m y i n p u t r u n   e 

(  y  ) i s a l w a y s e m p t y .  

3 . T h e r a n k o f e a c h d u m m y i n p u t r u n i s 1 .  

W e a s s i g n a p p r o p r i a t e l y s i z e d d u m m y s e t s t o e a c h o f t h e d u m m y r u n - r e c o r d s i n t r o d u c e d i n S t e p 2 a n d S t e p 4 o f  

t h e p r e p r o c e s s i n g s t a g e .  

D e n i t i o n 5 1   C o n s i d e r t h e   D 

d u m m y r u n - r e c o r d s   d 

; d 

; : : : ; d  

  1 

i n t r o d u c e d i n S t e p 2 o f t h e p r e p r o c e s s i n g  

s t a g e . E a c h d u m m y r u n - r e c o r d   d 

i s a s s i g n e d a d u m m y - s e t c o n t a i n i n g a s i n g l e d u m m y i n p u t r u n , f o r 0     j    D 

  1

C o n s i d e r t h e   D 

d u m m y r u n - r e c o r d s   d 

; d 

; : : : ; d  

  1 

i n t r o d u c e d i n S t e p 4 o f t h e p r e p r o c e s s i n g s t a g e . E a c h d u m m y  

r u n - r e c o r d   d 

i s a s s i g n e d a d u m m y s e t c o n t a i n i n g 2  

 ̀

m a x 

  1 

d u m m y i n p u t r u n s , f o r 0     j    D 

  1

J u s t a s t h e r e i s a r u n a s s o c i a t e d w i t h a n o n - d u m m y r u n - r e c o r d , w e c a n n o w a s s o c i a t e r u n s w i t h d u m m y r u n -  

r e c o r d s .  

D e n i t i o n 5 2   T h e r u n a s s o c i a t e d w i t h a d u m m y r u n - r e c o r d a s s i g n e d a s e t   s  o f d u m m y i n p u t r u n s i s d e n e d t o b e  

t h e ( v a c u o u s ) m e r g e o f t h e d u m m y i n p u t r u n s o f  s  . T h e r a n k o f t h i s r u n i s   j  s  j 

A s i m p l e l e m m a t h a t c a n b e p r o v e d b y i n d u c t i o n i s t h e f o l l o w i n g .  

L e m m a 5 6   C o n s i d e r a r u n - r e c o r d r r w h i c h i s n e i t h e r t h e r u n - r e c o r d a s s o c i a t e d w i t h a n i n p u t r u n n o r a d u m m y  

r u n - r e c o r d . L e t r r  

a n d r r  

0 0 

b e a n y t w o r u n - r e c o r d s i n t h e l i s t r r   i n p u t s . L e t   r  ,  r 

a n d  r 

0 0 

r e s p e c t i v e l y b e t h e r u n s  

a s s o c i a t e d w i t h r u n - r e c o r d s r r , r r  

a n d r r  

0 0 

r e s p e c t i v e l y . T h e n w e h a v e  

 p  (  r 

) =   p  (  r 

0 0 

) = 

 p  (  r  ) 

r r  O r d e r  

1 3 5 

Page 149: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 149/203

T h e f o l l o w i n g l e m m a f o l l o w s e a s i l y f r o m t h e d e n i t i o n o f t h e p o t e n t i a l a s s i g n e d t o a r u n - r e c o r d a n d t h e p o t e n t i a l  

o f t h e s t a t e o f t h e m e r g e .  

L e m m a 5 7   T h e r a n k o f t h e r u n   r 

g l o b a l  

a s s o c i a t e d w i t h r u n - r e c o r d r r  

g l o b a l  

d o e s n o t c h a n g e w i t h t i m e a n d i s l a r g e r  

t h a n t h e r a n k o f t h e r u n a s s o c i a t e d w i t h a n y o t h e r r u n - r e c o r d i n M A M e r g e . M o r e o v e r , w e h a v e    p  (  r 

g l o b a l  

)  <  2 l g    = 

O  ( l g  m 

m a x 

)  . T h e p o t e n t i a l o f t h e m e r g e w h e n M A M e r g e c o m p l e t e s e x e c u t i o n i s n o m o r e t h a n   2  n 

l g    , w h e r e   n 

i s 

t h e t o t a l n u m b e r o f b l o c k s m e r g e d b y M A M e r g e .  

W e c o n s i d e r a n y g o o d   l l m e r g e   (  r r 

 ̀

) o p e r a t i o n , w h e r e   r r 

 ̀

i s t h e a c t i v e r u n - r e c o r d o f l e v e l    ̀ a n d s u c h t h a t   r r 

 ̀

6= 

r r 

g l o b a l  

, e x e c u t e d w h e n t h e a l l o c a t i o n l e v e l i s    ̀ . T h e f o l l o w i n g l e m m a p r o v e s t h a t t h e t o t a l r e s o u r c e c o n s u m p t i o n  

c h a r g e d t o t h e   l l m e r g e   (  r r 

 ̀

) i s w i t h i n a c o n s t a n t f a c t o r o f t h e i n c r e a s e i n t h e p o t e n t i a l o f t h e s t a t e o f t h e m e r g e  

b r o u g h t a b o u t b y   l l m e r g e   (  r r 

 ̀

)

L e m m a 5 8   S u p p o s e t h a t t h e r e s o u r c e c o n s u m p t i o n o f a n l l m e r g e  ( )  c a l l i s d e n e d t o b e t h e r e s o u r c e c o n s u m p t i o n  

o v e r a l l t h e I / O o p e r a t i o n s c h a r g e d t o t h a t l l m e r g e  ( )  c a l l . C o n s i d e r a g o o d l l m e r g e  (  r r 

 ̀

)  c a l l i n w h i c h   G 

i t e m s a r e  

a d d e d t o t h e r u n a s s o c i a t e d w i t h t h e a c t i v e r u n - r e c o r d r r  

 ̀

o f l e v e l    ̀ , w h e r e r r  

 ̀

6=  r r 

g l o b a l  

. T h e n  

1 . T h e r e s o u r c e c o n s u m p t i o n o f t h a t l l m e r g e  (  r r 

 ̀

)  c a l l i s   O  (  G 

 ̀

= B  ) 

2 . T h e i n c r e a s e i n t h e p o t e n t i a l o f t h e s t a t e o f t h e m e r g e i s a t l e a s t   G 

 ̀

=  2  B 

P r o o f  : B y i n v a r i a n t 2 b a n d t h e d e s c r i p t i o n o f t h e   l l m e r g e   ( ) p r o c e d u r e w e k n o w t h a t a l l I / O o p e r a t i o n s c h a r g e d  

t o  l l m e r g e   (  r r 

 ̀

) a r e o n e s i n w h i c h t h e a l l o c a t i o n p h a s e i s o f s i z e a t m o s t   O  ( 2 

 ̀

) . B y L e m m a 4 8 a n d L e m m a 3 7 w e  

k n o w t h a t t h e t o t a l n u m b e r o f I / O o p e r a t i o n s c h a r g e d t o t h e   l l m e r g e   (  r r 

 ̀

) c a l l i s   O  (  G 

= B  ) . T h u s t h e n e t r e s o u r c e  

c o n s u m p t i o n c h a r g e d t o   l l m e r g e   (  r r 

 ̀

) i s  O 

 

(  G 

= B  ) l g 2  

 ̀

 

=  O 

 

(  G 

 ̀

)  = B 

 

, b y d e n i t i o n o f r e s o u r c e c o n s u m p t i o n .  

C o n s i d e r a n y i t e m   x  a p p e n d e d t o t h e p h y s i c a l s e q u e n c e o f t h e r u n   r 

 ̀

, a s s o c i a t e d w i t h   r r 

 ̀

, b y  l l m e r g e   (  r r 

 ̀

)

F r o m t h e p r o c e d u r e   l l m e r g e   ( ) a n d t h e d e n i t i o n o f t h e p o t e n t i a l a s s i g n e d t o a n i t e m a t a n y t i m e , w e k n o w t h a t  

t h e m a x i m u m p o s s i b l e r a n k   x  c o u l d h a v e h a d p r i o r t o   l l m e r g e   (  r r 

 ̀

) i s   p  (  r 

) , w h e r e   r 

i s t h e r u n a s s o c i a t e d w i t h a  

r u n - r e c o r d i n t h e l i s t   r r  i n p u t s   . B y i n v a r i a n t 1 0 , 9 a n d t h e d e n i t i o n o f t h e a c t i v e r u n - r e c o r d   r r 

 ̀

o f l e v e l    ̀ , w e 

k n o w t h a t   r r 

 ̀

O r d e r   = 2 

 ̀   1 

. T h u s b y L e m m a 5 6 , t h e r a n k o f e l e m e n t   x  i n c r e a s e s b y a f a c t o r o f a t l e a s t 2  

 ̀   1 

d u r i n g   l l m e r g e   (  r r 

 ̀

) . S i n c e   l l m e r g e   (  r r 

 ̀

) a d d s   G 

i t e m s t o t h e p h y s i c a l s e q u e n c e o f t h e r u n a s s o c i a t e d w i t h   r r 

 ̀

, t h e  

n e t i n c r e a s e i n m e r g e p o t e n t i a l i s a t l e a s t  

 

  l g 

 

 ̀   1 

 

=  G 

 ̀

=  2  B

T h u s t h e l e m m a i s p r o v e d .  

1 3 6 

Page 150: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 150/203

Page 151: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 151/203

Page 152: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 152/203

Page 153: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 153/203

D e n i t i o n 5 3   A n  f  - w a y   s h u e m e r g e   i s a m e r g e o f   f  r u n s e a c h c o n s i s t i n g o f a n e q u a l n u m b e r , s a y ,    p  b l o c k s o f  

i t e m s s u c h t h a t i f t h e s e q u e n c e o f i t e m s o f t h e   i  t h r u n a r e d e n o t e d b y  

i ;  0 

; x 

i ;  1 

; x 

i ;  2 

; : : : ; x  

i ; p B     1 

f o r e a c h   i  s a t i s f y i n g 0     i    f    1 , t h e n t h e o u t p u t o f t h e m e r g e i s  

0  ;  0 

; x 

1  ;  0 

; x 

2  ;  0 

; : : : ; x  

f    1  ;  0 

; x 

0  ;  1 

; x 

1  ;  1 

; : : : ; x  

f    1  ;  1 

; : : : : : : ; x  

0  ; p B    1 

; x 

1  ; p B    1 

; : : : ; x  

f    1  ; p B    1 

T h e f o l l o w i n g l e m m a f o l l o w s f r o m t h e d e n i t i o n a b o v e a n d T h e o r e m 1 2 .  

L e m m a 5 9   A n m 

m a x 

- w a y s h u e m e r g e s u c h t h a t e a c h r u n c o n s i s t s o f   n 

=  m 

m a x 

b l o c k s o f i t e m s c a n b e p e r f o r m e d  

i n a m e m o r y - a d a p t i v e m a n n e r b y a l g o r i t h m M A M e r g e w i t h a r e s o u r c e c o n s u m p t i o n o f   O  (  n 

l g  m 

m a x 

I n o u r m e m o r y - a d a p t i v e s i m u l a t i o n o f t h e F F T a l g o r i t h m o f V i t t e r a n d S h r i v e r , w e c h o p u p t h e   N  - i n p u t l g   N  - l e v e l  

F F T d i g r a p h i n t o ( l g   N  )  =  l g  M 

m a x 

\ l a y e r s " , w h e r e e a c h l a y e r c o n s i s t s o f l g   M 

m a x 

l e v e l s a n d   M 

m a x 

= 2 

 ̀

m a x 

  1 

B  . B e l o w  

w e d e s c r i b e h o w t o p r o c e s s e a c h l a y e r . I n o r d e r t o r o u t e t h e o u t p u t s o f o n e l a y e r t o a p p r o p r i a t e i n p u t d e s t i n a t i o n s  

o f t h e n e x t l a y e r w e n e e d t o p e r f o r m a s e r i e s o f m a x  

 

1  ;  l o g 

m a x 

( m i n   f  M 

m a x 

; N =  M 

m a x 

g  ) 

 

m a x 

- w a y s h u e - m e r g e  

o p e r a t i o n s e a c h i n v o l v i n g   n  b l o c k s o f i t e m s V S 9 4 ] . B y L e m m a 5 9 , w e c a n u s e   M A M e r g e   t o i m p l e m e n t a l l t h e s h u e -  

m e r g e o p e r a t i o n s r e q u i r e d t o r o u t e t h e o u t p u t s o f o n e l a y e r t o t h e i n p u t s o f t h e n e x t . T h e n e t r e s o u r c e c o n s u m p t i o n  

o f a l l s u c h   m 

m a x 

- w a y s h u e - m e r g e o p e r a t i o n s , s u m m e d o v e r a l l ( l g   N  )  =  l g  M 

m a x 

l a y e r s i s  

  

n  ( l g  m 

m a x 

l g  N 

l g  M 

m a x 

  

1 + l o g  

m a x 

  

m i n 

 

m a x 

m a x 

 

;  ( 5 . 1 2 )  

w h i c h c a n b e s i m p l i e d t o   O  (  n  l g  n  ) V S 9 4 ] .  

E a c h l a y e r c o n s i s t s o f l g   M 

m a x 

l e v e l s a n d a t o t a l o f   N  i n p u t i t e m s . W e c a n s p l i t e a c h l a y e r i n t o   N =  M 

m a x 

\ g r o u p s "  

s u c h t h a t e a c h g r o u p i t s e l f i s a n i n d e p e n d e n t   M 

m a x 

= 2 

 ̀

m a x 

  1 

B  i n p u t F F T g r a p h . W h i l e p r o c e s s i n g a p a r t i c u l a r  

l a y e r , w h e n e v e r o u r a l g o r i t h m h a s a n a l l o c a t i o n p h a s e o f s i z e   y    2 

 ̀

m a x 

  1 

f o r  y    1 , w e c o m p u t e t h e o u t p u t s o f  

b  y  c  g r o u p s d u r i n g t h a t p h a s e . I n o r d e r t o f u n c t i o n e c i e n t l y d u r i n g s m a l l e r a l l o c a t i o n p h a s e s , w e m a k e t h e c r u c i a l  

o b s e r v a t i o n t h a t p e b b l i n g t h r o u g h a n a n F F T g r a p h w i t h   M 

m a x 

= 2 

 ̀

m a x 

  1 

i n p u t s i s e q u i v a l e n t t o r s t p e b b l i n g  

t h r o u g h 2  

 ̀

m a x 

  2 

i n d e p e n d e n t F F T g r a p h s e a c h w i t h 2  

 ̀

m a x 

  2 

B  i n p u t n o d e s , t h e n e x e c u t i n g a 2  

 ̀

m a x 

  2 

- w a y s h u e -  

m e r g e t o t a l l y i n v o l v i n g 2  

 ̀

m a x 

  2 

b l o c k s , a n d t h e n p e b b l i n g t h r o u g h 2  

 ̀

m a x 

  2 

i n d e p e n d e n t F F T g r a p h s e a c h w i t h  

 ̀

m a x 

  2 

B  i n p u t n o d e s o n c e m o r e . T h i s d e c o m p o s i t i o n o f a n   m  = 2 

 ̀

m a x 

  1 

b l o c k F F T d i g r a p h i n t o  

m  = 2 

 ̀

m a x 

  2 

e q u a l l y s i z e d , i n d e p e n d e n t F F T d i g r a p h s i s a n a l o g o u s t o t h e s p l i t t i n g o f a n   m  - w a y m e r g e i n t o  

m  m e r g e s , e a c h o n e  

i t s e l f a  

m  - w a y m e r g e . E a c h o f t h e s e s t e p s c a n b e i m p l e m e n t e d i n a m e m o r y - a d a p t i v e m a n n e r b y u s i n g m o d i c a t i o n s  

1 4 0 

Page 154: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 154/203

o f t h e d a t a s t r u c t u r e s a n d o n l i n e r e o r g a n i z a t i o n t e c h n i q u e s t h a t w e d e v e l o p e d f o r   M A M e r g e   s o t h a t t h e n e t r e s o u r c e  

c o n s u m p t i o n i n c u r r e d i n p r o c e s s i n g a s i n g l e g r o u p i s   O 

 

(  M 

m a x 

= B  ) l g (  M 

m a x 

= B  ) 

 

=  O 

 

(  M 

m a x 

= B  ) l g  m 

m a x 

 

. A s a  

r e s u l t e a c h l a y e r c a n b e p r o c e s s e d w i t h a r e s o u r c e c o n s u m p t i o n o f   O  (  n  l g  m 

m a x 

)

T h u s t h e n e t r e s o u r c e c o n s u m p t i o n o f o u r F F T a l g o r i t h m i s   O  (  n  l g  n  ) a n d w e h a v e a d y n a m i c a l l y o p t i m a l F F T  

a l g o r i t h m . I t f o l l o w s t h a t w e a l s o h a v e a d y n a m i c a l l y o p t i m a l a l g o r i t h m f o r a r b i t r a r y p e r m u t a t i o n n e t w o r k s s i n c e i t  

i s w e l l k n o w n t h a t a n y   N  i n p u t p e r m u t a t i o n n e t w o r k c a n b e s i m u l a t e d b y a t m o s t t h r e e a p p r o p r i a t e   N  i n p u t F F T  

d i g r a p h s p l a c e d o n e a f t e r t h e o t h e r ; s e e A V 8 8 ] f o r r e f e r e n c e s .  

5 . 1 2 M e m o r y - A d a p t i v e B u e r T r e e      

I n t h i s s e c t i o n w e p r e s e n t a m e m o r y - a d a p t i v e v e r s i o n o f t h e b u e r t r e e d a t a s t r u c t u r e i n t r o d u c e d b y A r g e A r g 9 4 ] .  

T h e b u e r t r e e i s a g e n e r a l t e c h n i q u e t o e c i e n t l y e x t e r n a l i z e m a n y i n t e r n a l m e m o r y d a t a s t r u c t u r e s . T h e m o s t  

a p p e a l i n g a s p e c t o f t h e b u e r t r e e i s t h a t i t i s o l a t e s t h e I / O s p e c i c p a r t s o f d a t a s t r u c t u r e s s o t h a t a s p e c i c s e t  

o f I / O e c i e n t t e c h n i q u e s c a n b e a p p l i e d t o s e v e r a l d i e r e n t i n t e r n a l m e m o r y d a t a s t r u c t u r e s t h a t h a v e a \ b u e r  

t r e e w r a p p e r " , r e s u l t i n g i n I / O o p t i m a l ( i n a n a m o r t i z e d s e n s e A r g 9 4 ] ) a l g o r i t h m s f o r s e v e r a l a p p l i c a t i o n s c o n s i s t i n g  

o f  b a t c h e d d y n a m i c p r o b l e m s  . T h e s e i n c l u d e i m p r o v e d g r a p h a l g o r i t h m s , o r d e r e d b i n a r y d e c i s i o n d i a g r a m s , e x t e r n a l  

h e a p s a n d s t r i n g s o r t i n g , a m o n g o t h e r a p p l i c a t i o n s . ( S e e A r g 9 6 ] a n d V i t 9 8 ] f o r d e t a i l s . ) M o r e r e c e n t a p p l i c a t i o n s  

f o r t h e b u e r t r e e i n c l u d e \ b u l k l o a d i n g " o p e r a t i o n s o n   R  - t r e e s a n d   B  - t r e e s A H V V 9 9 ] .  

I n o r d e r t o p r e s e n t a c o n c i s e d e s c r i p t i o n o f o u r m e m o r y - a d a p t i v e b u e r t r e e , i t i s c o n v e n i e n t t o i n f o r m a l l y d i f -  

f e r e n t i a t e b e t w e e n t w o t y p e s o f e x t e r n a l m e m o r y p r o b l e m s : E x t e r n a l m e m o r y p r o b l e m s t h a t a r e   m e m o r y - o b l i v i o u s  

a n d e x t e r n a l m e m o r y p r o b l e m s t h a t a r e   m e m o r y - i n t e n s i v e  . M e m o r y - o b l i v i o u s p r o b l e m s i n c l u d e o p e r a t i o n s s u c h a s  

s c a n n i n g a l e , p a r t i t i o n i n g a l e i n t o a c o n s t a n t n u m b e r o f b u c k e t s , m e r g i n g t o g e t h e r a c o n s t a n t n u m b e r o f r u n s :  

A s s u m i n g t h a t t h e i n p u t s i z e c o n s i s t s o f   n  b l o c k s , a l l t h e a b o v e p r o b l e m s c a n b e s o l v e d i n a n o p t i m a l , l i n e a r n u m b e r  

O  (  n  ) n u m b e r o f I / O o p e r a t i o n s r e g a r d l e s s o f i n t e r n a l m e m o r y s i z e a n d a r e u n a e c t e d p o s i t i v e l y o r n e g a t i v e l y , b y  

m e m o r y u c t u a t i o n s . T h e   d o w n l o a d   ( ) o p e r a t i o n o f   M A M e r g e   i s a n e x a m p l e o f a m e m o r y - o b l i v i o u s o p e r a t i o n . O n  

t h e o t h e r h a n d , m e m o r y - i n t e n s i v e p r o b l e m s i n c l u d e s o r t i n g a l e , m e r g i n g a s e t o f   !  ( 1 ) r u n s t o g e t h e r , d i s t r i b u t i n g  

a n u n s o r t e d l e i n t o   !  ( 1 ) b u c k e t s . I n s u c h a p p l i c a t i o n s i t i s e s s e n t i a l t o m i m i c a n o p t i m a l a l g o r i t h m d e s i g n e d f o r t h e  

s t a t i c ,   m  - b l o c k m e m o r y v e r s i o n o f t h e p r o b l e m d u r i n g a l l o c a t i o n p h a s e s o f s i z e   m  ; n o t d o i n g s o r e s u l t s i n n o n o p t i m a l  

u t i l i z a t i o n o f a l l o c a t i o n s a n d a c c o m p a n y i n g o v e r h e a d . M e m o r y - a d a p t i v e a l g o r i t h m s f o r s u c h a p p l i c a t i o n s a r e a e c t e d  

b y m e m o r y u c t u a t i o n s a n d c h a n g e s i n t h e a l l o c a t i o n l e v e l : W h e n s u c h a l l o c a t i o n l e v e l s d r o p t h e y h a v e t o d o m o r e  

I / O t o d o t h e s a m e a m o u n t o f w o r k a n d w h e n a l l o c a t i o n l e v e l s r i s e t h e y c a n d o t h e s a m e w o r k w i t h a s m a l l n u m b e r  

o f I / O o p e r a t i o n s .  

W e i d e n t i f y t h e   b u e r - e m p t y i n g   o p e r a t i o n t o b e t h e o n l y m e m o r y - i n t e n s i v e o p e r a t i o n i n v o l v e d i n i m p l e m e n t i n g  

b u e r t r e e s a n d u s e o u r d y n a m i c a l l y o p t i m a l s o r t i n g t e c h n i q u e t o r e n d e r a n o p t i m a l , m e m o r y - a d a p t i v e v e r s i o n o f t h e  

1 4 1 

Page 155: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 155/203

b u e r e m p t y i n g o p e r a t i o n . S i n c e a l l o t h e r o p e r a t i o n s i n v o l v e d i n t h e b u e r t r e e t e c h n i q u e a r e m e m o r y - o b l i v i o u s , t h i s  

i s e n o u g h t o g u a r a n t e e a d y n a m i c a l l y o p t i m a l b u e r t r e e ( i n a n a m o r t i z e d s e n s e ) b y i n v o k i n g t h e s a m e a r g u m e n t s a s  

i n A r g 9 4 ] .  

D e n i t i o n 5 4   A b u e r t r e e o f f a n o u t p a r a m e t e r   m 

c o n s i s t s o f a n (  a ; b  ) - t r e e e x t e n d e d w i t h   m 

b u e r b l o c k s p e r  

i n t e r n a l n o d e w h e r e   a  =  m 

=  4  ; b  =  m 

, a s d e n e d i n A r g 9 4 ] . A   m e m o r y - a d a p t i v e b u e r t r e e   i s a b u e r t r e e o f f a n o u t  

p a r a m e t e r   m 

m a x 

, w h e r e   m 

m a x 

i s a p o l y n o m i a l i n   m 

m a x 

, w i t h m e m o r y - a d a p t i v e p e r f o r m a n c e ; t h a t i s , t h e b u e r t r e e  

o p e r a t i o n s h a v e t o b e p e r f o r m e d o v e r a n a l l o c a t i o n s e q u e n c e a s p e r o u r d y n a m i c m e m o r y m o d e l .  

I n s e r t a n d D e l e t e o p e r a t i o n s o n t h e b u e r t r e e m a y i n v o l v e t h e e x e c u t i o n o f b u e r e m p t y i n g c o m p u t a t i o n s a n d  

s p l i t t i n g a n d m e r g i n g n o d e s i n c o u r s e o f r e b a l a n c i n g o p e r a t i o n s . W e r e f e r t h e r e a d e r t o A r g 9 4 ] f o r d e t a i l s o n t h e  

b u e r t r e e . A n e x a m i n a t i o n o f b u e r t r e e o p e r a t i o n s a n d t h e t e c h n i q u e s u s e d t o i m p l e m e n t t h e m r e v e a l t h a t t h e b u e r  

e m p t y i n g o p e r a t i o n i s t h e o n l y m e m o r y - i n t e n s i v e b u e r t r e e o p e r a t i o n , a l l o t h e r o p e r a t i o n s b e i n g m e m o r y - o b l i v i o u s .  

5 . 1 2 . 1 M e m o r y - a d a p t i v e b u e r e m p t y i n g o f i n t e r n a l n o d e s  

I n t h e o r i g i n a l b u e r t r e e A r g 9 4 ] , t h e b u e r e m p t y i n g p r o c e s s a t i n t e r n a l n o d e   v  c o n s i s t s o f u s i n g (  m 

) b l o c k s o f  

m e m o r y t o e m p t y t h e c o n t e n t s a s s o c i a t e d w i t h n o d e   v  a s f o l l o w s :  

1 . L o a d i n t o i n t e r n a l m e m o r y a n d s o r t a t m o s t   m 

B =  2 t i m e s t a m p e d i t e m s o f t h e b u e r a s s o c i a t e d w i t h n o d e   v 

2 . D i s t r i b u t e t h e s e s o r t e d i t e m s , a f t e r c a n c e l l i n g o u t \ a n n i h i l a t i n g p a i r s " , i n t o a t m o s t   O  (  m 

) n o d e s c o r r e s p o n d i n g  

t o t h e c h i l d r e n o f n o d e   v  u s i n g t h e (  m 

) p a r t i t i o n i n g e l e m e n t s a s s o c i a t e d w i t h   v 

T h e a b o v e p r o c e d u r e t a k e s   O  (  m 

) I / O o p e r a t i o n s u s i n g (  m 

) i n t e r n a l m e m o r y b l o c k s . W e s h o w h o w t o i m p l e m e n t  

t h e a b o v e b u e r e m p t y i n g p r o c e s s i n o u r d y n a m i c m e m o r y m o d e l u s i n g n o m o r e t h a n   O  (  m 

m a x 

l g  m 

m a x 

) r e s o u r c e  

c o n s u m p t i o n i n o u r m e m o r y - a d a p t i v e b u e r t r e e .  

1 . T h e   m 

m a x 

B =  2 o r f e w e r t i m e s t a m p e d i t e m s o f n o d e   v  a r e s o r t i n g u s i n g o u r m e m o r y - s o r t i n g a l g o r i t h m u s i n g  

n o m o r e t h a n   O  (  m 

m a x 

l g  m 

m a x 

) r e s o u r c e c o n s u m p t i o n . T h i s i m p l e m e n t s S t e p 1 o f t h e a b o v e b u e r e m p t y i n g  

o p e r a t i o n .  

2 . S i n c e t h e s e t o f   m 

m a x 

B =  2 o r f e w e r i t e m s h a v e b e e n s o r t e d , w e c a n c a r r y o u t t h e d i s t r i b u t i o n o f t h e s e i t e m s t o  

t h e c h i l d r e n o f   v  i n a m e m o r y - o b l i v i o u s m a n n e r : s t r e a m t h r o u g h t h e s e r e c o r d s a n d t h e s o r t e d l i s t o f p a r t i t i o n i n g  

e l e m e n t s o f n o d e   v  : t h i s t a k e s n o m o r e t h a n   O  (  m 

m a x 

) I / O o p e r a t i o n s . T h e n e t r e s o u r c e c o n s u m p t i o n o v e r t h i s  

i m p l e m e n t a t i o n o f S t e p 2 o f t h e b u e r e m p t y i n g p r o c e s s c a n n o t b e m o r e t h a n   O  (  m 

m a x 

l g  m 

m a x 

)

H e n c e w e h a v e t h e f o l l o w i n g l e m m a .  

1 4 2 

Page 156: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 156/203

L e m m a 6 0   T h e t o t a l a m o u n t o f r e s o u r c e c o n s u m p t i o n d u r i n g a b u e r e m p t y i n g o p e r a t i o n o n a n i n t e r n a l n o d e o f  

o u r b u e r t r e e w i t h f a n o u t p a r a m e t e r m  

m a x 

i s  O  (  m 

m a x 

l g  m 

m a x 

5 . 1 2 . 2 M e m o r y - a d a p t i v e b u e r e m p t y i n g o f o t h e r n o d e s  

W e u s e t h e b u e r e m p t y i n g p r o c e s s o f S e c t i o n 5 . 1 2 . 1 e v e n i n t h e c a s e o f t r e e n o d e s j u s t a b o v e t h e l e v e l o f l e a f n o d e s ,  

w h i c h a r e n o t c o n s i d e r e d i n t e r n a l n o d e s A r g 9 4 ] . H o w e v e r , w h i l e t h e b u e r t r e e g u a r a n t e e s t h a t t h e b u e r e m p t y i n g  

c o m p u t a t i o n a t e a c h i n t e r n a l n o d e n e v e r i n v o l v e s m o r e t h a n   O  (  m 

m a x 

) b l o c k s o f r e c o r d s t o b e e m p t i e d , t h e r e i s n o s u c h  

g u a r a n t e e w h i l e e m p t y i n g t h e b u e r o f a t r e e n o d e j u s t a b o v e t h e l e v e l o f l e a f n o d e s . S o , a s f a r a s n o d e s j u s t a b o v e  

t h e l e v e l o f l e a f n o d e s a r e c o n c e r n e d , t h e b u e r e m p t y i n g p r o c e s s d e s c r i b e d a b o v e c a n i n v o l v e m o r e t h a n   m 

m a x 

B =  2 

i t e m s . I f t h e b u e r t r e e i s b e i n g u s e d t o c a r r y o u t a s e q u e n c e o f   N  =  n B  a r b i t r a r y i n s e r t / d e l e t e o p e r a t i o n s , t h e  

n u m b e r o f i t e m s i n v o l v e d i n a b u e r e m p t y i n g o p e r a t i o n a t a n o d e j u s t a b o v e t h e t r e e n o d e c o u l d b e a s h i g h a s  

O  (  n B  ) . F o r t u n a t e l y , i t c a n b e s h o w n A r g 9 4 ] t h a t e a c h i t e m  

1 2 

c a n b e i n v o l v e d a t m o s t o n c e i n a b u e r - e m p t y i n g  

c o m p u t a t i o n a t a n y n o d e o n t h e l e v e l j u s t a b o v e t h e l e a f l e v e l . T h i s m e a n s t h a t t h e n u m b e r o f i t e m s i n v o l v e d i n  

b u e r e m p t y i n g o p e r a t i o n s s u m m e d o v e r a l l t h e n o d e s o n t h e l e v e l j u s t a b o v e l e a f n o d e s i s   O  (  n B  )

U s i n g t h e s a m e t e c h n i q u e u s e d t o i m p l e m e n t t h e b u e r e m p t y i n g c o m p u t a t i o n f o r i n t e r n a l n o d e s w e h a v e t h e  

f o l l o w i n g l e m m a .  

L e m m a 6 1   C o n s i d e r a n i n i t i a l l y e m p t y b u e r t r e e w i t h f a n o u t p a r a m e t e r m  

m a x 

t h a t e v o l v e s o v e r a n a r b i t r a r y  

s e q u e n c e o f   n B  i n s e r t / d e l e t e o p e r a t i o n s . C o n s i d e r a l l t h e b u e r e m p t y i n g o p e r a t i o n s t h a t o c c u r a t n o d e s o n t h e  

l e v e l j u s t a b o v e t h e l e a f n o d e s o f t h e t r e e . L e t t h e   i  t h s u c h b u e r e m p t y i n g o p e r a t i o n o c c u r a t n o d e   v 

. L e t t h e t o t a l  

n u m b e r o f b l o c k s o f t h e i t e m s a s s o c i a t e d w i t h n o d e   v 

' s b u e r b e   n 

. T h e n  

1

P  

  n 

2 . T h e t o t a l a m o u n t o f r e s o u r c e c o n s u m p t i o n   R 

o f t h e b u e r e m p t y i n g o p e r a t i o n o n n o d e   v 

i s n o m o r e t h a n  

O  (  n 

l g  n 

3 . T h e t o t a l a m o u n t  

P  

o f r e s o u r c e c o n s u m p t i o n o v e r a l l b u e r e m p t y i n g o p e r a t i o n s a t n o d e s a t t h e l e v e l j u s t  

a b o v e t h e l e a f n o d e s o v e r t h e e n t i r e s e q u e n c e o f   n B  i n s e r t / d e l e t e o p e r a t i o n s i s  

P  

=  O  (  n  l g  n 

M a i n r e s u l t o n b u e r t r e e  

B a s e d u p o n L e m m a 6 0 a n d 6 1 a n d t h e a m o r t i z a t i o n a r g u m e n t s o f T h e o r e m 1 o f A r g 9 4 ] , w e h a v e t h e f o l l o w i n g  

t h e o r e m r e g a r d i n g r e s o u r c e c o n s u m p t i o n o f o u r m e m o r y - a d a p t i v e b u e r t r e e .  

1 2 

E a c h i t e m h e r e h a s a u n i q u e t i m e s t a m p . T h e   i  t h i n s e r t / d e l e t e o p e r a t i o n o n t h e b u e r t r e e  

g e n e r a t e s a r e c o r d w i t h t i m e s t a m p   i  . 

1 4 3 

Page 157: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 157/203

T h e o r e m 2 0   T h e t o t a l r e s o u r c e c o n s u m p t i o n o v e r a n a r b i t r a r y s e q u e n c e o f   n B  i n s e r t a n d d e l e t e o p e r a t i o n o n a n  

i n i t i a l l y e m p t y m e m o r y - a d a p t i v e b u e r t r e e i s   O  (  n  l g  n  )  ; t h e a m o r t i z e d r e s o u r c e c o n s u m p t i o n o f e a c h o p e r a t i o n i s  

 

( 1  = B  ) l g  n 

 

. O u r m e m o r y - a d a p t i v e b u e r t r e e i s d y n a m i c a l l y o p t i m a l .  

P r o o f   : T h e t o t a l n u m b e r o f t i m e s e a c h o f t h e   N  i t e m s c a n b e i n v o l v e d i n b u e r e m p t y i n g o p e r a t i o n s a t \ f u l l " i n t e r n a l  

n o d e s i s   O  ( l g  n =  l g  m 

m a x 

) A r g 9 4 ] . S i n c e e a c h s u c h b u e r e m p t y i n g p r o c e s s i n v o l v e s (  m 

m a x 

B  ) i t e m s a n d i n c u r s a  

r e s o u r c e c o n s u m p t i o n o f   O  (  m 

m a x 

l g  m 

m a x 

) r e s o u r c e c o n s u m p t i o n ( b y L e m m a 6 0 ) , t h e t o t a l r e s o u r c e c o n s u m p t i o n f o r  

a l l b u e r e m p t y i n g o p e r a t i o n s i n v o l v i n g \ f u l l " i n t e r n a l n o d e s i s  

N   

l g  n 

l g  m 

m a x 

 

m a x 

l g  m 

m a x 

m a x 

=  O  (  n  l g  n  ) 

E a c h r e b a l a n c e o p e r a t i o n  

1 3 

c a n i n c u r n o m o r e t h a n   O  (  m 

m a x 

l g  m 

m a x 

) r e s o u r c e c o n s u m p t i o n ( b y L e m m a 6 0 ) , a n d t h e r e  

a r e n o m o r e t h a n   O  (  n =  m 

m a x 

) r e b a l a n c i n g o p e r a t i o n s o v e r t h e e n t i r e s e q u e n c e o f   n B  i n s e r t / d e l e t e o p e r a t i o n s A r g 9 4 ] .  

T h u s r e b a l a n c i n g c a n n o t c o s t m o r e t h a n   O  (  n  l g  m 

m a x 

) =  O  (  n  l g  n  ) r e s o u r c e c o n s u m p t i o n . L e m m a 6 1 a c c o u n t s f o r t h e  

r e s o u r c e c o n s u m p t i o n d u r i n g b u e r e m p t y i n g o p e r a t i o n s a t n o n - i n t e r n a l n o d e s j u s t a b o v e t h e l e v e l o f l e a v e s . T h i s  

p r o v e s t h e t h e o r e m .  

5 . 1 3 D y n a m i c a l l y O p t i m a l M e m o r y - a d a p t i v e M a -    

t r i x A r i t h m e t i c      

I n t h i s s e c t i o n w e c o n s i d e r t h e p r o b l e m o f m u l t i p l y i n g t w o  

 ̂

N   

 ̂

N  m a t r i c e s i n a d y n a m i c a l l y o p t i m a l m a n n e r . I t t u r n s  

o u t t h a t t h e t e c h n i q u e s d e v e l o p e d h e r e f o r m a t r i x m u l t i p l i c a t i o n a l s o a p p l y t o t h e p r o b l e m o f L U f a c t o r i z a t i o n o f a n  

n  b l o c k m a t r i x , a s i m p l i e d b y r e s u l t s i n W G W R 9 3 ] . W e r s t c o n s i d e r i s s u e s r e l a t e d t o d i s k b l o c k l a y o u t o f m a t r i c e s  

t h a t a r i s e d u r i n g t h e a l g o r i t h m .  

5 . 1 3 . 1 T r a n s f o r m a t i o n b e t w e e n d i e r e n t b l o c k i n g o r d e r s  

C o n s i d e r t h e m u l t i p l i c a t i o n o f t w o  

 ̂

N   

 ̂

N  m a t r i c e s   A  a n d  B  e a c h c o n s i s t i n g o f   N  = 

 ̂

e l e m e n t s s p r e a d o v e r  

n  =  N = B 

1 4 

e l e m e n t s d i s k b l o c k s . T h e p r o d u c t m a t r i x   C  =  A B  a l s o c o n s i s t s o f   N  e l e m e n t s . F o r c o n v e n i e n c e , w e  

a s s u m e i n t h i s s e c t i o n t h a t   n  i s a p o w e r o f 4 : I f t h i s c o n d i t i o n i s n o t m e t e a c h m a t r i x c a n b e p a d d e d w i t h o u t c h a n g i n g  

t h e a s y m p t o t i c r u n n i n g t i m e o f o u r a l g o r i t h m .  

1 3 

I n e a c h r e b a l a n c e o p e r a t i o n , e i t h e r a n o d e i s s p l i t i n t o t w o o r t w o n o d e s a r e f u s e d i n t o o n e ; t h e  

l a t t e r o p e r a t i o n m a y r e q u i r e e m p t y i n g s o m e \ n o n - f u l l " b u e r c o n t a i n i n g   O  (  m 

m a x 

) b l o c k s . S e e  

A r g 9 4 ] f o r d e t a i l s .  

1 4 

I n c o n t r a s t t o p r e v i o u s d i s c u s s i o n s , i n t h i s S e c t i o n w e u s e   N  t o d e n o t e t h e s i z e o f t h e o u t p u t , a s  

o p p o s e d t o t h e i n p u t , w h i c h h e r e i s o f s i z e 2  N  . 

1 4 4 

Page 158: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 158/203

V e r y o f t e n , m a t r i c e s a r e s t o r e d i n   r o w - m a j o r   o r d e r , d e n e d b e l o w , o n d i s k . H o w e v e r , i n m a n y e x t e r n a l m e m o r y  

m a t r i x a l g o r i t h m s i t i s m o r e c o n v e n i e n t t o s t o r e m a t r i c e s i n   t w o - d i m e n s i o n a l b l o c k e d   o r d e r , d e n e d b e l o w , o n d i s k .  

D e n i t i o n 5 5   A n  N  = 

 ̂

N   

 ̂

N  s i z e d m a t r i x   A  i s s a i d t o b e s t o r e d i n r o w - m a j o r o r d e r o n d i s k i f i t s e l e m e n t s a r e o n  

n  b l o c k s   b 

i ; j 

, w h e r e 0     j   

N = B    1 a n d 0     i   

N    1 , s u c h t h a t b l o c k   b 

i ; j 

c o n t a i n s e l e m e n t s   A    i ; j B   ] t h r o u g h  

A    i ; j B   +  B    1 ]

A n  N  = 

 ̂

N   

 ̂

N  s i z e d m a t r i x   A  i s s a i d t o b e s t o r e d i n t w o - d i m e n s i o n a l b l o c k e d o r d e r o n d i s k i f i t s e l e m e n t s a r e  

o n  n  b l o c k s   b 

i ; j 

, w h e r e 0     i ; j    j  , s u c h t h a t   b 

i ; j 

c o n t a i n s t h e  

B  e l e m e n t s   A    i 

; j 

B  ] t h r o u g h   A    i 

; j 

B  + 

B    1 ] 

o f r o w   i 

, f o r e a c h   i 

s u c h t h a t   i 

B    i 

  i 

B  + 

B    1 . W e a s s u m e t h a t e a c h b l o c k   b 

i ; j 

o f t h e t w o - d i m e n s i o n a l  

b l o c k e d o r d e r h a s p o i n t e r s t o t h e ( a t m o s t t w o ) b l o c k s a d j a c e n t t o i t i n t h e r o w   i  o f b l o c k s a n d t h e ( a t m o s t t w o )  

b l o c k s a d j a c e n t t o i t i n t h e c o l u m n   j  o f b l o c k s .  

W e c a n t r a n s f o r m a n  

 ̂

N   

 ̂

N  m a t r i x ' s s t o r a g e f o r m a t f r o m r o w - m a j o r o r d e r t o t w o - d i m e n s i o n a l b l o c k e d o r d e r a s  

f o l l o w s : I f  

 ̂

N   

B  , t h e m a t r i x i s a l r e a d y i n t w o - d i m e n s i o n a l b l o c k e d o r d e r . A s s u m i n g  

 ̂

N > 

B  , i n a l i n e a r p a s s  

o v e r t h e m a t r i x w e a d d d u m m y e l e m e n t s i f n e c e s s a r y t o e n s u r e t h a t t h e n u m b e r o f r o w s a n d c o l u m n s i n t h e m a t r i x i s  

a m u l t i p l e o f  

B  . W i t h s o m e a b u s e o f n o t a t i o n , w e u s e t h e s a m e s y m b o l  

 ̂

N  t o d e n o t e t h e r e s u l t i n g n u m b e r o f r o w s  

a n d c o l u m n s . I f   r  = m i n  f 

B ; 

 ̂

N = 

B  g  , w e c a n p e r f o r m t h e d e s i r e d t r a n s f o r m a t i o n b y p e r f o r m i n g a s e r i e s o f   r  - w a y  

m e r g e s . E a c h o f t h e   r  r u n s a r e o n e b l o c k l o n g a n d t h e ( i m p l i c i t ) k e y s o f t h e m e r g e d i t e m s a r e d e t e r m i n e d b y t h e i r  

p o s i t i o n i n t h e r o w - m a j o r o r d e r .  

D u r i n g a l l o c a t i o n p h a s e s o f s i z e   x r  , w h e r e   b  x  c   1 ,  b  x  c  r  r o w - m a j o r o r d e r b l o c k s c a n b e t r i v i a l l y t r a n s f o r m e d  

i n t o   b  x  c  r  t w o - d i m e n s i o n a l o r d e r b l o c k s : T h e r e s o u r c e c o n s u m p t i o n o f t h e t r a n s f o r m a t i o n a l g o r i t h m d u r i n g a n y s u c h  

a l l o c a t i o n p h a s e i s   O 

 

(  x r  ) 

3  =  2 

 

O n t h e o t h e r h a n d , d u r i n g a l l o c a t i o n p h a s e s s m a l l e r t h a n   r  , w e c a n e m p l o y t h e m e m o r y - a d a p t i v e m e r g i n g a l g o r i t h m  

M A M e r g e   t o a p p r o p r i a t e l y i m p l e m e n t   r  - w a y m e r g e s r e a l i z i n g t h e r e q u i r e d t r a n s f o r m a t i o n . I f   m 

; m 

; : : : ; m  

a r e t h e  

s i z e s o f t h e a l l o c a t i o n p h a s e s i n v o l v e d i n a s i n g l e s u c h   r  - w a y m e m o r y - a d a p t i v e m e r g e c o m p u t a t i o n , w e k n o w f r o m  

T h e o r e m 1 7 t h a t  

X   

i  = 1 

l g  m 

  c r  l g  r 

w h e r e   c  i s a p o s i t i v e c o n s t a n t . I t f o l l o w s t h a t  

X   

i  = 1 

(  m 

l g  m 

  

l g  m 

 

  (  c r  l g  r  ) m a x  

1    i    t 

 

l g  m 

 

w h i c h i m p l i e s t h a t t h e n e t r e s o u r c e c o n s u m p t i o n o v e r t h e p h a s e s   m 

; m 

; : : : ; m  

i s n o m o r e t h a n   O  (  r 

3  =  2 

) , s i n c e  

m a x 

1    i    t 

=  l g  m 

g  

r =  l g  r  . T h u s w e h a v e t h e f o l l o w i n g l e m m a .  

1 4 5 

Page 159: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 159/203

L e m m a 6 2   A n y 

 ̂

N   

 ̂

N  m a t r i x c o n s i s t i n g o f   N  =  n B  = 

 ̂

e l e m e n t s c a n b e t r a n s f o r m e d f r o m r o w - m a j o r o r d e r t o  

t w o - d i m e n s i o n a l b l o c k e d o r d e r a n d v i c e - v e r s a w i t h o u t i n c u r r i n g a r e s o u r c e c o n s u m p t i o n o f m o r e t h a n   O  (  n 

3  =  2 

S i n c e w e a r e i n t e r e s t e d i n a n   O  (  n 

3  =  2 

) b o u n d o n t h e r e s o u r c e c o n s u m p t i o n o f o u r m e m o r y - a d a p t i v e m a t r i x m u l -  

t i p l i c a t i o n a l g o r i t h m , b y L e m m a 6 2 , w e c a n a s s u m e w i t h o u t l o s s o f g e n e r a l i t y t h a t a l l m a t r i c e s a r e s t o r e d i n t w o -  

d i m e n s i o n a l b l o c k e d o r d e r o n d i s k .  

5 . 1 3 . 2 M e m o r y - a d a p t i v e M a t r i x M u l t i p l i c a t i o n  

T h e i n - m e m o r y m a t r i x m u l t i p l i c a t i o n   A B  =  C  , w h e r e e a c h o f   A  ,  B  a n d  C  c o n s i s t   n  b l o c k s , c a n b e e x e c u t e d u s i n g  

a p p r o x i m a t e l y 3  n  b l o c k s o f i n t e r n a l m e m o r y a n d (  n  ) I / O o p e r a t i o n s . T h u s w e s e t t h e p a r a m e t e r   m 

m a x 

o f t h e  

d y n a m i c m e m o r y m o d e l t o b e   m 

m a x 

= m i n  f  3  n ;  p h y 

m a x 

T h e m u l t i p l i c a t i o n o f l a r g e m a t r i c e s c a n b e c a r r i e d o u t b y a s e r i e s o f m u l t i p l i c a t i o n s o f s m a l l e r m a t r i c e s a s  

e x p l a i n e d b e l o w . W e r s t c h o p t h e m a t r i c e s   A  ,  B  a n d  C  i n t o s u b m a t r i c e s e a c h c o n s i s t i n g o f a n a p p r o p r i a t e n u m b e r  

 ̂m 

m a x 

= (  m 

m a x 

) o f d i s k b l o c k s . W e o r g a n i z e t h e c o m p u t a t i o n   A B  =  C  t o p r o c e e d i n (  n =   ̂m 

m a x 

3  =  2 

s t e p s s u c h t h a t  

e a c h s t e p i s g u a r a n t e e d t o i n c u r r e s o u r c e c o n s u m p t i o n o f   O  (  ̂m 

3  =  2 

m a x 

) , t h u s o b t a i n i n g a d y n a m i c a l l y o p t i m a l m e m o r y -  

a d a p t i v e a l g o r i t h m .  

S u p p o s e t h a t m a t r i x   A  i s p a r t i t i o n e d i n t o (  n =   ̂m 

m a x 

) s q u a r e s u b m a t r i c e s   A 

i ; j 

, w h e r e 0     i ; j   

p  

n =   ̂m 

m a x 

  1 , 

s u c h t h a t e a c h s q u a r e s u b m a t r i x c o n s i s t s o f  

 ̂m 

m a x 

 

 ̂m 

m a x 

=  ̂m 

m a x 

b l o c k s . S u p p o s e t h a t   B  a n d  C  a r e s i m i l a r l y  

p a r t i t i o n e d i n t o s q u a r e s u b m a t r i c e s e a c h c o n s i s t i n g o f ^  m 

m a x 

b l o c k s . T h e n , w e o r g a n i z e o u t c o m p u t a t i o n o f   A B  =  C 

t o p r o c e e d a s f o l l o w s :  

1 . F o r 0     i ; j   

p  

n =   ̂m 

m a x 

  1 ,  C 

i ; j 

: = 0 . ( S e t e a c h s u b m a t r i x   C 

i ; j 

o f m a t r i x   C  t o z e r o . )  

2 . F o r 0     i ; j ; k    

p  

n =   ̂m 

m a x 

  1 ,  C 

i ; j 

: =  C 

i ; j 

+  A 

i ; k 

k ; j 

. ( C o m p u t e   A 

i ; k 

k ; j 

a n d a d d t h e r e s u l t i n g ^  m 

m a x 

e l e m e n t s t o t h e c o r r e s p o n d i n g e x i s t i n g ^  m 

m a x 

B  e l e m e n t s o f   C 

i ; j 

T h e f o l l o w i n g l e m m a c a n b e p r o v e d e a s i l y .  

L e m m a 6 3   T h e c o m p u t a t i o n i n d i c a t e d a b o v e i n S t e p s 1 a n d 2 c o r r e c t l y o u t p u t s t h e p r o d u c t m a t r i x   C  =  A B 

T h e c o m p u t a t i o n i n d i c a t e d i n S t e p 1 a b o v e c a n e a s i l y b e c a r r i e d o u t i m p l i c i t l y . I n t h e r e m a i n d e r o f t h i s S e c t i o n  

w e s h o w h o w t o c a r r y o u t t h e c o m p u t a t i o n   C 

i ; j 

: =  C 

i ; j 

+  A 

i ; k 

k ; j 

i n d i c a t e d i n S t e p 2 a b o v e i n a m e m o r y - a d a p t i v e  

m a n n e r i n c u r r i n g o n l y   O  (  ̂m 

3  =  2 

m a x 

) r e s o u r c e c o n s u m p t i o n , t h u s y i e l d i n g a d y n a m i c a l l y o p t i m a l m a t r i x m u l t i p l i c a t i o n  

a l g o r i t h m . I n o r d e r t o m i m i c t h e s t a n d a r d , I / O - o p t i m a l m a t r i x m u l t i p l i c a t i o n a l g o r i t h m f o r s t a t i c   m  - b l o c k i n t e r n a l  

m e m o r y , w e n e e d t o c a r r y o u t a m a t r i x m u l t i p l i c a t i o n o p e r a t i o n i n v o l v i n g (  m  ) b l o c k s d u r i n g a n a l l o c a t i o n p h a s e  

1 4 6 

Page 160: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 160/203

o f s i z e   m  : A s a r e s u l t o f t h e n a t u r e o f t h e r e s o u r c e c o n s u m p t i o n , w e n e e d t o \ p e b b l e "  

 

(  m B  ) 

3  =  2 

 

i n a \ t y p i c a l "  

a l l o c a t i o n p h a s e o f s i z e   m  , i n o r d e r t o a c h i e v e o p t i m a l i t y . T h i s s u g g e s t s t h a t t h e m a t r i x m u l t i p l i c a t i o n c o m p u t a t i o n  

s h o u l d b e o r g a n i z e d i n s u c h a m a n n e r t h a t w h e n e v e r t h e a l l o c a t i o n p h a s e s i z e   m 

i s i n t h e r a n g e  m ; c m   ] , f o r a  

c o n s t a n t   c >  1 , w e s h o u l d c a r r y o u t a a m u l t i p l i c a t i o n o f t w o s q u a r e s u b - m a t r i c e s e a c h c o n t a i n i n g (  c 

l o g 

) d i s k  

b l o c k s : T h i s e n s u r e s t h a t t h e n u m b e r o f D A G n o d e s p e b b l e d i s  

 

(  c 

l o g 

 

3  =  2 

) =  

 

(  m 

B  ) 

3  =  2 

 

D e n i t i o n 5 6   I n o u r m e m o r y - a d a p t i v e m a t r i x m u l t i p l i c a t i o n a l g o r i t h m a n a l l o c a t i o n p h a s e o f s i z e   m  i s s a i d t o b e a t  

a l l o c a t i o n l e v e l   l e v e l  (  m  ) , w h e r e   l e v e l  (  m  ) i s d e n e d ( f o r o u r m a t r i x m u l t i p l i c a t i o n a l g o r i t h m ) t o b e   d  l o g 

l e v e l  

e  , w h e r e  

l e v e l  

i s a n a p p r o p r i a t e l y c h o s e n p o s i t i v e c o n s t a n t . T h u s e a c h a l l o c a t i o n p h a s e i s a t s o m e l e v e l    ̀ w h e r e 1      ̀    ̀

m a x 

a n d   ̀

m a x 

=  l e v e l  (  m 

m a x 

) . W e d e n e ^  m 

m a x 

t o b e t h e n u m b e r 4  

 ̀

m a x 

  1 

5 . 1 3 . 3 M o p R e c o r d s a n d L e v e l - R e c o r d s  

W e f o c u s n o w o n t h e p r o b l e m o f i m p l e m e n t i n g t h e c o m p u t a t i o n o f S t e p 2 i n a m e m o r y - a d a p t i v e m a n n e r . I n o u r  

s c h e m e w e h a v e t o d e a l w i t h s q u a r e s u b m a t r i c e s c o n s i s t i n g o f 2  

 ̀

  2 

 ̀

b l o c k s , w h e r e 1      ̀    ̀

m a x 

. R e c a l l t h a t w e  

a s s u m e t h a t m a t r i c e s a r e s t o r e d i n t w o - d i m e n s i o n a l b l o c k e d o r d e r o n d i s k . T h u s , g i v e n a p o i n t e r t o a n y o n e b l o c k  

o f a s u b m a t r i x , w e c a n e a s i l y a c c e s s a l l o t h e r b l o c k s o f t h e s u b m a t r i x i n o r d e r t o t o l o a d t h e d i s k b l o c k s s u b m a t r i x  

i n t o m e m o r y . W i t h o u t l o s s o f g e n e r a l i t y , w e c h o o s e t h e p o i n t e r    p  ( 

 ̂

A  ) t o a s p e c i c b l o c k o f a m a t r i x  

 ̂

A  t o a c t a s t h e  

h a n d l e f o r m a t r i x  

 ̂

D e n i t i o n 5 7   G i v e n a s q u a r e m a t r i x  

 ̂

A  s t o r e d i n t w o - d i m e n s i o n a l b l o c k e d o r d e r o n d i s k , t h e   l t - p t r    p  ( 

 ̂

A  ) o f m a t r i x  

 ̂

A  i s t h e p o i n t e r t o t h a t b l o c k o f  

 ̂

A  t h a t i s t h e i n t e r s e c t i o n o f  

 ̂

A  ' s r s t r o w o f b l o c k s w i t h i t s r s t c o l u m n o f b l o c k s .  

W e a r e n o w i n a p o s i t i o n t o d e s c r i b e   m o p  ( m a t r i x o p e r a t i o n ) r e c o r d s , e a c h o f w h i c h c o r r e s p o n d s t o a m u l t i p l i c a t i o n  

o f s u b m a t r i c e s c o n s i s t i n g o f 2  

 ̀

  2 

 ̀

b l o c k s , f o r s o m e    ̀ s u c h t h a t 1      ̀    ̀

m a x 

D e n i t i o n 5 8   C o n s i d e r t h e m o p r e c o r d   m r  c o r r e s p o n d i n g t o t h e m a t r i x - m u l t i p l i c a t i o n  

 ̂

C  : = 

 ̂

C  + 

 ̂

 ̂

B  , w h e r e e a c h  

o n e o f  

 ̂

A ; 

 ̂

B  a n d 

 ̂

C  c o n s i s t o f 2  

 ̀

  2 

 ̀

b l o c k s . W e d e n o t e b y  

 ̂

i ; j 

, w h e r e 0     i ; j    1 , t h e f o u r 2  

 ̀   1 

  2 

 ̀   1 

- b l o c k  

n o n - o v e r l a p p i n g s q u a r e s u b m a t r i c e s , t h a t  

 ̂

A  c a n b e d e c o m p o s e d i n t o . S i m i l a r l y , w e d e n o t e b y  

 ̂

i ; j 

a n d 

 ̂

i ; j 

, w h e r e  

0    i ; j    1 , r e s p e c t i v e l y t h e s q u a r e s u b m a t r i c e s r e s u l t i n g f r o m a s i m i l a r d e c o m p o s i t i o n o f   B  a n d  C  r e s p e c t i v e l y . T h e  

m o p r e c o r d   m r  t h e n c o n s i s t s o f t h e f o l l o w i n g e l d s :  

1 l t p t r s   : T h i s e l d i s a s s i g n e d t h e t r i p l e    p  ( 

 ̂

A  )  ; p  ( 

 ̂

B  )  ;  a n d   p  ( 

 ̂

C  ) o f l t - p t r s o f m a t r i c e s  

 ̂

A ; 

 ̂

B  a n d 

 ̂

C  r e s p e c t i v e l y .  

2 l s i z e   : T h i s e l d a s s i g n e d t h e n u m b e r    ̀

1 4 7 

Page 161: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 161/203

3 s p l i t  : T h i s e l d i s a s s i g n e d t h e t w e l v e p o i n t e r s    p  ( 

 ̂

i ; j 

)  ; p  ( 

 ̂

i ; j 

)  ; p  ( 

 ̂

i ; j 

) w h e r e 0     i ; j    1 , w h i c h a r e r e s p e c t i v e l y  

t h e l t - p t r s o f t h e t w e l v e s u b m a t r i c e s  

 ̂

i ; j 

 ̂

i ; j 

;  a n d 

 ̂

i ; j 

d e n e d a b o v e .  

T h e t w e l v e p o i n t e r s a s s i g n e d t o t h e e l d   s p l i t   o f a m o p r e c o r d a r e u s e d t o f u r t h e r s p l i t t h e m a t r i x m u l t i p l i c a t i o n  

o p e r a t i o n i f n e e d e d , a s f o l l o w s : I f m a t r i x  

 ̂

A  ( r e s p e c t i v e l y  

 ̂

B  a n d 

 ̂

C  ) i s b r o k e n d o w n i n t o f o u r s q u a r e s u b m a t r i c e s  

 ̂

i ; j 

( r e s p e c t i v e l y  

 ̂

i ; j 

a n d 

 ̂

i ; j 

) w h e r e 0     i ; j    1 , t h e n t h e p r o d u c t  

 ̂

C  : = 

 ̂

C  + 

 ̂

 ̂

B  c a n b e c o m p u t e d b y c o m p u t i n g t h e  

e i g h t p r o d u c t s ,  

 ̂

i ; j 

: = 

 ̂

i ; j 

 ̂

i ; k 

 ̂

k ; j 

, w h e r e 0     i ; j ; k     1

D e n i t i o n 5 9   C o n s i d e r t h e m o p r e c o r d   m r  c o r r e s p o n d i n g t o t h e o p e r a t i o n  

 ̂

C  : = 

 ̂

C  + 

 ̂

 ̂

B  , w i t h  

 ̂

i ; j 

 ̂

i ; j 

;  a n d 

 ̂

i ; j 

f o r 0     i ; j    1 a s d e n e d a b o v e . S u p p o s e   q  i s a n i n t e g e r s u c h t h a t 0     q    7 . T h e n b y \ t h e   q  t h 0    1 t r i p l e " , w e r e f e r  

t o t h e t r i p l e (  i 

; j 

; k 

) t h a t i s t h e   q  t h t r i p l e i n a l e x i c o g r a p h i c o r d e r i n g o f t h e e i g h t t r i p l e s   f  (  i ; j ; k   ) : 0    i ; j ; k     1  g 

A n d b y \ t h e   q  t h s u b p r o d u c t o f m o p r e c o r d   m r  " , w e r e f e r t o t h e p r o d u c t  

 ̂

; j 

0  : = 

 ̂

; j 

0  + 

 ̂

; k 

 ̂

; j 

0  , w h e r e (  i 

; j 

; k 

i s t h e   q  t h 0    1 t r i p l e .  

W e a r e n o w i n a p o s i t i o n t o d e s c r i b e l e v e l - r e c o r d s f o r m a t r i x - m u l t i p l i c a t i o n , w h i c h p e r f o r m t h e s a m e r o l e h e r e  

t h a t t h e y p l a y e d i n o u r m e m o r y - a d a p t i v e s o r t i n g a l g o r i t h m : T h a t i s , g i v e n a n a l l o c a t i o n p h a s e a t l e v e l    ̀ , w e c a n  

s i m p l y l o o k u p   l r     ̀ ] , t h e l e v e l - r e c o r d c o r r e s p o n d i n g t o l e v e l    ̀ , t o d e c i d e w h a t c o m p u t a t i o n t o c a r r y o u t d u r i n g t h a t  

p h a s e .  

D e n i t i o n 6 0   C o n s i d e r    ̀ s u c h t h a t 1      ̀    ̀

m a x 

. T h e l e v e l - r e c o r d   l r     ̀ ] c o r r e s p o n d i n g t o a l l o c a t i o n l e v e l    ̀ i s e i t h e r  

s e t t o   n i l  o r c o n s i s t s o f t h e f o l l o w i n g e l d s :  

1 m r  : T h i s i s a s s i g n e d a m o p - r e c o r d   m r  s u c h t h a t   m r  l s i z e   =   ̀

2 . T h e i n t e g e r   c t r i p l e   s u c h t h a t 0     c t r i p l e     7

A l l l e v e l - r e c o r d s   l r     ̀ ] , w h e r e 1      ̀    ̀

m a x 

, a r e s t o r e d a s a s b l o c k e d l i n k e d l i s t .  

W h e n o u r a l g o r i t h m i s s u b j e c t e d t o a p h a s e a t l e v e l    ̀ , o u r a l g o r i t h m l o o k s u p   l r     ̀ ] a n d t h e n e x e c u t e s c o m p u t a t i o n  

c o r r e s p o n d i n g t o t h e   l r     ̀ ]  c t r i p l e   - t h s u b p r o d u c t o f m o p r e c o r d   l r     ̀ ]  m r  , i n c r e m e n t i n g   l r     ̀ ]  c t r i p l e  

5 . 1 3 . 4 T h e   l o a d l e v e l  ( ) ,  d o w n l o a d   ( ) , a n d   l l m u l t  ( ) S u b r o u t i n e s  

W e n o w d e s c r i b e t h e   l o a d l e v e l  ( ) a n d   d o w n l o a d   ( ) f u n c t i o n s t h a t p r o v i d e t h e s a m e f u n c t i o n a l i t y t h e y d i d d u r i n g  

m e m o r y - a d a p t i v e s o r t i n g .  

T h e a l g o r i t h m m a i n t a i n s a v a r i a b l e c a l l e d   m a x l e v e l   s u c h t h a t 1     m a x l e v e l      ̀

m a x 

i s a l w a y s t r u e . I n t u i t i v e l y ,  

m a x l e v e l   i s s u c h t h a t a n y t i m e o u r a l g o r i t h m i s s u b j e c t e d t o a n a l l o c a t i o n p h a s e a t l e v e l   m a x l e v e l   + 1 o r h i g h e r ,  

1 4 8 

Page 162: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 162/203

i t c o m p l e t e s t h e e n t i r e c o m p u t a t i o n i n v o l v e d i n a n i n s t a n c e o f S t e p 2 o f S e c t i o n 5 . 1 3 . 2 : I f , o n a n y g i v e n i n s t a n c e ,  

s o m e c o m p u t a t i o n p e r t a i n i n g t o t h a t i n s t a n c e h a s a l r e a d y b e e n c o m p l e t e d b e f o r e r e c e i v i n g t h e p h a s e a t a l l o c a t i o n  

l e v e l g r e a t e r t h a n   m a x l e v e l  , w e s i m p l y e x e c u t e t h e r e m a i n i n g c o m p u t a t i o n r e q u i r e d t o n i s h p r o c e s s i n g t h a t i n s t a n c e ,  

d u r i n g t h a t p h a s e . E v e n i f t h e a l l o c a t i o n l e v e l i s n e v e r   m a x l e v e l  + 1 , o u r a l g o r i t h m c o m p l e t e s t h e c o m p u t a t i o n o f e a c h  

i n s t a n c e o f S t e p 2 o f S e c t i o n 5 . 1 3 . 2 e c i e n t l y . U n t i l t h e p r o c e s s i n g o f a g i v e n i n s t a n c e o f S t e p 2 o f S e c t i o n 5 . 1 3 . 2 i s  

n o t c o m p l e t e d , w e h a v e   l r    m a x l e v e l  ]  6=  n i l  . T h u s t h e v a r i a b l e   m a x l e v e l   i s u p d a t e d a p p r o p r i a t e l y d u r i n g t h e f u n c t i o n s  

l o a d l e v e l  ( ) a n d   d o w n l o a d   ( )

T h e s u b r o u t i n e   l o a d l e v e l  (   ̀ ) 

A s m e n t i o n e d e a r l i e r , o u r g o a l i s t o e x e c u t e a s u b p r o d u c t o f   l r     ̀ ]  m r  w h e n t h e a l l o c a t i o n l e v e l i s    ̀ . W h e n a l l s u c h  

s u b p r o d u c t s o f a g i v e n m o p r e c o r d   l r     ̀ ]  m r  a r e c o m p l e t e d ,   l r     ̀ ] i s s e t t o   n i l  . W h e n t h i s h a p p e n s , w e n e e d t o a s s i g n  

c o m p u t a t i o n w o r k t o   l r     ̀ ] a p p r o p r i a t e l y i n a d y n a m i c m a n n e r i n o r d e r t o u s e f u t u r e p h a s e s a t l e v e l   ̀ e e c t i v e l y . T h e  

p r o c e d u r e   l o a d l e v e l  (   ̀ ) , w h e r e 1      ̀    ̀

m a x 

  1 , g i v e n b e l o w , i s e x e c u t e d t o a s s i g n w o r k f r o m   l r     ̀ + 1 ] t o   l r     ̀ ] a n d i s  

e x e c u t e d o n l y w h e n   l r     ̀ + 1 ]  6=  n i l  : 

1 . S u p p o s e t h a t   l r     ̀ + 1 ]  m r  c o r r e s p o n d s t o t h e m a t r i x o p e r a t i o n  

 ̂

C  : = 

 ̂

C  + 

 ̂

 ̂

B  . L e t   q  =  l r     ̀ + 1 ]  c t r i p l e   a n d l e t  

(  i ; j ; k   ) b e s u c h t h a t  

 ̂

i ; j 

+   

 ̂

i ; k 

 ̂

k ; j 

i s t h e   q  t h s u b p r o d u c t o f   l r     ̀ + 1 ]  m r  . S u p p o s e   x  i s a n e w m o p r e c o r d  

t o b e a p p r o p r i a t e l y i n i t i a l i z e d .  

2 . S e t   x l t p t r s   t o t h e t r i p l e    p  ( 

 ̂

i ; k 

)  ; p  ( 

 ̂

k ; j 

)  ; p  ( 

 ̂

i ; j 

) o f l t - p t r s .  

3 . S e t   x l s i z e   t o   ̀

4 . I f    ̀   1 , t h e n c o m p u t e t h e f o u r l t - p t r s    p  (  X 

; j 

0  ) , w h e r e 0     i 

; j 

  1 , c o r r e s p o n d i n g t o t h e f o u r 2  

 ̀   1 

  2 

 ̀   1 

b l o c k s u b m a t r i c e s   X 

; j 

0  , f o r e a c h o n e o f   X  = 

 ̂

i ; k 

; X  = 

 ̂

k ; j 

;  a n d  X  = 

 ̂

i ; j 

. T h e s e p o i n t e r s c a n b e c o m p u t e d  

b y t r a v e r s i n g a p p r o p r i a t e l y t h e b o u n d a r y b l o c k s o f   X  , f o r a g i v e n v a l u e o f   X  . S e t   x s p l i t   t o t h e t w e l v e p o i n t e r s  

s o o b t a i n e d .  

5 . S e t   l r     ̀ ]  m r  t o  x  a n d  l r     ̀ ]  c t r i p l e   = 0

6 . I f   l r     ̀ + 1 ]  c t r i p l e   <  7 , i n c r e m e n t   l r     ̀ + 1 ]  c t r i p l e   . O t h e r w i s e , s e t   l r     ̀ + 1 ] t o   n i l  a n d I f   m a x l e v e l   =   ̀ + 1 s e t  

m a x l e v e l   t o   ̀

T h e f o l l o w i n g l e m m a b o u n d s t h e t o t a l n u m b e r o f I / O s a n d t h e t o t a l n u m b e r o f i n t e r n a l m e m o r y b l o c k s r e q u i r e d  

t o e x e c u t e   l o a d l e v e l  (   ̀ )

L e m m a 6 4   T h e t o t a l n u m b e r o f i n t e r n a l m e m o r y b l o c k s r e q u i r e d d u r i n g t h e e x e c u t i o n o f l o a d l e v e l  (   ̀ )  i s  O  ( 1 )  . T h e  

t o t a l n u m b e r o f I / O o p e r a t i o n s i n c u r r e d d u r i n g l o a d l e v e l  (   ̀ )  i s  O  ( 2 

 ̀   1 

1 4 9 

Page 163: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 163/203

P r o o f  : I t i s e a s y t o s e e t h a t n o m o r e t h a n a c o n s t a n t a m o u n t o f i n t e r n a l m e m o r y i s r e q u i r e d d u r i n g   l o a d l e v e l  (   ̀ )

A s r e g a r d s t h e n u m b e r o f I / O o p e r a t i o n s , i t c a n b e s e e n t h a t f o r e a c h o n e o f t h e t h r e e i n s t a n c e s o f   X  , o b t a i n i n g  

t h e l t - p t r s o f   X 

; j 

0  , w h e r e 0     i 

; j 

  1 , t a k e s n o m o r e t h a n   O  ( 2 

 ̀   1 

) I / O o p e r a t i o n s . N o o t h e r a c t i v i t y d u r i n g  

l o a d l e v e l  (   ̀ ) i n c u r s a n y I / O . T h u s t h e l e m m a i s p r o v e d .  

T h e s u b r o u t i n e   d o w n l o a d   (   ̀

W h e n e v e r   l r     ̀

] i s  n i l  w e m a y n e e d t o a s s i g n s o m e n e w w o r k t o   l r     ̀

] f r o m s o m e l e v e l - r e c o r d a t a h i g h e r l e v e l    ̀ + 1 , 

w h e r e    ̀

   ̀ , v i a a s e r i e s o f a p p l i c a t i o n s o f   l o a d l e v e l  (   ̀

0 0 

) f o r    ̀

   ̀

0 0 

   ̀ . W e p r e s e n t b e l o w t h e s t e p s i n v o l v e d i n  

d o w n l o a d   (   ̀

) , w h i c h i s o n l y e x e c u t e d w h e n    ̀

<  m a x l e v e l  : 

1 . S e t    ̀

0 0 

=   ̀

2 . W h i l e   l r     ̀

0 0 

] =  n i l  ,   ̀

0 0 

=   ̀

0 0 

+ 1

3 . S e t    ̀ =   ̀

0 0 

  1

4 . F o r    ̀

0 0 

g o i n g f r o m    ̀ d o w n t o    ̀

, e x e c u t e   l o a d l e v e l  (   ̀

0 0 

)

D e n i t i o n 6 1   T h e l e v e l s    ̀

t h r o u g h    ̀ a r e s a i d t o h a v e b e e n l o a d e d b y t h e   d o w n l o a d   (   ̀

) c a l l d e s c r i b e d a b o v e . L e v e l  

 ̀ i s s a i d t o b e t h e h i g h e s t l e v e l t o b e l o a d e d .  

T h e f o l l o w i n g l e m m a b o u n d s t h e t o t a l m e m o r y a n d I / O r e q u i r e m e n t o f   d o w n l o a d   (   ̀

) . T h e p r o o f f o l l o w s e a s i l y  

f r o m L e m m a 6 4 .  

L e m m a 6 5   S u p p o s e    ̀ i s a s d e n e d a b o v e ; t h a t i s ,    ̀ i s t h e h i g h e s t l e v e l t o g e t l o a d e d d u r i n g d o w n l o a d   (   ̀

)  . T h e n  

t h e t o t a l n u m b e r o f I / O s i n c u r r e d i n r s t a c c e s s i n g l r     ̀

]  b y f o l l o w i n g t h e b l o c k e d l i n k e d l i s t o f l e v e l - r e c o r d s a n d t h e n  

e x e c u t i n g d o w n l o a d   (   ̀

)  i s  O  ( 2 

 ̀   1 

)  . T h e t o t a l n u m b e r o f i n t e r n a l m e m o r y b l o c k s r e q u i r e d i s   O  ( 1 ) 

T h e f o l l o w i n g l e m m a i s u s e f u l w h i l e a c c o u n t i n g f o r t h e r e s o u r c e c o n s u m p t i o n d u r i n g   d o w n l o a d   ( ) o p e r a t i o n s .  

L e m m a 6 6   C o n s i d e r a s e q u e n c e o f   d  o p e r a t i o n s s u c h t h a t :  

1 . I n t h e   i  t h o p e r a t i o n , w h e r e   0    i    d    1  , w e t r a v e r s e t h e b l o c k e d l i n k e d l i s t o f l e v e l - r e c o r d s t o a c c e s s l r      ̀

]  a n d 

t h e n e x e c u t e d o w n l o a d   (   ̀

2 . O v e r t h e e n t i r e s e q u e n c e o f   d  o p e r a t i o n s , f o r n o l e v e l    ̀

, w h e r e   1     ̀

   ̀

m a x 

  1  , i s l o a d l e v e l  (   ̀

)  e x e c u t e d m o r e  

t h a n o n c e . M o r e o v e r , l e t    ̀ d e n o t e d t h e h i g h e s t l e v e l    ̀

f o r w h i c h l o a d l e v e l  (   ̀

)  w a s e x e c u t e d o v e r t h e s e q u e n c e  

o f  d  o p e r a t i o n s .  

T h e n t h e r e e x i s t s a s m a l l p o s i t i v e c o n s t a n t   c 

d l 

s u c h t h a t t h e n u m b e r o f I / O o p e r a t i o n s o v e r t h e e n t i r e s e q u e n c e o f   d 

o p e r a t i o n s i s n o m o r e t h a n   c 

d l 

  2 

 ̀   1 

1 5 0 

Page 164: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 164/203

T h e s u b r o u t i n e   l l m u l t  ( ) 

W e n o w d e s c r i b e t h e s i m p l e m a t r i x m u l t i p l i c a t i o n r o u t i n e   l l m u l t  (   ̀ ) e x e c u t e d w h e n t h e a l l o c a t i o n l e v e l i s    ̀ a n d  l r     ̀ ] 

i s n o t   n i l  . B a s i c a l l y t h i s r o u t i n e s i m p l y r e a d s i n t h e b l o c k s o f t h e s u b m a t r i c e s i n v o l v e d i n t h e   q  t h s u b p r o d u c t o f  

l r     ̀ ]  m r  , w h e r e   q  =  l r     ̀ ]  c t r i p l e   , c a r r i e s o u t t h e m u l t i p l i c a t i o n a n d a d d i t i o n , a n d t h e n w r i t e s t h e b l o c k s b a c k t o d i s k .  

1 . S u p p o s e   l r     ̀ ]  l t p t r s   c o n t a i n s t h e l t - p t r s o f s u b m a t r i c e s  

 ̂

A ; 

 ̂

B ;  a n d 

 ̂

C  r e s p e c t i v e l y , e a c h c o n s i s t i n g o f 2  

 ̀

  2 

 ̀

b l o c k s .  

S u p p o s e   l r     ̀ ]  c t r i p l e   i s  q  a n d t h a t (  i ; j ; k   ) i s t h e   q  t h 0    1 t r i p l e .  

2 . U s e t h e l t - p t r s    p  ( 

 ̂

i ; k 

)  ; p  ( 

 ̂

j ; k 

) a n d    p  ( 

 ̂

i ; j 

) s t o r e d i n t h e e l d   l r     ̀ ]  m r  s p l i t   t o r e s p e c t i v e l y r e a d i n b l o c k s o f t h e  

t h r e e 2  

 ̀   1 

  2 

 ̀   1 

- b l o c k s u b m a t r i c e s  

 ̂

i ; k 

 ̂

j ; k 

;  a n d 

 ̂

i ; j 

3 . P e r f o r m t h e i n t e r n a l m e m o r y c o m p u t a t i o n  

 ̂

i ; j 

: = 

 ̂

i ; j 

 ̂

i ; k 

 ̂

k ; j 

4 . W r i t e t h e d i s k b l o c k s o f  

 ̂

i ; j 

b a c k t o d i s k .  

1 5 

5 . I f   l r     ̀ ]  c t r i p l e   <  7 , i t i s i n c r e m e n t e d . O t h e r w i s e   l r     ̀ ] i s s e t t o   n i l  . L e v e l - r e c o r d   l r     ̀ ] i s w r i t t e n t o d i s k .  

W e w i l l n o w b o u n d t h e t o t a l n u m b e r o f I / O s a n d t h e t o t a l m e m o r y r e q u i r e m e n t o f   l l m u l t   (   ̀ )

L e m m a 6 7   T h e n u m b e r o f I / O o p e r a t i o n s i n c u r r e d i n a c c e s s i n g l r     ̀ ]  u s i n g t h e b l o c k e d l i n k e d l i s t o f l e v e l - r e c o r d s  

i s n o m o r e t h a n   ` = B  + 1  . T h e n u m b e r o f I / O o p e r a t i o n s i n c u r r e d d u r i n g l l m u l t  (   ̀ )  i s n o m o r e t h a n   4    4 

 ̀   1 

. T h e  

t o t a l n u m b e r o f i n t e r n a l m e m o r y b l o c k s r e q u i r e d i s n o m o r e t h a n   4    4 

 ̀   1 

. T h e r e e x i s t s a s m a l l c o n s t a n t   c 

l l m 

s u c h  

t h a t t h e t o t a l n u m b e r o f I / O o p e r a t i o n s i n c u r r e d i n r s t a c c e s s i n g l r     ̀ ]  a n d t h e n e x e c u t i n g l l m u l t  (   ̀ )  i s b o u n d e d b y  

l l m 

  4 

 ̀   1 

a n d t h e t o t a l n u m b e r o f m e m o r y b l o c k s r e q u i r e d i s b o u n d e d b y   c 

l l m 

  4 

 ̀   1 

=  2 

P r o o f  : T h e p r o o f i s t r i v i a l s i n c e t h e n u m b e r o f l e v e l - r e c o r d s i n t h e a c c e s s e d p o r t i o n o f t h e b l o c k e d l i s t o f l e v e l - r e c o r d s  

i s   ̀ a n d t h e n u m b e r o f b l o c k s o f  

 ̂

i ; k 

 ̂

k ; j 

;  a n d 

 ̂

i ; j 

e a c h i s 4  

 ̀   1 

; b l o c k s o f  

 ̂

i ; k 

a n d 

 ̂

k ; j 

a r e o n l y r e a d i n w h e r e a s  

b l o c k s o f  

 ̂

i ; j 

a r e i n p u t a n d t h e n o u t p u t a f t e r c o m p u t a t i o n .  

W e p r e s e n t a u s e f u l l e m m a t h a t w i l l c o m e i n h a n d y w h i l e a c c o u n t i n g f o r r e s o u r c e c o n s u m p t i o n .  

L e m m a 6 8   S u p p o s e   c 

l l m 

i s a s d e n e d i n L e m m a 6 7 . T h e n t h e r e e x i s t s a s m a l l p o s i t i v e c o n s t a n t   c 

l l m 

s u c h t h a t  

P  

 ̀

 ̀

= 1 

l l m 

  4 

 ̀

  1 

  c 

l l m 

  4 

 ̀   1 

1 5 

I n p r a c t i c e t h e l e v e l    ̀ m a t r i x m u l t i p l i c a t i o n o p e r a t i o n s c a n b e o r d e r e d s u c h t h a t t h e n e x t l e v e l    ̀

o p e r a t i o n i s  

 ̂

i ; j 

+   

 ̂

i ; k  + 1 

 ̂

k  + 1  ; j 

s o t h a t d i s k b l o c k s o f  

 ̂

i ; j 

w o u l d n o t b e w r i t t e n b a c k t o d i s k  

i f i f t h e a l l o c a t i o n l e v e l r e m a i n s    ̀ l o n g e n o u g h f o r t h i s n e x t o p e r a t i o n t o i m m e d i a t e l y f o l l o w t h e  

 j u s t c o m p l e t e d o p e r a t i o n .  

1 5 1 

Page 165: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 165/203

5 . 1 3 . 5 A l g o r i t h m   M A M u l t i p l y  

T h e p r o c e d u r e   d o w n l o a d   ( ) d e s c r i b e d a b o v e i s m e m o r y o b l i v i o u s i n t h e s e n s e i t c a n f u n c t i o n w i t h s o m e c o n s t a n t  

n u m b e r   c  o f i n t e r n a l m e m o r y b l o c k s a n d s i n c e w e e n s u r e t h a t t h e s m a l l e s t a l l o c a t i o n p h a s e h a s s i z e   c  , i t c a n e x e c u t e  

i n a n y a l l o c a t i o n p h a s e . T h e p r o c e d u r e   l l m u l t  (   ̀ ) o n t h e o t h e r h a n d r e q u i r e s   O  ( 4 

 ̀   1 

) i n t e r n a l m e m o r y b l o c k s o v e r a  

s e q u e n c e o f   O  ( 4 

 ̀   1 

) I / O o p e r a t i o n s , s o i t i s e x e c u t e d w h e n t h e a l l o c a t i o n l e v e l i s    ̀ . W e n o w s h o w h o w t o s e w t h e s e  

t w o p r o c e d u r e s t o g e t h e r t o o b t a i n a m e m o r y - a d a p t i v e m a t r i x m u l t i p l i c a t i o n a l g o r i t h m .  

C o n s i d e r s o m e p o i n t o f t i m e a t w h i c h t h e a l l o c a t i o n l e v e l i s    ̀ a n d w e c o u l d s t a r t e x e c u t i o n o n   l l m u l t  (   ̀ ) : I t i s  

a p p r o p r i a t e t o a c t u a l l y g o t h r o u g h w i t h t h e c a l l t o   l l m u l t  (   ̀ ) o n l y w h e n e i t h e r t h e c u r r e n t a l l o c a t i o n p h a s e , s a y o f s i z e  

m  , h a s   O  ( 4 

 ̀   1 

) I / O o p e r a t i o n s r e m a i n i n g i n i t o r i f w e k n o w t h a t t h e n e x t a l l o c a t i o n p h a s e i s a l s o a l e v e l    ̀ a l l o c a t i o n  

p h a s e . W e d e n e t h e f o l l o w i n g p r e d i c a t e   e n o u g h   (  m  ) t o g u i d e t h i s d e c i s i o n o f t h e m e m o r y - a d a p t i v e a l g o r i t h m  

D e n i t i o n 6 2   D u r i n g a n o n g o i n g a l l o c a t i o n p h a s e o f s i z e   m  s u c h t h a t   l e v e l  (  m  ) =   ̀ , t h e b o o l e a n p r e d i c a t e   e n o u g h   (  m  ) 

i s t r u e i f a n d o n l y i f   l e f t     c 

l l m 

  4 

 ̀   1 

o r  l e v e l  (  n e x t  ) =   ̀

W e n o w d e n e t h e c o n s t a n t   c 

l e v e l  

a p p r o p r i a t e l y , w h i c h i s i n s t r u m e n t a l i n t h e c l a s s i c a t i o n o f a l l o c a t i o n p h a s e s i z e s  

i n t o d i e r e n t a l l o c a t i o n l e v e l s .  

D e n i t i o n 6 3   W e d e n e t h e c o n s t a n t   c 

l e v e l  

t o b e t h e s m a l l e s t c o n s t a n t s u c h t h a t 2  c 

l e v e l  

  c 

l l m 

+  c 

d l 

W e n o w p r e s e n t t h e m e m o r y - a d a p t i v e m a t r i x m u l t i p l i c a t i o n t h a t c a r r i e s o u t t h e c o m p u t a t i o n  

 ̂

C  +   

 ̂

A   

 ̂

B  , w h e r e  

e a c h o f  

 ̂

A ; 

 ̂

B ;  a n d 

 ̂

C  c o n s i s t o f  

 ̂m 

m a x 

 

 ̂m 

m a x 

b l o c k s , t h u s y i e l d i n g a m e m o r y - a d a p t i v e i m p l e m e n t a t i o n o f S t e p 2 .  

W e u s e   c l e v e l   t o m e a n   l e v e l  (  m e m  ) i n t h e f o l l o w i n g d e s c r i p t i o n .  

1 . I n i t i a l i z e a l l e l d s o f a n e w m o p r e c o r d   x  c o r r e s p o n d i n g t o t h e m a t r i x - m u l t i p l i c a t i o n o p e r a t i o n  

 ̂

C  +   

 ̂

A   

 ̂

T h e n s e t   l r     ̀

m a x 

]  m r  t o  x  a n d  l r     ̀

m a x 

]  c t r i p l e   t o 0 . S e t   m a x l e v e l   t o   ̀

m a x 

2 . W h i l e (  l r    m a x l e v e l  ]  6=  n i l  ) e x e c u t e t h e f o l l o w i n g :  

( a ) W a l k t h r o u g h l e v e l - r e c o r d s u n t i l   l r  m i n   f  c l e v e l  ;  m a x l e v e l  g  ] i s i n m e m o r y .  

( b ) I f (  c l e v e l   >  m a x l e v e l  ) , c o m p l e t e t h e o p e r a t i o n l o a d i n g i n a p p r o p r i a t e b l o c k s i n t o i n t e r n a l m e m o r y , p e r -  

f o r m i n g r e q u i r e d o p e r a t i o n s a n d t h e n w r i t i n g t h e m o u t t o d i s k . S e t   l r     ̀ ] t o  n i l  f o r a l l    ̀

( c ) O t h e r w i s e ; t h a t i s , i f (  c l e v e l     m a x l e v e l  ) , t h e n  

( d ) I f (  l r    c l e v e l  ] =  n i l  ) , t h e n  

i . E x e c u t e   d o w n l o a d   (  c l e v e l  )

1 5 2 

Page 166: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 166/203

i i . ( H e r e ,   m e m  m a y h a v e c h a n g e d f r o m i t s v a l u e a t t h e b e g i n n i n g o f S t e p 2 ( d ) i . ) I f   e n o u g h   (  m e m  ) i s f a l s e  

t h e n r e l i n q u i s h w h a t ' s l e f t o f t h e o n g o i n g a l l o c a t i o n p h a s e .  

i i i . G o T o S t e p 2 a .  

( e ) O t h e r w i s e ; t h a t i s , i f (  l r    c l e v e l  ]  6=  n i l  ) , t h e n  

i . W h i l e (  e n o u g h   (  m e m  ) A N D   l r    c l e v e l  ]  6=  n i l  , e x e c u t e   l l m u l t   (  c l e v e l  )

i i . I f   e n o u g h   (  m e m  ) i s f a l s e t h e n r e l i n q u i s h w h a t ' s l e f t o f t h e o n g o i n g a l l o c a t i o n p h a s e .  

i i i . G o T o S t e p 2 a .  

F o r a n a l y s i s , i t i s c o n v e n i e n t t o d e n e t h e c a l l   l l m u l t  (  m a x l e v e l  + 1 ) , a l t h o u g h   l l m u l t   (   ̀ ) i s o n l y d e n e f o r t h e c a s e  

 ̀   m a x l e v e l  

D e n i t i o n 6 4   W e d e n e t h e c o m p u t a t i o n i n v o l v e d i n t h e e x e c u t i o n o f S t e p 2 b a b o v e t o b e t h e c o m p u t a t i o n c o r r e -  

s p o n d i n g t o   l l m u l t  (  m a x l e v e l   + 1 ) . T h u s ,   l l m u l t   (  m a x l e v e l   + 1 ) i s s a i d t o b e e x e c u t e d w h e n ( a n d i f ) S t e p 2 b a b o v e i s  

e x e c u t e d .  

5 . 1 3 . 6 R e s o u r c e C o n s u m p t i o n A n a l y s i s o f   M A M u l t i p l y  

W e w i l l n o w p r o v e t h a t t h e a l g o r i t h m   M A M u l t i p l y   c o m p u t e s t h e m a t r i x m u l t i p l i c a t i o n o p e r a t i o n  

 ̂

C  +   

 ̂

 ̂

B  , w h e r e  

e a c h o f t h e t h r e e s u b m a t r i c e s c o n s i s t o f  

 ̂m 

m a x 

 

 ̂m 

m a x 

b l o c k s e a c h , i n c u r r i n g a r e s o u r c e c o n s u m p t i o n o f n o m o r e  

t h a n   O  (  ̂m 

3  =  2 

m a x 

) . W e r s t p r o v e t h a t t h e r e s o u r c e c o n s u m p t i o n i n t h e   d o w n l o a d   ( ) e x p e n s e a c c o u n t i s   O  (  ̂m 

3  =  2 

m a x 

) b y 

c o m b i n i n g b o u n d s o n t h e n u m b e r o f  d o w n l o a d   ( ) o p e r a t i o n s w i t h b o u n d s o n t h e a m o u n t o f r e s o u r c e c o n s u m p t i o n o f  

i n d i v i d u a l   d o w n l o a d   ( ) o p e r a t i o n s . T h e f a c t t h a t t h e r e s o u r c e c o n s u m p t i o n o f a l l   l l m u l t  ( ) o p e r a t i o n s i s   O  (  ̂m 

3  =  2 

m a x 

f o l l o w s f r o m t h e o b s e r v a t i o n t h a t t h e   O  ( 4 

3  ` =  2 

) r e s o u r c e c o n s u m p t i o n d u r i n g t h e e x e c u t i o n o f   l l m u l t  (   ̀ ) i s c h a r g e d t o  

t h e  

 

( 4 

 ̀

B  ) 

3  =  2 

 

p e b b l i n g o p e r a t i o n s p e r f o r m e d d u r i n g   l l m u l t  (   ̀ )

R e s o u r c e c o n s u m p t i o n o f   d o w n l o a d   ( ) o p e r a t i o n s  

W e b e g i n w i t h t h e d e n i t i o n o f a c e r t a i n t y p e o f   d o w n l o a d   ( ) o p e r a t i o n s e q u e n c e f o l l o w e d b y a c o u p l e o f k e y l e m m a s  

a b o u t s u c h s e q u e n c e s .  

D e n i t i o n 6 5   C o n s i d e r a s e q u e n c e o f   d  c o n s e c u t i v e   d o w n l o a d   (   ̀

) o p e r a t i o n s , w h e r e 0     i    d    1 a n d   d    1 , t h a t  

s a t i s f y t h e c o n d i t i o n s m e n t i o n e d i n L e m m a 6 6 a n d l e t    ̀ b e a s d e n e d i n L e m m a 6 6 . W e c a l l t h e a b o v e s e q u e n c e  

o f  d  d o w n l o a d   ( ) o p e r a t i o n s a n   ` ; d  - s e q u e n c e i f t h e r s t t i m e   M A M u l t i p l y   e i t h e r r e l i n q u i s h e s I / O o p e r a t i o n s ( i n  

S t e p 2 ( d ) i i a b o v e ) o r e x e c u t e s a n   l l m u l t  ( ) o p e r a t i o n a f t e r i t e x e c u t e s   d o w n l o a d   (   ̀

) i s o n l y i m m e d i a t e l y a f t e r i t  

e x e c u t e s   d o w n l o a d   (   ̀

d    1 

)

1 5 3 

Page 167: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 167/203

L e m m a 6 9   C o n s i d e r a n y   ` ; d  - s e q u e n c e d o w n l o a d   (   ̀

)  ; : : : ;  d o w n l o a d   (   ̀

d    1 

)  . I f , a t a n y t i m e a f t e r d o w n l o a d   (   ̀

)  b e g i n s  

a n d b e f o r e d o w n l o a d   (   ̀

d    1 

)  e n d s , M A M u l t i p l y i s s u b j e c t e d t o a n a l l o c a t i o n p h a s e o f s i z e   m 

s u c h t h a t l e v e l  (  m 

)   

` =  2 + 1  , t h e n t h e e x e c u t i o n o f d o w n l o a d   (   ̀

d    1 

)  i s i m m e d i a t e l y f o l l o w e d ( t h a t i s , w i t h o u t r e l i n q u i s h i n g a n y I / O s ) b y  

t h e e x e c u t i o n o f l l m u l t  (   ̀

)  , w h e r e    ̀

= m i n  f  l e v e l  (  m 

)  ;  m a x l e v e l   + 1  g 

P r o o f  : F r o m L e m m a 6 6 , w e k n o w t h a t t h e t o t a l n u m b e r o f I / O o p e r a t i o n s r e q u i r e d o v e r t h e e n t i r e   ` ; d  - s e q u e n c e i s  

n o m o r e t h a n   c 

d l 

  2 

 ̀   1 

. S u p p o s e t h a t a f t e r   d o w n l o a d   (   ̀

) b e g i n s e x e c u t i o n a n d b e f o r e   d o w n l o a d   (   ̀

d    1 

) c o m p l e t e s  

e x e c u t i o n ,   M A M u l t i p l y   g e t s a n a l l o c a t i o n p h a s e o f s i z e   m 

w h e r e   m 

i s a s d e n e d a b o v e . T h e n e v e n i f a l l t h e  

d l 

  2 

 ̀   1 

  c 

d l 

  4 

` =  2 

I / O o p e r a t i o n s i n c u r r e d d u r i n g t h e   ` ; d  - s e q u e n c e o c c u r r e d d u r i n g t h e p h a s e o f s i z e   m 

, t h a t  

a l l o c a t i o n p h a s e i s s t i l l l e f t w i t h   c 

l l m 

  4 

l e v e l  (  m 

)    1 

p e n d i n g I / O o p e r a t i o n s . H e n c e o n c o m p l e t i o n o f t h e   ` ; d  - s e q u e n c e ,  

e n o u g h   (  l e v e l  (  m 

) ) e v a l u a t e s t o t r u e : T h i s f o l l o w s f r o m t h e d e n i t i o n o f   c 

l e v e l  

a b o v e . F u r t h e r m o r e , b y d e n i t i o n o f  

` ; d  - s e q u e n c e , t h e   d  t h  d o w n l o a d   ( ) o p e r a t i o n   d o w n l o a d   (   ̀

d    1 

) o f t h e   ` ; d  - s e q u e n c e c a n n o t b e i m m e d i a t e l y f o l l o w e d  

b y a n o t h e r   d o w n l o a d   ( ) o p e r a t i o n s o   l l m u l t  (   ̀

) i s t h e n e x t o p e r a t i o n e x e c u t e d b y   M A M u l t i p l y   . T h u s t h e l e m m a i s  

p r o v e d .  

W e s t a t e n o w a s i m p l e c o r o l l a r y o f t h e a b o v e l e m m a .  

C o r o l l a r y 5   I f a n   ` ; d  - s e q u e n c e i s f o l l o w e d b y t h e e x e c u t i o n o f S t e p 2 ( d ) i i , t h e t o t a l n u m b e r o f I / O o p e r a t i o n s  

r e l i n q u i s h e d i s n o m o r e t h a n   O  ( 4 

l =  2 

C h a r g i n g S c h e m e f o r   d o w n l o a d   ( ) O p e r a t i o n s  

E a c h   ` ; d  - s e q u e n c e i n c u r s a c e r t a i n a m o u n t o f r e s o u r c e c o n s u m p t i o n . W e u s e t h e f o l l o w i n g c h a r g i n g s c h e m e t o a c c o u n t  

f o r t h e o f r e s o u r c e c o n s u m p t i o n o f   ` ; d  - s e q u e n c e s :  

1 . I n t h e e v e n t t h a t t h e   ` ; d  - s e q u e n c e i s f o l l o w e d b y   l l m u l t  (   ̀

) , w h e r e    ̀

> l =  2 , w e c h a r g e t h e r e s o u r c e c o n s u m p t i o n  

o f t h e   ` ; d  - s e q u e n c e t o t h e   l l m u l t   (   ̀

) o p e r a t i o n .  

2 . I n t h e e v e n t t h a t t h e   ` ; d  - s e q u e n c e i s f o l l o w e d b y t h e e x e c u t i o n o f S t e p 2 ( d ) i i o r b y t h e e x e c u t i o n o f a n   l l m u l t  (   ̀

o p e r a t i o n , w h e r e    ̀

  ` =  2 , w e a c c o u n t f o r i t s r e s o u r c e c o n s u m p t i o n u s i n g L e m m a 6 9 a n d C o r o l l a r y 5 .  

W e r s t c o u n t t h e m a x i m u m n u m b e r o f   ` ; d  - s e q u e n c e s t h a t c a n o c c u r d u r i n g   M A M u l t i p l y  

L e m m a 7 0   T h e t o t a l n u m b e r o f t i m e s a n   ` ; d  - s e q u e n c e c a n o c c u r d u r i n g t h e e n t i r e e x e c u t i o n o f M A M u l t i p l y i s  

 ̀

m a x 

   ̀

, w h e r e   1     ̀    ̀

m a x 

  1 

P r o o f  : T h i s f o l l o w s f r o m t h e f a c t t h a t e a c h t i m e   l r     ̀ + 1 ] i s s e t t o a n o n -  n i l  v a l u e , t h e m a x i m u m n u m b e r o f   ` ; d  - 

s e q u e n c e s t h a t c a n o c c u r b e f o r e   l r     ̀ + 1 ] b e c o m e s   n i l  i s 8 .  

1 5 4 

Page 168: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 168/203

W e w i l l n o w b o u n d t h e t o t a l r e s o u r c e c o n s u m p t i o n o f a l l   d o w n l o a d   ( ) o p e r a t i o n s , b a r r i n g t h o s e i n v o l v e d i n   ` ; d  - 

s e q u e n c e s w h o s e r e s o u r c e c o n s u m p t i o n i s c h a r g e d t o   l l m u l t   ( ) o p e r a t i o n s .  

T h e o r e m 2 1   S u p p o s e t h a t t h e r e s o u r c e c o n s u m p t i o n o f a n a n   ` ; d  - s e q u e n c e i s t h e r e s o u r c e c o n s u m p t i o n d u r i n g  

I / O o p e r a t i o n s i n c u r r e d d u r i n g t h e   ` ; d  - s e q u e n c e   a n d  t h e r e s o u r c e c o n s u m p t i o n c o r r e s p o n d i n g t o t h e I / O o p e r a t i o n s  

r e l i n q u i s h e d b y t h e ( p o s s i b l e ) e x e c u t i o n o f S t e p 2 ( d ) i i i m m e d i a t e l y f o l l o w i n g t h e   ` ; d  - s e q u e n c e . T h e t o t a l r e s o u r c e  

c o n s u m p t i o n o f a l l   ` ; d  - s e q u e n c e s , e x c e p t a n y   ` ; d  - s e q u e n c e w h o s e r e s o u r c e c o n s u m p t i o n w e c h a r g e i n S t e p 1 o f  

S e c t i o n 5 . 1 3 . 6 t o a n l l m u l t  (   ̀

)  o p e r a t i o n w i t h    ̀

> l =  2  , i s n o m o r e t h a n   O  (  ̂m 

3  =  2 

m a x 

P r o o f  : B y L e m m a 7 0 , t h e t o t a l n u m b e r o f  ` ; d  - s e q u e n c e s t h a t c a n o c c u r i s 8  

 ̀

m a x 

   ̀

. I n c l u d i n g t h e I / O o p e r a t i o n s t h a t  

a r e p o s s i b l y r e l i n q u i s h e d o n a c c o u n t o f e x e c u t i n g S t e p 2 ( d ) i i i m m e d i a t e l y a f t e r t h e   ` ; d  - s e q u e n c e , t h e t o t a l n u m b e r  

o f I / O o p e r a t i o n s c h a r g e d t o t h e   ` ; d  - s e q u e n c e i s n o m o r e t h a n   O  ( 4 

` =  2 

) , b y L e m m a 6 6 a n d C o r o l l a r y 5 . A l s o , b y  

L e m m a 6 9 , t h e m a x i m u m a l l o c a t i o n l e v e l d u r i n g a n y o f t h e s e   O  ( 4 

l =  2 

) I / O o p e r a t i o n s i s n o m o r e t h a n   ` =  2 , i m p l y i n g  

t h a t t h e m a x i m u m r e s o u r c e c o n s u m p t i o n o f e a c h   ` ; d  - s e q u e n c e r e l e v a n t t o t h i s t h e o r e m i s n o m o r e t h a n   O  ( ( 4 

` =  2 

3  =  2 

)

H e n c e t h e t o t a l a m o u n t o f r e s o u r c e c o n s u m p t i o n t h a t c a n b e c h a r g e d t o a l l   ` ; d  - s e q u e n c e s i s  

 ̀

m a x 

  1 

X   

l  = 1 

 ̀

m a x 

   ̀

  O 

 

 

 ̀

 

3  =  2 

 

=  O 

0  

@  

 ̀

m a x 

 ̀

m a x 

  1 

X   

l  = 1 

3  ` =  2 

=  2 

3   ̀

=  O 

0  

@  

 ̀

m a x 

 ̀

m a x 

  1 

X   

l  = 1 

1  =  2 

3  ` =  2 

=  O 

 

 ̀

m a x 

 

w h i c h i s   O  (  ̂m 

m a x 

) s i n c e 8  

 ̀

m a x 

= ( 4 

3  =  2 

 ̀

m a x 

= ( 4 

 ̀

m a x 

3  =  2 

=  ̂m 

3  =  2 

m a x 

R e s o u r c e C o n s u m p t i o n o f   l l m u l t   ( ) O p e r a t i o n s  

W e a r g u e h e r e t h a t t h e t o t a l a m o u n t o f r e s o u r c e c o n s u m p t i o n t h a t c a n b e c h a r g e d t o a n   l l m u l t   (   ̀ ) o p e r a t i o n i s n o  

m o r e t h a n   O 

 

( 4 

 ̀

3  =  2 

 

w h i l e t h e n u m b e r o f p e b b l i n g o p e r a t i o n s a c c o m p l i s h e d i s a t l e a s t  

 

( 4 

 ̀

B  ) 

3  =  2 

 

W e r s t h a v e t h e f o l l o w i n g l e m m a i m p l y i n g t h a t o u r r e o r g a n i z a t i o n o f t h e o p e r a t i o n  

 ̂

: = 

 ̂

 ̂

 ̂

, w h e r e e a c h  

o f 

 ̂

 ̂

;  a n d 

 ̂

a r e s u b m a t r i c e s c o n s i s t i n g o f 2  

 ̀

  2 

 ̀

b l o c k s , i n t o 8 s u b p r o d u c t o p e r a t i o n s  

 ̂

i ; j 

: = 

 ̂

i ; j 

 ̂

i ; k 

 ̂

j ; k 

c o r r e s p o n d i n g t o t h e 8 0     1 - t r i p l e s i s c o r r e c t .  

L e m m a 7 1   T h e m a t r i x o p e r a t i o n  

 ̂

+   

 ̂

 ̂

i s c o r r e c t l y i m p l e m e n t e d b y t h e   8  o p e r a t i o n s  

 ̂

i ; j 

: = 

 ̂

i ; j 

 ̂

i ; k 

 ̂

j ; k 

c o r r e s p o n d i n g t o t h e   8 (  i ; j ; k   ) 0    1  - t r i p l e s .  

1 5 5 

Page 169: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 169/203

I t c a n b e i n d u c t i v e l y p r o v e d t h a t t h e n u m b e r o f p e b b l i n g o p e r a t i o n s p e r f o r m e d b y   M A M u l t i p l y   u s i n g t h e a b o v e  

a p p r o a c h i s n o m o r e t h a n ( ^  m 

m a x 

B  ) 

3  =  2 

. W e c o n s i d e r n o w t h e m a x i m u m r e s o u r c e c o n s u m p t i o n t h a t c a n b e c h a r g e d  

t o a s i n g l e   l l m u l t   (   ̀ ) o p e r a t i o n .  

L e m m a 7 2   T h e m a x i m u m r e s o u r c e c o n s u m p t i o n t h a t c a n b e c h a r g e d t o a s i n g l e l l m u l t  (   ̀ )  o p e r a t i o n , w h e r e   1     ̀  

m a x l e v e l , i s   O 

 

( 4 

 ̀

3  =  2 

 

P r o o f  : B y L e m m a s 6 7 a n d 6 8 , t h e t o t a l n u m b e r o f I / O o p e r a t i o n s i n c u r r e d b y a n   l l m u l t  (   ̀ ) o p e r a t i o n i s   O  ( 4 

 ̀

) f o r  

a n y   ̀ , i n c l u d i n g    ̀ =  m a x l e v e l   + 1 . T h e t o t a l n u m b e r o f I / O o p e r a t i o n s p o s s i b l y r e l i n q u i s h e d o n a c c o u n t o f e x e c u t i n g  

S t e p 2 ( e ) i i i m m e d i a t e l y a f t e r t h e   l l m u l t  (   ̀ ) o p e r a t i o n i s   O  ( 4 

 ̀

) . I f 1      ̀   m a x l e v e l   t h e a l l o c a t i o n l e v e l t h r o u g h o u t  

t h e a b o v e I / O o p e r a t i o n s i s    ̀ s o t h a t t h e r e s o u r c e c o n s u m p t i o n i s   O 

 

( 4 

 ̀

3  =  2 

 

. O n t h e o t h e r h a n d , t h e t o t a l n u m b e r  

o f I / O o p e r a t i o n s i n c u r r e d b y t h e    ̀

; d  - s e q u e n c e , w h e r e    ̀

  2   ̀   2 , w h o s e r e s o u r c e c o n s u m p t i o n w e p o s s i b l y c h a r g e  

i n S t e p 1 o f S e c t i o n 5 . 1 3 . 6 t o   l l m u l t  (   ̀ ) i s n o m o r e t h a n   O  ( 4 

 ̀

) , b y L e m m a 6 6 . T h e m a x i m u m a l l o c a t i o n l e v e l d u r i n g  

t h e s e   O  ( 4 

 ̀

) I / O o p e r a t i o n s i s    ̀ , s o t h e i r r e s o u r c e c o n s u m p t i o n i s   O 

 

( 4 

 ̀

3  =  2 

 

. T h i s p r o v e s t h e l e m m a .  

W e n o w b o u n d t h e t o t a l r e s o u r c e c o n s u m p t i o n c h a r g e d t o a l l t h e   l l m u l t   ( ) o p e r a t i o n s i n c u r r e d d u r i n g   m a m u l t i p l y  

b y  O  (  ̂m 

3  =  2 

m a x 

)

T h e o r e m 2 2   T h e t o t a l r e s o u r c e c o n s u m p t i o n c h a r g e d t o a l l t h e l l m u l t  ( )  o p e r a t i o n s i n c u r r e d d u r i n g   m a m u l t i p l y  

b y  O  (  ̂m 

3  =  2 

m a x 

P r o o f  : F i r s t w e c o n s i d e r a l l   l l m u l t  (   ̀ ) o p e r a t i o n s w i t h   ` <  m a x l e v e l  + 1 . B y L e m m a 7 2 , w e k n o w t h a t e a c h   l l m u l t  (   ̀ ) 

o p e r a t i o n c a n b e c h a r g e d a r e s o u r c e c o n s u m p t i o n o f n o m o r e t h a n   O 

 

( 4 

 ̀

3  =  2 

 

. B y d e n i t i o n , e a c h   l l m u l t  (   ̀ ) o p e r a t i o n  

p e r f o r m s  

 

( 4 

 ̀

B  ) 

3  =  2 

 

p e b b l i n g o p e r a t i o n s . T h u s a t a n y t i m e d u r i n g   M A M u l t i p l y   ,  B 

3  =  2 

t i m e s t h e t o t a l r e s o u r c e  

c o n s u m p t i o n c h a r g e d t o   l l m u l t  ( ) o p e r a t i o n s u p t o t h a t p o i n t o f t i m e i s a l w a y s o f t h e o r d e r o f t h e t o t a l n u m b e r  

o f p e b b l i n g o p e r a t i o n s p e r f o r m e d b y   M A M u l t i p l y   u p t o t h a t p o i n t . S i n c e   M A M u l t i p l y   p e r f o r m s n o m o r e t h a n  

(  ̂m 

m a x 

B  ) 

3  =  2 

p e b b l i n g o p e r a t i o n s , t h e l e m m a h o l d s f o r a l l   l l m u l t  (   ̀ ) o p e r a t i o n s w i t h   ` <  m a x l e v e l   + 1 . T h e r e c a n  

b e a t m o s t o n e   l l m u l t  (   ̀ ) o p e r a t i o n s w i t h    ̀   m a x l e v e l   a n d s u c h a n o p e r a t i o n i n c u r s   O  (  ̂m 

m a x 

) I / O o p e r a t i o n s s o i t s  

r e s o u r c e c o n s u m p t i o n i s a l s o   O  (  ̂m 

3  =  2 

m a x 

) . T h i s p r o v e s t h e l e m m a .  

5 . 1 3 . 7 P r o v i n g O p t i m a l i t y  

T h e o r e m 2 1 a n d T h e o r e m 2 2 t o g e t h e r i m p l y t h e f o l l o w i n g l e m m a b o u n d i n g t h e t o t a l r e s o u r c e c o n s u m p t i o n o f  

M A M u l t i p l y  

1 5 6 

Page 170: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 170/203

T h e o r e m 2 3   T h e t o t a l r e s o u r c e c o n s u m p t i o n o f M A M u l t i p l y i s n o m o r e t h a n   O  (  ̂m 

3  =  2 

m a x 

S i n c e t h e t o t a l n u m b e r o f   M A M u l t i p l y   o p e r a t i o n s i n v o l v e d i s t h e s a m e a s t h e n u m b e r o f t i m e s S t e p 2 , w h i c h i s  

(  n =   ̂m 

m a x 

3  =  2 

, T h e o r e m 2 3 , C o r o l l a r y 2 a n d t h e d e n i t i o n o f d y n a m i c o p t i m a l i t y i m p l i e s t h e f o l l o w i n g t h e o r e m .  

T h e o r e m 2 4   T h e t o t a l a m o u n t o f r e s o u r c e c o n s u m p t i o n o f o u r m e m o r y - a d a p t i v e m a t r i x m u l t i p l i c a t i o n a l g o r i t h m  

w h e n u s e d t o m u l t i p l y t w o   n  b l o c k m a t r i c e s i s   O  (  n 

3  =  2 

)  . O u r m e m o r y - a d a p t i v e m a t r i x m u l t i p l i c a t i o n a l g o r i t h m i s  

d y n a m i c a l l y o p t i m a l .  

5 . 1 4 C o n c l u s i o n s a n d F u t u r e W o r k      

I n t h i s c h a p t e r w e h a v e p r e s e n t e d a s i m p l e a n d r e a s o n a b l e d y n a m i c m e m o r y a l l o c a t i o n m o d e l t h a t e n a b l e s d a t a b a s e  

a n d o p e r a t i n g s y s t e m s t o d y n a m i c a l l y c h a n g e t h e a m o u n t o f m e m o r y t h a t e x t e r n a l m e m o r y a l g o r i t h m s a r e a l l o c a t e d .  

W e h a v e d e n e d w h a t i t m e a n s f o r m e m o r y - a d a p t i v e e x t e r n a l m e m o r y a l g o r i t h m s d e s i g n e d t o w o r k i n t h i s m o d e l t o b e  

d y n a m i c a l l y o p t i m a l . W e h a v e p r e s e n t e d d y n a m i c a l l y o p t i m a l m e m o r y - a d a p t i v e a l g o r i t h m s f o r f u n d a m e n t a l p r o b l e m s  

s u c h a s s o r t i n g , p r o b l e m s r e l a t e d t o s o r t i n g , p e r m u t i n g , o t h e r p r o b l e m s r e l a t e d t o s o r t i n g a n d m a t r i x m u l t i p l i c a t i o n .  

W e h a v e a l s o p r e s e n t e d a d y n a m i c a l l y o p t i m a l ( i n a n a m o r t i z e d s e n s e ) v e r s i o n o f t h e b u e r t r e e , w h i c h h a s a l a r g e  

n u m b e r o f b a t c h e d d y n a m i c a p p l i c a t i o n s a n d a p p l i c a t i o n s s u c h a s \ b u l k - l o a d i n g " o f e x t e r n a l m e m o r y d a t a s t r u c t u r e s .  

W e h a v e s h o w n t h a t a p r e v i o u s l y d e v i s e d a p p r o a c h t o m e m o r y - a d a p t i v e e x t e r n a l m e r g e s o r t i s p r o v a b l y n o n o p t i m a l  

b e c a u s e o f f u n d a m e n t a l d r a w b a c k s . T h e l o w e r b o u n d p r o o f t e c h n i q u e s f o r s o r t i n g a n d m a t r i x m u l t i p l i c a t i o n a r e t h e  

t w o f u n d a m e n t a l l y d i s t i n c t p r o o f t e c h n i q u e s i n v o k e d b y m o s t o t h e r e x t e r n a l m e m o r y l o w e r b o u n d s a n d h e n c e w e  

a n t i c i p a t e t h a t t h e t e c h n i q u e s p r e s e n t e d h e r e w i l l a p p l y t o m a n y e x t e r n a l m e m o r y p r o b l e m s .  

I n t h e c a s e o f m e r g e s o r t i n g a n d m a t r i x m u l t i p l i c a t i o n , w e h a v e s h o w n h o w t o s e w t o g e t h e r a c o n v e n t i o n a l e x t e r n a l  

m e m o r y a l g o r i t h m w i t h a n a p p r o p r i a t e \ m e m o r y - a d a p t i v i t y " d a t a s t r u c t u r e t h a t b a l a n c e s w o r k a c r o s s \ l e v e l s o f  

a l l o c a t i o n " t o o b t a i n a m e m o r y - a d a p t i v e e x t e r n a l m e m o r y a l g o r i t h m . O u r p r o o f t e c h n i q u e s d e a l w i t h t h e i n t e r e s t i n g  

c o n s t r a i n t s f a c e d w h i l e p r o v i n g o p t i m a l i t y o f r e s o u r c e c o n s u m p t i o n i n o u r d y n a m i c m e m o r y m o d e l .  

W e b e l i e v e t h a t o u r t e c h n i q u e s f o r m e m o r y - a d a p t i v e m e r g i n g a p p l y t o m e m o r y - a d a p t i v e d i s t r i b u t i o n a n d t h u s t o  

a d y n a m i c a l l y o p t i m a l d i s t r i b u t i o n s o r t . S i n c e t h e   B a t c h M e r g e  

( ) o p e r a t i o n u s e d i n B K 9 8 ] c a n b e p e r f o r m e d u s i n g  

a m o d i c a t i o n o f o u r m e m o r y - a d a p t i v e m e r g i n g t e c h n i q u e , w e c o n j e c t u r e t h a t w e c a n d e s i g n a d y n a m i c a l l y o p t i m a l  

m e m o r y - a d a p t i v e v e r s i o n o f t h e w o r s t - c a s e o p t i m a l e x t e r n a l p r i o r i t y q u e u e o f B K 9 8 ] .  

W e h a v e m e n t i o n e d i n S e c t i o n 5 . 1 0 s o m e i n t e r e s t i n g o p e n q u e s t i o n s r e g a r d i n g d y n a m i c a l l y o p t i m a l m e m o r y -  

a d a p t i v e m e r g i n g . A n o t h e r i n t e r e s t i n g o p e n q u e s t i o n p e r t a i n s t o t h e m e m o r y - a d a p t i v e b u e r t r e e : I n c o n t r a s t t o  

t h e b u e r t r e e p r e s e n t e d i n S e c t i o n 5 . 1 2 w h i c h h a s r e l a t i v e l y h u g e b u e r s o f x e d s i z e   m 

m a x 

b l o c k s f o r e a c h n o d e ,  

i s i t p o s s i b l e t o d e s i g n a \ n e r g r a n u l a r i t y " b u e r t r e e w i t h \ m e m o r y - a d a p t i v e b u e r s i z e s " ? I t w o u l d b e f r u i t f u l t o  

e x t e n d o u r a p p r o a c h t o o t h e r d o m a i n s a n d a p p l i c a t i o n s . A n i n t e r e s t i n g q u e s t i o n i s w h e t h e r o r n o t w e c a n d e v i s e a  

1 5 7 

Page 171: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 171/203

g e n e r a l t e c h n i q u e t h a t t a k e s a n y e x t e r n a l m e m o r y a l g o r i t h m t h a t i s o p t i m a l f o r s t a t i c m e m o r y a n d c o n v e r t i t i n t o a  

d y n a m i c a l l y o p t i m a l m e m o r y - a d a p t i v e a l g o r i t h m .  

1 5 8 

Page 172: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 172/203

C h a p t e r 6      

M o d e l i n g a n d O p t i m i z i n g t h e I / O        

P e r f o r m a n c e o f M u l t i p l e D i s k s o n a S C S I    

B u s  

S u m m a r y      

F o r a w i d e v a r i e t y o f c o m p u t a t i o n a l t a s k s , d i s k I / O c o n t i n u e s t o b e a s e r i o u s o b s t a c l e t o h i g h p e r f o r m a n c e . T o m e e t  

d e m a n d i n g I / O r e q u i r e m e n t s , s y s t e m s a r e d e s i g n e d t o u s e m u l t i p l e d i s k d r i v e s t h a t s h a r e o n e o r m o r e I / O p o r t s t o f o r m  

a d i s k f a r m o r R A I D a r r a y . T h e f o c u s o f t h e p r e s e n t c h a p t e r i s o n s y s t e m s t h a t u s e m u l t i p l e d i s k s p e r S C S I b u s . W e  

m e a s u r e d t h e p e r f o r m a n c e o f c o n c u r r e n t r a n d o m I / O s f o r t h r e e t y p e s o f S C S I d i s k d r i v e s a n d t h r e e t y p e s o f c o m p u t e r s .  

T h e m e a s u r e m e n t s e n a b l e u s t o s t u d y b u s - r e l a t e d p h e n o m e n a t h a t i m p a i r p e r f o r m a n c e . W e d e s c r i b e t h e s e p h e n o m e n a ,  

a n d p r e s e n t a n e w I / O p e r f o r m a n c e m o d e l t h a t i n c o r p o r a t e s b u s e e c t s t o p r e d i c t t h e a v e r a g e t h r o u g h p u t a c h i e v e d  

b y c o n c u r r e n t r a n d o m I / O s t h a t s h a r e a S C S I b u s . T h i s m o d e l , a l t h o u g h r e l a t i v e l y s i m p l e , p r e d i c t s p e r f o r m a n c e  

o n t h e s e p l a t f o r m s t o w i t h i n 1 1 % f o r x e d I / O s i z e s i n t h e r a n g e 1 6 { 1 2 8 K B / s . W e t h e n d e s c r i b e a t e c h n i q u e t o  

i m p r o v e t h e I / O t h r o u g h p u t . T h i s t e c h n i q u e i n c r e a s e s t h e p e r c e n t a g e o f d i s k h e a d p o s i t i o n i n g t i m e t h a t i s o v e r l a p p e d  

w i t h d a t a t r a n s f e r s , a n d i n c r e a s e s t h e p e r c e n t a g e o f t r a n s f e r s t h a t o c c u r a t b u s b a n d w i d t h , r a t h e r t h a n a t d i s k - h e a d  

b a n d w i d t h . O u r t e c h n i q u e i s m o s t e e c t i v e f o r l a r g e I / O s a n d h i g h c o n c u r r e n c y | a n i m p o r t a n t p e r f o r m a n c e r e g i o n  

f o r l a r g e - s c a l e c o m p u t i n g | o u r i m p r o v e m e n t s a r e 1 0 { 2 0 % b e t t e r t h a n t h e n a i v e m e t h o d f o r r a n d o m w o r k l o a d s .  

6 . 1 I n t r o d u c t i o n      

A s a c o n s e q u e n c e o f t h e d i s p a r i t y i n i n t e r n a l m e m o r y a n d m a g n e t i c d i s k d r i v e a c c e s s p e r f o r m a n c e s , c o m p u t e r s y s t e m s  

t h a t p e r f o r m I / O - i n t e n s i v e p r o c e s s i n g a r e o f t e n d e s i g n e d t o u s e m a n y d i s k s i n p a r a l l e l , u s u a l l y o r g a n i z e d a s a d i s k  

f a r m o r a R A I D a r r a y . T h e p h y s i c a l o r g a n i z a t i o n g e n e r a l l y c o n s i s t s o f o n e o r m o r e I / O b u s e s ( e . g . , S C S I , F C , o r  

S S A ) w i t h s e v e r a l d i s k s o n e a c h b u s . V e r y o f t e n , i t i s c o n v e n i e n t t o u s e p a r a l l e l I / O s y s t e m s c o m p r i s i n g o n l y o f  

\ o - t h e - s h e l f " h a r d w a r e c o m p o n e n t s ( s a n s a n y s p e c i a l i z e d h a r d w a r e c o n t r o l l e r s e t c . ) b y a t t a c h i n g s e v e r a l d i s k s t o a  

S C S I b u s a n d t h e n p e r f o r m i n g p a r a l l e l I / O u s i n g s o f t w a r e s t r i p i n g , o r i n t h e a p p l i c a t i o n i t s e l f . S i n c e m o d e l i n g s u c h  

p a r a l l e l I / O s y s t e m s i s i n h e r e n t l y c o m p l e x , u n d e r s t a n d i n g , i n a q u a n t i t a t i v e m a n n e r , t h e p e r f o r m a n c e o f a p a r a l l e l  

I / O s y s t e m i s a s i g n i c a n t p r o b l e m t h a t m u s t b e o v e r c o m e b y s y s t e m d e s i g n e r s , a p p l i c a t i o n w r i t e r s a n d d e v e l o p e r s  

o f R A I D c o n t r o l l e r s .  

1 5 9 

Page 173: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 173/203

P r e v i o u s w o r k r e l a t e d t o d i s k I / O p e r f o r m a n c e h a s f o c u s e d o n t h e d i s k d r i v e a s t h e b o t t l e n e c k , d o w n p l a y i n g t h e  

i m p o r t a n c e o f b u s c o n t e n t i o n a n d o t h e r b u s e e c t s . I n d e e d , t h e b u s e e c t s p l a y a n i n s i g n i c a n t r o l e i n I / O p e r f o r m a n c e  

f o r U N I X w o r k l o a d s w i t h s m a l l I / O r e q u e s t s i z e s . B u t m a n y I / O - i n t e n s i v e a p p l i c a t i o n s b e n e t s i g n i c a n t l y f r o m l a r g e  

s i z e d r e q u e s t s . A m o n g t h e s e a r e m u l t i m e d i a s e r v e r s a n d c e r t a i n d a t a b a s e a n d s c i e n t i c c o m p u t i n g a p p l i c a t i o n s b a s e d  

u p o n E M a l g o r i t h m s t o p r o c e s s m a s s i v e d a t a s e t s ( e . g . , V S 9 4 , M N O  

9 8 , C H 9 6 ] ) . I n s u c h a p p l i c a t i o n s , p a r a l l e l I / O  

p e r f o r m a n c e i s o f t e n l i m i t e d b y b u s e e c t s , r a t h e r t h a n b y t h e p e r f o r m a n c e o f i n d i v i d u a l d i s k d r i v e s .  

I n t h i s c h a p t e r , o u r g o a l i s t o u n d e r s t a n d t h e I / O p e r f o r m a n c e o f a s y s t e m c o n s i s t i n g o f a S C S I b u s w i t h s e v e r a l d i s k  

d r i v e s a t t a c h e d t o t h a t b u s . T h e w o r k l o a d w e p r i m a r i l y f o c u s o n i s i n t e n d e d t o m o d e l t h e I / O w o r k l o a d c o r r e s p o n d i n g  

t o a p p l i c a t i o n s b a s e d u p o n p a r a l l e l d i s k a l g o r i t h m s a n d o t h e r s i m i l a r a p p l i c a t i o n s V S 9 4 , M N O  

9 8 , C H 9 6 ] . W e  

d e v e l o p a g e n e r a l a n a l y t i c m o d e l t o p r e d i c t t h e I / O p e r f o r m a n c e o f a p a r a l l e l d i s k s y s t e m , f o r s u c h w o r k l o a d s . S u c h  

a n u n d e r s t a n d i n g c o m p r i s e s a s t e p t o w a r d s t h e e l u s i v e g o a l o f b e i n g a b l e t o a c c u r a t e l y a n d g e n e r a l l y p r e d i c t t h e  

r u n n i n g t i m e o f a n E M a p p l i c a t i o n . B a s e d u p o n o u r u n d e r s t a n d i n g , w e a l s o d e s i g n a n d i m p l e m e n t a c l e v e r t e c h n i q u e  

t h a t c a n e x p l o i t f u t u r e a c c e s s i n f o r m a t i o n a n d f e a t u r e s o f m o d e r n d i s k d r i v e c o n t r o l l e r s t o s i g n i c a n t l y i m p r o v e t h e  

I / O p e r f o r m a n c e o f a p a r a l l e l d i s k s y s t e m , i n c e r t a i n s i t u a t i o n s . A p a t e n t a p p l i c a t i o n b a s e d u p o n t h e m o d e l i n g a n d  

p e r f o r m a n c e i m p r o v e m e n t a s p e c t s o f o u r w o r k i s c u r r e n t l y l e d .  

I n a p a r a l l e l I / O s y s t e m w i t h m u l t i p l e d i s k s o n a b u s , m a n y f a c t o r s i n u e n c e t h e t h r o u g h p u t . T h e f a c t o r s t h a t  

a r e u s u a l l y c o n s i d e r e d i n c l u d e t h e n u m b e r o f d i s k s , t h e s i z e o f e a c h I / O t r a n s f e r , a n d t h e p o s i t i o n i n g t i m e ( s e e k a n d  

r o t a t i o n a l l a t e n c y ) . W e a l s o a c c o u n t f o r t h e d i e r e n c e b e t w e e n t h e t r a n s f e r r a t e f r o m a d i s k p l a t t e r t h r o u g h t h e  

d i s k h e a d t o t h e d i s k ' s i n t e r n a l c a c h e ( t h a t i s , t h e   d i s k b a n d w i d t h   ) , a n d t h e ( s i g n i c a n t l y h i g h e r ) b u r s t r a t e f r o m a  

d i s k ' s c a c h e t o t h e h o s t o v e r t h e S C S I b u s ( t h a t i s , t h e   b u s b a n d w i d t h   ) . W e m o d e l t h e e e c t o f a d i s k d r i v e ' s r e a d  

l o o k a h e a d m e c h a n i s m , w h i c h s o m e t i m e s e n a b l e s t h e d i s k t o p r e f e t c h d a t a i n t o i t s i n t e r n a l c a c h e i n a n t i c i p a t i o n o f a  

f u t u r e s e q u e n t i a l r e a d r e q u e s t . W e a l s o c o n s i d e r t h e e e c t o f a r e l a t i v e l y o b s c u r e d i s k c o n t r o l p a r a m e t e r c a l l e d t h e  

f e n c e  

T h e f e n c e s e t t i n g c a n s i g n i c a n t l y i n u e n c e I / O p e r f o r m a n c e . B a s e d u p o n e x p e r i m e n t s a n d o b s e r v a t i o n s , w e  

f o u n d a n i n t e r e s t i n g c o n v o y - l i k e b e h a v i o r n o t r e p o r t e d i n l i t e r a t u r e , w h i c h w e c a l l   r o u n d s  , t h a t p l a y s a k e y r o l e i n  

d e t e r m i n i n g I / O p e r f o r m a n c e . W e p r e s e n t a n a d e s c r i p t i o n , a n a l y s i s a n d a n e x p l a n a t i o n f o r t h e r o u n d s i n S e c t i o n 6 . 6 .  

O u r p e r f o r m a n c e m o d e l d i e r s f r o m p r e v i o u s w o r k o n p a r a l l e l I / O p e r f o r m a n c e b e c a u s e o u r m o d e l i s b a s e d u p o n  

a q u a n t i t a t i v e s t u d y o f I / O b a n d w i d t h i n v o l v i n g b u s e e c t s , d i s k d r i v e m e c h a n i s m s a n d i m p o r t a n t p a r a m e t e r s n o t  

c o n s i d e r e d b y p r e v i o u s a p p r o a c h e s . F o r a w o r k l o a d c o n s i s t i n g o f r a n d o m , p a r a l l e l a c c e s s e s t o m u l t i p l e d i s k s o n a b u s ,  

w i t h z e r o \ t h i n k t i m e " b e t w e e n r e q u e s t s , w e q u a n t i t a t i v e l y m o d e l t h e s u s t a i n e d I / O . W e v a l i d a t e o u r m o d e l o n f o u r  

p a r a l l e l I / O s y s t e m s ( S u n U l t r a - 1 w i t h f o u r S e a g a t e C h e e t a h d i s k s , S u n S p a r c - 2 0 w i t h f o u r S e a g a t e C h e e t a h d i s k s ,  

S u n S p a r c - 2 0 w i t h s e v e n S e a g a t e W r e n - 7 d i s k s , a n d D E C A l p h a w i t h f o u r S e a g a t e B a r r a c u d a d i s k s ) .  

O u r m o d e l i n g a n d a n a l y s i s r e v e a l e d t h a t t h e I / O p e r f o r m a n c e o f t h e p a r a l l e l d i s k s y s t e m c a n v e r y o f t e n b e i m p r o v e d  

T h e f e n c e i s c a l l e d t h e   b u e r f u l l r a t i o   o n t h e S C S I - 2 d i s c o n n e c t / r e c o n n e c t c o n t r o l m o d e p a g e .  

1 6 0 

Page 174: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 174/203

Page 175: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 175/203

I n S e c t i o n 6 . 9 , w e d e s c r i b e a t e c h n i q u e t o i n c r e a s e I / O t h r o u g h p u t b y c a u s i n g d i s k s t o p r e f e t c h d a t a f r o m t h e  

d i s k s u r f a c e t o t h e i r i n t e r n a l c a c h e s ( t h u s o v e r l a p p i n g o n e d i s k ' s p o s i t i o n i n g t i m e w i t h o t h e r d i s k s ' b u s t r a n s f e r t i m e ) .  

T h i s t e c h n i q u e d i e r s f r o m p r e v i o u s t e c h n i q u e s t h a t p r e f e t c h f r o m d i s k t o m a i n m e m o r y d u r i n g s e q u e n t i a l a c c e s s  

w o r k l o a d s ( t h u s o v e r l a p p i n g I / O w i t h a p p l i c a t i o n t h i n k t i m e ) , b y u s i n g h i s t o r i c a l a c c e s s p a t t e r n s ( s e e T P G 9 7 ] f o r  

r e f e r e n c e s ) o r b y u s i n g a p p l i c a t i o n o r c o m p i l e r p r o v i d e d p r e d i c t i o n s o f f u t u r e a c c e s s e s C F L 9 4 b , K T P  

9 6 , M D K 9 6 ] .  

T P G 9 7 ] m e n t i o n s u s i n g a p p l i c a t i o n - p r o v i d e d k n o w l e d g e t o s c h e d u l e f u t u r e d i s k I / O t o r e d u c e a c c e s s l a t e n c y , b u t  

t h i s i d e a i s n o t d e v e l o p e d f u r t h e r . C F L 9 4 b ] p r e s e n t s r e s u l t s o n p r e f e t c h i n g i n t o m a i n m e m o r y b y s c h e d u l i n g m u l t i p l e  

p r e f e t c h c o m m a n d s f o r t w o d i s k s o n a S C S I b u s . T h e a b o v e p r e f e t c h i n g t e c h n i q u e s a t t e m p t t o h i d e d i s k l a t e n c y b y  

o v e r l a p p i n g I / O w i t h c o m p u t a t i o n w h e r e a s o u r t e c h n i q u e t r i e s t o o v e r l a p d i s k l a t e n c y w i t h b u s t r a n s f e r f r o m o t h e r  

d i s k s , s o o u r t e c h n i q u e o p e r a t e s a t a   n e r l e v e l o f g r a n u l a r i t y   a n d m a y e v e n b e u s e d i n a m a n n e r c o m p l e m e n t a r y t o  

t h e p r e f e t c h i n g t e c h n i q u e s a b o v e . C T 9 6 ] p r o p o s e s a n d s t u d i e s a s c h e d u l i n g a l g o r i t h m f o r a v i d e o s e r v e r a r c h i t e c t u r e  

c o n s i s t i n g o f m u l t i p l e d i s k s o n e a c h b u s . A   S C S I P R E F E T C H   c o m m a n d i s u s e d t o p r e f e t c h i n t o e a c h d i s k ' s i n t e r n a l  

c a c h e , p r i o r t o a r e a d o p e r a t i o n t h a t t r a n s f e r s t h e d a t a o n t h e b u s . A t o k e n - b a s e d r o u n d - r o b i n s c h e d u l i n g o f t h e s e  

r e a d s i s p r o p o s e d t o o v e r c o m e t h e p r o b l e m o f u n f a i r a r b i t r a t i o n i n t h e S C S I p r o t o c o l . C T 9 6 ] r e p o r t s o n l y s i m u l a t i o n  

r e s u l t s , w i t h n o v a l i d a t i o n o f w h e t h e r o r n o t t h e s i m u l a t o r a d e q u a t e l y c a p t u r e s t h e d i s k a n d b u s e e c t s o f r e a l  

s y s t e m s . M o r e o v e r , m a n y c u r r e n t d i s k d r i v e s ( i n c l u d i n g t h e S e a g a t e B a r r a c u d a a n d C h e e t a h ) d o n o t i m p l e m e n t t h e  

S C S I P R E F E T C H   c o m m a n d .  

6 . 3 W o r k l o a d      

O u r w o r k l o a d c o n s i s t s o f x e d - s i z e  

r e a d r e q u e s t s d i r e c t e d t o a c o l l e c t i o n o f i n d e p e n d e n t d i s k s t h a t s h a r e a S C S I b u s .  

T h e r e q u e s t s a r e g e n e r a t e d b y m u l t i p l e p r o c e s s e s o f e q u a l p r i o r i t y r u n n i n g c o n c u r r e n t l y o n a u n i p r o c e s s o r , o n e p r o c e s s  

p e r d i s k . E a c h p r o c e s s e x e c u t e s a t i g h t l o o p t h a t g e n e r a t e s a r a n d o m b l o c k a d d r e s s o n i t s d i s k , t a k e s a t i m e s t a m p ,  

i s s u e s a s e e k a n d a r e a d s y s t e m c a l l t o t h e r a w d i s k ( b y p a s s i n g t h e l e s y s t e m ) , a n d t a k e s a n o t h e r t i m e s t a m p w h e n  

t h e r e a d r e q u e s t c o m p l e t e s . E a c h e x p e r i m e n t c o n s i s t s o f t h r e e p h a s e s : a s t a r t u p p e r i o d d u r i n g w h i c h r e q u e s t s a r e  

i s s u e d b u t n o t t i m e d , a m e a s u r e m e n t p e r i o d d u r i n g w h i c h t h e t i m i n g s a r e a c c u m u l a t e d i n t a b l e s i n m a i n m e m o r y , a n d  

a c o o l d o w n p e r i o d d u r i n g w h i c h r e q u e s t s c o n t i n u e t o b e i s s u e d . T h e p u r p o s e o f t h e s t a r t u p a n d c o o l d o w n p e r i o d s  

i s t o e n s u r e t h a t t h e I / O s y s t e m i s u n d e r f u l l l o a d d u r i n g t h e m e a s u r e m e n t s . W e o b s e r v e d t h a t t h e I / O s y s t e m s  

p r o v i d e d f a i r n e s s i n a l l o u r e x p e r i m e n t s : e a c h d i s k c o m p l e t e d a p p r o x i m a t e l y t h e s a m e n u m b e r o f I / O s .  

T h i s w o r k l o a d c a p t u r e s t h e a c c e s s p a t t e r n s o f e x t e r n a l - m e m o r y a l g o r i t h m s d e s i g n e d f o r t h e P a r a l l e l D i s k M o d e l  

V S 9 4 ] . E x a m p l e s o f s u c h a l g o r i t h m s a r e p a r a l l e l d i s k s o r t i n g a l g o r i t h m s B G V 9 7 , C H 9 6 ] a n d p a r a l l e l d i s k m a t r i x  

m u l t i p l i c a t i o n V S 9 4 ] . I n P a r a l l e l D i s k M o d e l a l g o r i t h m s , r e a d s a n d w r i t e s a r e c o n c u r r e n t r e q u e s t s t o a s e t o f d i s k s ,  

I n a r e c e n t e x t e n s i o n t o t h i s w o r k , w e h a v e a l s o i n c o r p o r a t e d r e q u e s t s v a r i a b l e - s i z e d b l o c k s ;  

e s s e n t i a l l y t h e s a m e m o d e l w o r k s , w i t h t h e d i e r e n c e t h a t w e h a v e t o u s e t h e a v e r a g e b l o c k s i z e  

i n s t e a d o f a n y x e d s i z e .  

1 6 2 

Page 176: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 176/203

i s s u e d i n l o c k - s t e p , o n e r e q u e s t p e r d i s k . O u r w o r k l o a d a l s o m o d e l s a p p l i c a t i o n s t h a t u s e b a l a n c e d   c o l l e c t i v e I / O   , 

i . e . , w h e r e a l l p r o c e s s e s m a k e a s i n g l e j o i n t I / O r e q u e s t r a t h e r t h a n n u m e r o u s i n d e p e n d e n t r e q u e s t s . T h i s w o r k l o a d  

a l s o c a n b e u s e d t o m o d e l a v i d e o - o n - d e m a n d s e r v e r w h e n t h e d a t a i s s t r i p e d a c r o s s m u l t i p l e d i s k s .  

6 . 4 H a r d w a r e C o n g u r a t i o n      

W e t o o k m e a s u r e m e n t s o n f o u r h a r d w a r e c o n g u r a t i o n s . T h e r s t c o n s i s t s o f f o u r S e a g a t e C h e e t a h S T - 3 4 5 0 1 W d i s k s  

c o n n e c t e d t o a S u n U l t r a - 1 c o m p u t e r r u n n i n g S o l a r i s 2 . 5 . 1 . A l t h o u g h t h i s C h e e t a h h a s a n u l t r a - w i d e S C S I i n t e r f a c e  

c a p a b l e o f a 4 0 M B / s m a x i m u m b u s r a t e , t h e c o n t r o l l e r c a r d i n t h e c o m p u t e r i s a f a s t - w i d e c a r d t h a t c a n n o t e x c e e d  

2 0 M B / s . T h e s e c o n d c o n g u r a t i o n i s f o u r S e a g a t e C h e e t a h ( S T - 3 4 5 0 1 W ) d i s k s c o n n e c t e d t o a S u n S p a r c - 2 0 r u n n i n g  

S o l a r i s 2 . 5 , a g a i n w i t h t h e 2 0 M B / s c o n t r o l l e r . T h e t h i r d c o n g u r a t i o n i s f o u r S e a g a t e B a r r a c u d a ( S T - 3 2 1 7 1 W )  

d i s k s c o n n e c t e d t o a D E C A l p h a S t a t i o n 6 0 0 5 / 2 6 6 r u n n i n g D i g i t a l U N I X 4 . 0 . T h e f o u r t h c o n g u r a t i o n u s e s s e v e n  

I m p r i m i s ( S e a g a t e ) W r e n - 7 ( 9 4 6 0 1 - 1 5 ) d i s k s ( 5 M B / s S C S I - 1 ) o n a S u n S p a r c 2 0 r u n n i n g S o l a r i s 2 . 5 . T a b l e 6 . 1  

p r e s e n t s a d d i t i o n a l p a r a m e t e r s o f t h e d i s k s w e u s e d C o r 8 9 , T e c 9 7 b , T e c 9 7 a ] .  

E a c h d i s k h a s a u n i q u e S C S I i d w h i c h d e t e r m i n e s t h e p r i o r i t y o f t h e d i s k w h e n m u l t i p l e d e v i c e s a r e c o n t e n d i n g  

f o r u s e o f t h e i d l e S C S I b u s . T h e S C S I c o n t r o l l e r a t t h e h o s t h a s t h e h i g h e s t p r i o r i t y , s o i t w i l l w i n a n y c o n t e n t i o n  

i n w h i c h i t p a r t i c i p a t e s .  

W h e n t h e W r e n i s t r a n s f e r r i n g d a t a f r o m t h e d i s k s u r f a c e t o t h e h o s t ( t h r o u g h t h e c a c h e ) , i t d i s c o n n e c t s f r o m  

t h e b u s w h e n i t r e a c h e s a t r a c k b o u n d a r y . W h e n t h e W r e n i s p e r f o r m i n g r e a d a h e a d i n t o t h e d i s k c a c h e , r e a d a h e a d  

s t o p s w h e n a c y l i n d e r b o u n d a r y i s r e a c h e d . I n t h e m o r e m o d e r n B a r r a c u d a s a n d C h e e t a h s , r e a d a h e a d c a n c o n t i n u e  

a c r o s s a c y l i n d e r b o u n d a r y , a l t h o u g h t h e s e d i s k s m u s t d e t e c t a s e q u e n t i a l a c c e s s p a t t e r n b e f o r e t h e y w i l l c o m m e n c e  

r e a d a h e a d .  

6 . 4 . 1 T h e F e n c e P a r a m e t e r  

A s m e n t i o n e d e a r l i e r , t h e t i m e a t w h i c h t h e d i s k c o n t e n d s f o r r e c o n n e c t i o n t o t h e b u s d e p e n d s u p o n t h e   f e n c e  

p a r a m e t e r . W h e n a S C S I d i s k i s i n s t r u c t e d t o p e r f o r m a r e a d , a n d t h e d i s k r e c o g n i z e s t h a t t h e r e w i l l b e a s i g n i c a n t  

d e l a y , s u c h a s f o r a s e e k , t h e d i s k r e l e a s e s c o n t r o l o f t h e S C S I b u s ( i t   d i s c o n n e c t s  ) . W h e n t h e d i s k i s r e a d y t o t r a n s f e r  

t h e d a t a t o t h e h o s t , t h e d i s k c o n t e n d s f o r c o n t r o l o f t h e S C S I b u s (  r e c o n n e c t  ) s o t h a t t h e r e a d c a n b e c o m p l e t e d .  

T h e f e n c e d e t e r m i n e s t h e t i m e a t w h i c h t h e d i s k w i l l b e g i n t o c o n t e n d f o r t h e S C S I b u s . I f t h e f e n c e i s s e t t o t h e  

m i n i m u m v a l u e , t h e d i s k w i l l c o n t e n d a f t e r t h e r s t s e c t o r o f d a t a h a s b e e n t r a n s f e r r e d f r o m t h e d i s k s u r f a c e t o t h e  

d i s k ' s i n t e r n a l c a c h e . B y c o n t r a s t , i f t h e f e n c e i s s e t t o t h e m a x i m u m v a l u e , t h e d i s k w i l l w a i t  

u n t i l a l m o s t a l l o f t h e  

A s d i s c u s s e d i n S e c t i o n 6 . 4 a n d S e c t i o n 6 . 7 . 3 , d i s k s r e a c h i n g t r a c k o r c y l i n d e r b o u n d a r i e s o n t h e  

d i s k s u r f a c e m a y a l s o d i s c o n n e c t , a n d l a t e r r e c o n n e c t , d u r i n g d a t a t r a n s f e r .  

A c t u a l l y , t h e b e h a v i o r o f t h e d i s k i s a l i t t l e m o r e c o m p l i c a t e d t h a n s t a t e d h e r e ; a p r e c i s e s p e c i -  

c a t i o n i s g e n e r a l l y a v a i l a b l e f r o m t h e p r o d u c t m a n u a l .  

1 6 3 

Page 177: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 177/203

T a b l e 6 . 1  : D i s k p a r a m e t e r s  

p a r a m e t e r C h e e t a h B a r r a c u d a W r e n  

m a x i m u m d i s k q u e u e l e n g t h 6 4 6 4 1  

a v e r a g e s e e k l a t e n c y 7 . 7 m s 9 . 4 m s 1 5 m s  

r o t a t i o n a l s p e e d ( r e v o l u t i o n s p e r m i n u t e ) 1 0 0 3 3 7 2 0 0 3 5 9 7  

a v e r a g e s e c t o r s p e r t r a c k 1 7 0 1 6 3 7 0  

s e c t o r s i z e 5 1 2 b y t e s 5 1 2 b y t e s 5 1 2 b y t e s  

n u m b e r o f d a t a s u r f a c e s 8 5 1 5  

d i s k b u e r s i z e 5 1 2 K B 5 1 2 K B 2 4 0 K B  

n u m b e r o f b u e r s e g m e n t s 1 { 1 5 1 { 1 5 1  

r e q u e s t e d d a t a h a s a c c u m u l a t e d i n t h e d i s k c a c h e b e f o r e c o n t e n d i n g f o r t h e b u s . T h e p e r f o r m a n c e i m p l i c a t i o n i s a s  

f o l l o w s . A l o w f e n c e s e t t i n g t e n d s t o r e d u c e t h e r e s p o n s e t i m e , b e c a u s e t h e d i s k a t t e m p t s t o s e n d d a t a t o t h e h o s t a s  

s o o n a s t h e r s t s e c t o r i s a v a i l a b l e . B u t w h e n t h e c a c h e d d a t a h a s b e e n s e n t t o t h e h o s t ( a t t h e f u l l b u s b a n d w i d t h ) ,  

t h e d i s k c o n t i n u e s t o h o l d t h e b u s . T h e r e m a i n d e r o f t h e t r a n s f e r o c c u r s a t t h e d i s k h e a d b a n d w i d t h | t h e r a t e a t  

w h i c h b i t s p a s s u n d e r t h e d i s k h e a d . T h e d i s k h e a d b a n d w i d t h i s u s u a l l y l e s s t h a n 2 5 % o f t h e b u s b a n d w i d t h , a n d  

f o r s o m e d i s k s , f a r l e s s . A h i g h f e n c e s e t t i n g c a u s e s t h e d i s k t o d e l a y t h e s t a r t o f d a t a t r a n s f e r t o t h e h o s t , b u t w h e n  

t h e t r a n s f e r d o e s o c c u r , i t p r o c e e d s a t \ b u s b a n d w i d t h " , f r o m s e m i c o n d u c t o r c a c h e o n t h e d i s k d r i v e i n t o t h e h o s t  

c o n t r o l l e r a n d m e m o r y s y s t e m . I n s y s t e m s w i t h m u l t i p l e d i s k s o n a b u s , a h i g h f e n c e s e t t i n g p o t e n t i a l l y i n c r e a s e s  

o v e r a l l t h r o u g h p u t f o r I / O i n t e n s i v e w o r k l o a d s .  

I f t h e f e n c e v a l u e  

i s 0 , t h e d i s k c o n t e n d s f o r t h e b u s a s s o o n a s o n e s e c t o r h a s b e e n r e a d i n t o t h e c a c h e . I f t h e  

f e n c e v a l u e i s 2 5 5 / 2 5 6 , t h e d i s k w a i t s u n t i l 2 5 5 / 2 5 6 o f t h e r e q u e s t e d n u m b e r o f s e c t o r s a r e i n t h e c a c h e , o r u n t i l t h e  

c a c h e b e c o m e s f u l l .  

6 . 5 C o m p o n e n t s O f S e r v i c e T i m e      

T h e s i g n i c a n t c o m p o n e n t s o f t h e t i m e t o c o m p l e t e a r e a d o p e r a t i o n a r e a s f o l l o w s .  

H o s t q u e u e t i m e :   t h e t i m e d u r i n g w h i c h a r e q u e s t r e m a i n s q u e u e d u p i n t h e d e v i c e d r i v e r o r t h e h o s t S C S I c o n t r o l l e r ,  

w h i c h d e p e n d s u p o n t h e p a r t i c u l a r s t r a t e g y e m p l o y e d i n t h o s e c o m p o n e n t s o f t h e s y s t e m .  

S C S I o v e r h e a d :   t h e t i m e f o r t h e S C S I p r o t o c o l t o s e n d a r e q u e s t f r o m t h e d e v i c e d r i v e r t o t h e d i s k , d e n o t e d a s  

O v e r h e a d   i n t h e e q u a t i o n s o f S e c t i o n 6 . 7 . 2 a n d 6 . 7 . 3 .  

D e v i c e q u e u e t i m e :   t h e t i m e t h a t a r e q u e s t w a i t s i n t h e d i s k c o n t r o l l e r w h i l e t h e c o n t r o l l e r i s s e r v i n g s o m e p r e v i o u s  

r e q u e s t . T h i s t i m e i s z e r o f o r a d r i v e t h a t c a n o n l y h a n d l e o n e r e q u e s t a t a t i m e .  

S e e k t i m e :   t h e t i m e r e q u i r e d b y t h e d i s k h e a d t o m o v e t o t h e t r a c k c o n t a i n i n g a r e q u e s t e d b l o c k a d d r e s s . S e e k t i m e  

h a s a n o n - l i n e a r d e p e n d e n c y u p o n t h e n u m b e r o f t r a c k s t o b e t r a v e r s e d .  

I n t h i s c h a p t e r , w e r e p o r t o n l y f o r t h e f e n c e s e t t o z e r o o r t h e f e n c e s e t t o 2 5 5  =  2 5 6 c a s e ; i n a  

r e c e n t e x t e n s i o n , w e h a v e i n c o r p o r a t e d o t h e r f e n c e v a l u e s i n o u r m o d e l .  

1 6 4 

Page 178: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 178/203

R o t a t i o n a l l a t e n c y t i m e :   a f t e r a s e e k c o m p l e t e s , t h e t i m e d u r i n g w h i c h t h e d i s k r o t a t e s t o b r i n g t h e r e q u e s t e d b l o c k  

t o t h e d i s k h e a d .  

R o t a t i o n a l t r a n s f e r t i m e :   a f t e r t h e r o t a t i o n a l l a t e n c y c o m p l e t e s , t h e t i m e r e q u i r e d f o r t h e h e a d t o t r a n s f e r d a t a  

f r o m t h e d i s k s u r f a c e t o t h e d i s k b u e r . T h i s t i m e i s l a r g e l y g o v e r n e d b y t h e s p e e d o f r o t a t i o n a n d t h e n u m b e r  

o f b y t e s p e r t r a c k . T h i s t i m e i s p r o p o r t i o n a l t o t h e n u m b e r o f b y t e s t r a n s f e r r e d , a n d i n c l u d e s a n y a d d i t i o n a l  

t i m e r e q u i r e d f o r t r a c k s w i t c h e s a n d c y l i n d e r s w i t c h e s w h e n a n I / O e x t e n d s a c r o s s m u l t i p l e t r a c k s o r c y l i n d e r s ,  

B u s b u s y t i m e :   t h e t i m e p e r i o d d u r i n g w h i c h a r e q u e s t e d b l o c k s i t s i n t h e d i s k ' s b u e r , w a i t i n g f o r t h e S C S I b u s t o  

b e c o m e a v a i l a b l e f o r a t r a n s f e r t o t h e h o s t .  

B u s t r a n s f e r t i m e :   t h e t i m e r e q u i r e d t o t r a n s m i t t h e b l o c k o v e r t h e S C S I b u s , a t t h e s u s t a i n e d b u s b a n d w i d t h , f r o m  

t h e d i s k t o t h e h o s t . I t i s p r o p o r t i o n a l t o t h e s i z e o f t h e b l o c k t o b e t r a n s f e r r e d .  

T h e s e r v i c e t i m e f o r a d i s k r e q u e s t i s n o t t h e s i m p l e s u m o f t h e s e c o m p o n e n t s . F o r i n s t a n c e , i f t h e f e n c e i s 0 ,  

s o m e o f t h e r o t a t i o n a l t r a n s f e r t i m e m a y b e o v e r l a p p e d w i t h t h e b u s t r a n s f e r t i m e . I f m a n y d i s k s s h a r e a b u s , t h e  

o v e r l a p p e d I / O t r a n s f e r s m a y c a u s e t h e b u s b u s y t i m e t o d o m i n a t e , l e a d i n g t o s e r v i c e t i m e s m u c h l a r g e r t h a n t h e  

b u s t r a n s f e r t i m e . I f t h e I / O r e q u e s t s a r e s m a l l , t h e n t h e S C S I o v e r h e a d m a y d o m i n a t e , i n w h i c h c a s e t h e e e c t i v e  

d a t a r a t e o n t h e b u s c a n n o t a p p r o a c h t h e b u s b a n d w i d t h , e v e n i f m a n y d i s k s s h a r e t h e b u s .  

O u r e x p e r i m e n t s h a v e a t m o s t o n e o u t s t a n d i n g r e q u e s t p e r d i s k , s o b o t h t h e h o s t q u e u e t i m e a n d t h e d e v i c e q u e u e  

t i m e a r e z e r o .  

6 . 6 R o u n d s    

I n o u r e x p e r i m e n t s , w e o b s e r v e d f a i r n e s s i n t h e s e r v i c i n g o f s u c i e n t l y l a r g e I / O r e q u e s t s , d e s p i t e t h e f a c t t h a t t h e  

S C S I d i s k s h a v e d i e r e n t p r i o r i t i e s w h e n c o n t e n d i n g f o r t h e b u s . A l t h o u g h e a c h p r o c e s s a t t e m p t s t o p r o g r e s s t h r o u g h  

i t s r e q u e s t s a s f a s t a s p o s s i b l e , w i t h o u t c o o r d i n a t i n g w i t h o t h e r p r o c e s s e s , w e t y p i c a l l y o b s e r v e a c o n v o y b e h a v i o r  

a m o n g t h e r e q u e s t s b y   a l l  t h e p r o c e s s e s . N a m e l y , a l l d i s k s r e c e i v e a r e q u e s t , t h e n a l l d i s k s t r a n s m i t d a t a b a c k t o t h e  

h o s t b e f o r e a n y d i s k r e c e i v e s a n o t h e r r e q u e s t . W e u s e t h e t e r m   r o u n d s   f o r t h i s p e r i o d i c c o n v o y b e h a v i o r .  

W e w e r e s u r p r i s e d t o s e e r o u n d s . S i n c e t h e h o s t h a s t h e h i g h e s t S C S I p r i o r i t y , o n e w o u l d e x p e c t t h a t s o o n a f t e r  

a d i s k c o m p l e t e s o n e r e q u e s t , t h e h o s t w o u l d s e i z e t h e b u s t o s e n d a n o t h e r r e q u e s t t o t h a t d i s k , t h e r e b y k e e p i n g t h e  

b u s a n d a l l t h e d i s k s b u s y .  

W e o b s e r v e d r o u n d s o n a v a r i e t y  

o f h a r d w a r e a r c h i t e c t u r e s ( S u n , D E C , I n t e l - P C ) a n d S C S I c o n t r o l l e r s , r u n n i n g  

s e v e r a l d i e r e n t v e r s i o n s o f U N I X s u c h a s S o l a r i s , U l t r i x , a n d N e t - B S D . I n a r e c e n t d e v e l o p m e n t , b y i n s t r u m e n t i n g  

R e c e n t l y o u r e x p e r i m e n t w a s r e p l i c a t e d N i e 9 8 ] o n a 2 6 - C P U S u n E 6 0 0 0 w i t h S e a g a t e C h e e t a h  

( S T - 1 9 1 7 1 F C ) F i b r e C h a n n e l d i s k s . U s i n g o n e C P U t o s e n d r e q u e s t s t o f o u r d i s k s o n o n e F i b r e  

C h a n n e l l o o p , i t w a s o b s e r v e d t h a t t h e r e w a s r o u n d - l i k e b e h a v i o r f o r r e q u e s t s i z e s 1 6 - 2 0 0 K B .  

1 6 5 

Page 179: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 179/203

t h e N e t B S D k e r n e l , w e d e t e r m i n e d t h a t t h e o p e r a t i n g s y s t e m d o e s n o t q u e u e r e q u e s t s b e f o r e s e n d i n g t h e m t o t h e h o s t  

b u s a d a p t e r . W h e n a n A n c o t S C S I b u s a n a l y z e r w a s u s e d t o d e t e r m i n e w h e t h e r t h e h o s t b u s a d a p t e r a r b i t r a t e s f o r  

t h e b u s w h e n i t h a s a d i s k r e q u e s t i t w a s f o u n d t h a t i t d o e s n o t : I f a n y d i s k w a n t s t h e b u s , t h e h o s t b u s a d a p t e r w i l l  

n o t a r b i t r a t e f o r t h e b u s , e v e n i f i t i s w a i t i n g t o s e n d a r e q u e s t t o a n i d l e d i s k . T h e h o s t b u s a d a p t e r o n l y a r b i t r a t e s  

f o r t h e b u s i f n o d i s k i s a r b i t r a t i n g .  

S i n c e u s i n g t h e S C S I b u s a n a l y z e r i s t i m e - i n t e n s i v e a n d s i n c e w e d i d n o t o r i g i n a l l y h a v e e a s y a c c e s s t o a S C S I  

a n a l y z e r , w e r s t d e t e r m i n e d w h e n r o u n d s h a p p e n u s i n g a p p l i c a t i o n - l e v e l t i m e s t a m p s . T o d e t e r m i n e w h e t h e r   D 

d i s k s a r e b e i n g s e r v e d i n r o u n d s u n d e r s o m e w o r k l o a d , w e e x a m i n e t h e o r d e r e d I / O c o m p l e t i o n t i m e s t a m p s f r o m a  

1 0 s e c o n d r u n ( a f t e r a s t a r t u p i n t e r v a l ) u s i n g a s l i d i n g w i n d o w o f s i z e   D  . A d e t a i l e d d e s c r i p t i o n o f o u r t i m e s t a m p  

a n a l y s i s a l g o r i t h m s t h a t r e v e a l t h e r o u n d - l i k e b e h a v i o r o f t h e I / O c a n b e f o u n d i n B G H  

9 8 ] : H e r e w e s k e t c h o u r  

t e c h n i q u e . A v i o l a t i o n o f r o u n d o r d e r i n g i s s a i d t o o c c u r o n t h e   j  t h t i m e s t a m p i n t h e w i n d o w ( w h e r e 0     j    D    1 ) i f  

t h e r e i s a n   i < j  s u c h t h a t t h e   i  t h a n d   j  t h I / O o f t h e w i n d o w b o t h o r i g i n a t e f r o m t h e s a m e d i s k : i f t h e c u r r e n t s l i d i n g  

w i n d o w c o n t a i n s a v i o l a t i o n a t t h e   j  t h p o s i t i o n , t h e w i n d o w i s a d v a n c e d b y   j  p o s i t i o n s . O t h e r w i s e i t i s a d v a n c e d  

b y  D  p o s i t i o n s . T h e f r a c t i o n o f I / O o p e r a t i o n s t h a t d o n o t v i o l a t e r o u n d o r d e r i n g i s o u r m e a s u r e o f t h e e x t e n t o f  

r o u n d f o r m a t i o n f o r t h a t e x p e r i m e n t . I n o u r e x p e r i m e n t s , r o u n d s o c c u r r e d 8 8 { 9 9 % o f t h e t i m e f o r u n i f o r m r a n d o m  

w o r k l o a d s c o n t a i n i n g a m i x t u r e o f 1 , 2 , 3 , o r 4 d i e r e n t r e q u e s t s i z e s a n d f o r w o r k l o a d s t h a t h a v e s p a t i a l l o c a l i t y .  

T h e w o r k l o a d s t h a t w e e x p e r i m e n t e d w i t h h a v e r e q u e s t s i z e s o f   B ; : : : i B   , f o r   i  t h e n u m b e r o f r e q u e s t s i z e s i n t h e  

w o r k l o a d a n d f o r   B  = 8  ;  1 6  ;  3 2  ;  6 4  ;  o r 1 2 8 K B s .  

T h e W r e n d i s k s e x h i b i t r o u n d s f o r r e q u e s t s o f s i z e 8 K B o r l a r g e r ; m o r e d e t a i l s c a n b e f o u n d i n B G H  

9 8 ] . T h e  

B a r r a c u d a s a n d C h e e t a h s e x h i b i t r o u n d s w i t h r e q u e s t s o f s i z e 1 6 K B o r l a r g e r . I f t h e r e q u e s t s i z e i s v e r y s m a l l , w e  

d o n o t o b s e r v e r o u n d s . I n t h i s c a s e , t h e b u s i s n o t a b o t t l e n e c k , b u t t h e r a n d o m s e e k s a n d r o t a t i o n a l l a t e n c i e s c a u s e  

r e a s o n a b l y f a i r w o r k l o a d s o n t h e d i s k s .  

T h e c u r r e n t l i t e r a t u r e d o e s n o t d i s c u s s r o u n d s a s w e o b s e r v e d t h e m . I n f a c t , S T V 9 6 ] s t a t e s t h a t e v e n i n c a s e s w h e n  

t h e l o a d i s s y m m e t r i c a l l y d i s t r i b u t e d a n d b a l a n c e d , o n e p r o c e s s c a n m o n o p o l i z e t h e d i s k s w h i l e a l l o t h e r p r o c e s s e s  

c o m e t o a h a l t .  

6 . 7 A n a l y t i c a l M o d e l    

I n t h i s s e c t i o n , w e d e v e l o p a d i s k m o d e l f o r o n e o r m o r e d i s k s t h a t s h a r e a S C S I b u s . F o r t h e w o r k l o a d d e s c r i b e d  

a b o v e , o u r m o d e l p r e d i c t s t h e a v e r a g e t i m e t o c o m p l e t e a r e a d r e q u e s t , a s a f u n c t i o n o f t h e n u m b e r o f d i s k s s h a r i n g  

t h e b u s , t h e r e q u e s t s i z e i n b y t e s , t h e s e t t i n g o f t h e f e n c e p a r a m e t e r ( 0 o r 2 5 5 / 2 5 6 ) , a n d a c o l l e c t i o n o f p e r f o r m a n c e  

p a r a m e t e r s f o r i n d i v i d u a l d i s k s a n d t h e S C S I b u s . W e n o t e t h a t t h e s e t w o f e n c e s e t t i n g s e m p h a s i z e r e s p o n s e t i m e  

a n d b a n d w i d t h , r e s p e c t i v e l y .  

I n S e c t i o n 6 . 7 . 1 , w e r s t d e n e a r e a d d u r a t i o n , t h e q u a n t i t y w h o s e a v e r a g e v a l u e o u r m o d e l a c t u a l l y p r e d i c t s .  

T h e a v e r a g e r e a d d u r a t i o n i s i n h e r e n t l y r e l a t e d t o t h e p a r a l l e l I / O t h r o u g h p u t b e i n g d e l i v e r e d b y t h e I / O s y s t e m . I n  

1 6 6 

Page 180: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 180/203

S e c t i o n 6 . 7 . 2 , w e p r e s e n t a m o d e l t o p r e d i c t a v e r a g e r e a d d u r a t i o n o n a s i n g l e d i s k s y s t e m a n d i n S e c t i o n 6 . 7 . 3 , w e  

p r e s e n t a m o d e l t o p r e d i c t a v e r a g e r e a d d u r a t i o n o n a s i n g l e d i s k s y s t e m .  

6 . 7 . 1 R e a d d u r a t i o n  

T h e w o r k l o a d e x p e r i m e n t s d e s c r i b e d i n S e c t i o n 6 . 3 c o l l e c t t i m e s t a m p s i m m e d i a t e l y b e f o r e a r e a d c a l l i s m a d e a n d  

i m m e d i a t e l y a f t e r t h e r e a d c a l l r e t u r n s .  

W e u s e t h e t e r m   r e a d d u r a t i o n   f o r t h e t i m e p e r i o d b e t w e e n s u c h a p a i r o f  

t i m e s t a m p s .  

T h e a v e r a g e r e a d d u r a t i o n i s c l o s e l y r e l a t e d t o t h e t h r o u g h p u t a t w h i c h d a t a b l o c k s a r e b e i n g r e t r i e v e d b y t h e  

p a r a l l e l I / O s y s t e m . F o r w o r k l o a d s t h a t h a v e z e r o t h i n k - t i m e b e t w e e n r e q u e s t s f o r b l o c k s o f s i z e   B  b y t e s , r e t r i e v e d  

i n p a r a l l e l f r o m   D  d i s k s , t h e a v e r a g e t h r o u g h p u t i n b y t e s p e r s e c o n d i s   D B =  R e a d D u r a t i o n   , w h e r e   R e a d D u r a t i o n   i s t h e  

a v e r a g e r e a d d u r a t i o n , c o m p u t e d o v e r a l l t h e r e a d c a l l s o f a l l t h e p r o c e s s e s .  

T h e b u s b a n d w i d t h p l a c e s a n u p p e r b o u n d o n p e r f o r m a n c e . I f t h e b u s w e r e c o n t i n u o u s l y b u s y t r a n s f e r r i n g d a t a ,  

t h e c o r r e s p o n d i n g a v e r a g e r e a d d u r a t i o n w o u l d e q u a l t h e t i m e r e q u i r e d t o t r a n s m i t   D  b l o c k s o f d a t a . T h i s s c e n a r i o  

w o u l d c o r r e s p o n d w i t h a s i t u a t i o n i n w h i c h a l l t h e o t h e r c o m p o n e n t s o f t h e s e r v i c e t i m e f o r a d i s k ( e . g . , s e e k t i m e ,  

S C S I o v e r h e a d , b u s b u s y t i m e , r o t a t i o n a l l a t e n c y a n d t r a n s f e r ) a r e o v e r l a p p e d w i t h t h e d a t a t r a n s f e r s o f t h e o t h e r  

d i s k s t h a t s h a r e t h e b u s . T h u s , t h e a v e r a g e r e a d d u r a t i o n i s a n i n d i c a t o r o f h o w e e c t i v e l y t h e d i s k l a t e n c y i s h i d d e n  

b y o t h e r c o n c u r r e n t t r a n s f e r s o n t h e b u s .  

6 . 7 . 2 S i n g l e d i s k m o d e l  

I n t h i s s e c t i o n w e p r e s e n t o u r m o d e l o f r e a d d u r a t i o n w h e n o n l y a s i n g l e d i s k i s a c t i v e .  

R e a d d u r a t i o n f o r f e n c e v a l u e 0 .   W h e n t h e f e n c e v a l u e i s 0 , t h e d i s k r e q u e s t s t h e b u s a s s o o n a s t h e r s t s e c t o r  

i s i n t h e d i s k c a c h e . A f t e r t h e r s t s e c t o r h a s b e e n t r a n s f e r r e d t o t h e h o s t , t h e t r a n s f e r o f t h e r e m a i n d e r o f t h e d a t a  

o c c u r s a t t h e m e d i a - t o - c a c h e r a t e (  b a n d w i d t h  

r o t 

) , w h i c h i s s m a l l e r t h a n t h e c a c h e - t o - h o s t r a t e (  b a n d w i d t h  

b u s 

) . W h e n  

u s i n g o n l y a s i n g l e d i s k , a n d t h e b l o c k d o e s n o t c r o s s a t r a c k o r c y l i n d e r b o u n d a r y , t h e a v e r a g e t i m e t o r e a d a b l o c k  

o f s i z e   B  (  B > >  1 s e c t o r ) i s w e l l a p p r o x i m a t e d b y  

R e a d D u r a t i o n   =  O v e r h e a d   +  E    S e e k T i m e  ] +  E    R o t a t i o n a l L a t e n c y   ] + 

b a n d w i d t h  

r o t 

T h i s e q u a t i o n a p p r o x i m a t e s t h e a v e r a g e r e a d d u r a t i o n a s t h e s u m o f t h e S C S I p r o t o c o l o v e r h e a d t i m e , t h e e x p e c t e d  

s e e k t i m e , t h e e x p e c t e d r o t a t i o n a l l a t e n c y , a n d t h e t i m e t o r e a d t h e d a t a f r o m t h e d i s k s u r f a c e .  

W h e n   B  i s l a r g e , t h e d a t a w i l l b e s p r e a d o u t o v e r a n u m b e r o f t r a c k s a n d p o s s i b l y c y l i n d e r s . T h u s t h e t r a c k  

a n d c y l i n d e r s w i t c h t i m e s m u s t b e t a k e n i n t o a c c o u n t . L e t   T r a c k S w i t c h T i m e   a n d  C y l i n d e r S w i t c h T i m e   r e p r e s e n t t h e  

T h e p r e e m p t i o n o f a p r o c e s s d u r i n g t h e b r i e f t i m e i n t e r v a l b e t w e e n t h e r e t u r n o f a r e a d c a l l a n d  

t h e i n v o c a t i o n o f t h e n e x t r e a d c a l l i s s u c i e n t l y r a r e t o b e n e g l i g i b l e .  

1 6 7 

Page 181: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 181/203

Page 182: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 182/203

P a r a l l e l r e a d d u r a t i o n f o r f e n c e v a l u e 0 .   T h e g e n e r a l s c e n a r i o i n a r o u n d i s a s f o l l o w s .   D  b l o c k s a r e r e q u e s t e d .  

U s u a l l y t h e r e q u e s t e d b l o c k s a r e n o t i n t h e d i s k c a c h e s , s o t h e d r i v e s d i s c o n n e c t f r o m t h e S C S I b u s . A f t e r t h e s m a l l e s t  

o f t h e   D  p o s i t i o n i n g t i m e s , t h a t d i s k r e a d s t h e r s t s e c t o r i n t o i t s c a c h e , a n d r e c o n n e c t s t o t h e h o s t . I t t r a n s m i t s  

t h e r s t s e c t o r a t   b a n d w i d t h  

b u s 

, a n d t h e n c o n t i n u e s t r a n s m i t t i n g a t   b a n d w i d t h  

r o t 

. I t t r a n s m i t s a l e a d i n g p o r t i o n o f  

t h e r e q u e s t e d b l o c k t o t h e h o s t , a f t e r w h i c h i t d i s c o n n e c t s , e i t h e r b e c a u s e t h e l e a d i n g p o r t i o n w a s t h e e n t i r e b l o c k ,  

o r b e c a u s e t h e r e m a i n i n g p o r t i o n o f t h e b l o c k l i e s o n t h e n e x t t r a c k o r c y l i n d e r . B y t h e t i m e t h i s d i s c o n n e c t i o n  

o c c u r s , i t i s l i k e l y t h a t o t h e r d r i v e s h a v e r e a d e n o u g h d a t a i n t o t h e i r d i s k c a c h e s t h a t t h e r e m a i n i n g p o r t i o n o f t h e   D 

b l o c k s c a n b e t r a n s m i t t e d t o t h e h o s t a t   b a n d w i d t h  

b u s 

. T h e r e m a y b e s e v e r a l d i s c o n n e c t s d u r i n g t h i s t r a n s m i s s i o n , a s  

v a r i o u s d r i v e s r e a c h t r a c k o r c y l i n d e r b o u n d a r i e s , b u t a s s o o n a s o n e d r i v e d i s c o n n e c t s , a n o t h e r r e c o n n e c t s t o c o n t i n u e  

s e n d i n g d a t a t o t h e h o s t . W e d e n o t e t h e a v e r a g e s i z e o f t h e l e a d i n g p o r t i o n o f t h e r s t b l o c k b y   L e a d i n g P o r t i o n   (  B  )

W e m a k e t w o s i m p l i c a t i o n s . A l t h o u g h t h e r s t d i s k s e n d s o n e s e c t o r a t   b a n d w i d t h  

b u s 

b e f o r e s e n d i n g m o r e a t  

b a n d w i d t h  

r o t 

, w e s a y t h a t t h e e n t i r e l e a d i n g p o r t i o n f r o m t h e r s t d i s k i s s e n t a t   b a n d w i d t h  

r o t 

. S e c o n d , t h e o v e r h e a d  

o f t h e d i s c o n n e c t i o n a n d r e c o n n e c t i o n i s s u c i e n t l y s m a l l t h a t i t i s a b s o r b e d i n t o t h e o v e r h e a d t e r m .  

T h u s t h e a v e r a g e r e a d d u r a t i o n i s g i v e n b y  

R e a d D u r a t i o n  

=  O v e r h e a d   +  M P T  (  D  ) + 

L e a d i n g P o r t i o n   (  B  ) 

b a n d w i d t h  

r o t 

D B    L e a d i n g P o r t i o n   (  B  ) 

b a n d w i d t h  

b u s 

( 6 . 3 )  

W h e n t h e b l o c k s i z e   B  i s s m a l l , i t i s u s u a l f o r t h e e n t i r e b l o c k t o r e s i d e o n a s i n g l e t r a c k , w h e r e a s f o r l a r g e b l o c k s  

t h e e x p e c t e d s i z e o f t h e l e a d i n g p o r t i o n i s o n e h a l f t h e t r a c k s i z e . T h u s i f   B    A v e r a g e T r a c k S i z e  =  2 , w e a p p r o x i m a t e  

L e a d i n g P o r t i o n   (  B  ) =  B  , o t h e r w i s e   L e a d i n g P o r t i o n   (  B  ) =  A v e r a g e T r a c k S i z e  =  2

N o t e t h a t e q u a t i o n ( 6 . 3 ) d o e s n o t c o n t a i n t e r m s t o a c c o u n t f o r t h e t r a c k a n d c y l i n d e r c r o s s i n g s a s e q u a t i o n s ( 6 . 1 )  

a n d ( 6 . 2 ) d o . T h e s e c r o s s i n g s d o n o t a d d t o t h e r e a d d u r a t i o n , b e c a u s e t h e b u s r e m a i n s b u s y : o n e d i s k d i s c o n n e c t s  

a n d a n o t h e r d i s k i m m e d i a t e l y s e i z e s t h e b u s t o s e n d i t s d a t a t o t h e h o s t .  

P a r a l l e l r e a d d u r a t i o n f o r m a x i m u m f e n c e v a l u e .   I n t h i s c a s e , t h e b u s i s i d l e d u r i n g t h e s h o r t e s t p o s i t i o n i n g  

t i m e , t h e n t h e b u s c o n t i n u e s t o r e m a i n i d l e w h i l e t h a t d i s k r e a d s t h e b l o c k o f B b y t e s i n t o i t s c a c h e . N e x t t h e b u s  

t r a n s m i t s t h a t b l o c k t o t h e h o s t , f o l l o w e d b y t h e b l o c k s f r o m t h e o t h e r   D    1 d i s k s . T h u s t h e a v e r a g e r e a d d u r a t i o n  

i n t h i s c a s e i s g i v e n b y  

R e a d D u r a t i o n   =  O v e r h e a d   +  M P T  (  D  ) + 

b a n d w i d t h  

r o t 

D B 

b a n d w i d t h  

b u s 

( 6 . 4 )  

6 . 8 V a l i d a t i o n      

T o v a l i d a t e t h e f o u r p e r f o r m a n c e e q u a t i o n s o f t h e p r e v i o u s s e c t i o n , w e r a n e x p e r i m e n t s u s i n g t h e w o r k l o a d a n d  

h a r d w a r e c o n g u r a t i o n s d e s c r i b e d i n S e c t i o n 6 . 4 t o m e a s u r e t h e a v e r a g e r e a d d u r a t i o n s . T h e e x p e r i m e n t s c o n t a i n e d  

1 6 9 

Page 183: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 183/203

s t a r t u p a n d c o o l d o w n p h a s e s t o e n s u r e t h a t t h e b u s e x p e r i e n c e d a t y p i c a l l o a d d u r i n g t h e m e a s u r e m e n t p e r i o d . T h e  

m e a s u r e m e n t p e r i o d w a s 1 0 s e c o n d s ; t h i s p e r i o d w a s s m a l l , y e t g a v e r e s u l t s c l o s e t o l o n g e r m e a s u r e m e n t p e r i o d s .  

W e v a r i e d t h e r e q u e s t s i z e f r o m 8 K B t o 1 2 8 K B a n d t h e v a l u e s o f   D  f r o m 1 t o t h e m a x i m u m f o r t h a t h a r d w a r e  

c o n g u r a t i o n ( 4 o r 7 d i s k s o n a S C S I b u s ) . W e c o m p a r e d t h e m e a s u r e d a v e r a g e r e a d d u r a t i o n s w i t h t h e v a l u e s  

p r e d i c t e d b y e q u a t i o n s ( 6 . 1 ) { ( 6 . 4 ) t o c a l c u l a t e t h e r e l a t i v e m o d e l e r r o r .  

B e l o w , w e r s t p r e s e n t , a l o n g w i t h s o m e a d d i t i o n a l e x p e r i m e n t s u s e d f o r m e a s u r e m e n t s , t h e p a r a m e t e r s u s e d t o  

v a l i d a t e t h e p e r f o r m a n c e m o d e l o n a l l f o u r o f t h e I / O s y s t e m s d e s c r i b e d i n S e c t i o n 6 . 4 a n d p r e s e n t i n d e t a i l t h e r e s u l t s  

o f o u r v a l i d a t i o n e x p e r i m e n t s . E q u a t i o n s ( 6 . 1 ) { ( 6 . 4 ) r e q u i r e a n u m b e r o f d i s k - s p e c i c p a r a m e t e r s s u c h a s   O v e r h e a d   , 

b a n d w i d t h  

r o t 

a n d  b a n d w i d t h  

b u s 

. W e m e a s u r e d s o m e o f t h e s e v a l u e s e x p e r i m e n t a l l y , a n d u s e d t h e d e v i c e s p e c i c a t i o n s  

f o r o t h e r s .  

W e w r a p u p t h i s s e c t i o n b y d r a w i n g c o n c l u s i o n s r e g a r d i n g t h e a c c u r a c y o f o u r m o d e l .  

6 . 8 . 1 E x p e r i m e n t s t o V a l i d a t e M o d e l s  

I n S e c t i o n 6 . 7 , w e p r e s e n t e d e q u a t i o n s t h a t p r e d i c t t h e a v e r a g e r e a d l a t e n c y f o r o n e o r m o r e d i s k s t h a t s h a r e a b u s ,  

f o r a n i n t e n s i v e w o r k l o a d o f x e d - s i z e r a n d o m r e a d s . I n t h i s a p p e n d i x , w e d e s c r i b e t h e e x p e r i m e n t s a n d p a r a m e t e r s  

t h a t w e r e u s e d t o v a l i d a t e t h e p e r f o r m a n c e m o d e l o n a l l f o u r o f t h e I / O s y s t e m s d e s c r i b e d i n S e c t i o n 6 . 4 .  

S e a g a t e W r e n 7  

F i r s t w e d e s c r i b e h o w w e d e t e r m i n e t h e v a l u e s o f t h e m o d e l p a r a m e t e r s f o r t h e W r e n 7 , a n d t h e n w e p r e s e n t t a b l e s  

t h a t c o m p a r e t h e m o d e l p r e d i c t i o n s w i t h t h e m e a s u r e d v a l u e s .  

T h e S C S I o v e r h e a d .   W h e n a n I / O r e q u e s t i s i s s u e d b y a n a p p l i c a t i o n , i t t r a v e l s a p a t h t h r o u g h t h e o p e r a t i n g  

s y s t e m , d e v i c e d r i v e r , S C S I c o n t r o l l e r , S C S I b u s , a n d t h e d i s k c o n t r o l l e r . T h i s p a t h c a n b e d e l a y e d a t m a n y p o i n t s ,  

s o t h e t i m e t o d e l i v e r t h e r e q u e s t t o t h e d i s k i s n o t c o n s t a n t . F o r i n s t a n c e , t h e d e v i c e d r i v e r c a n b e p r e e m p t e d b y a  

h i g h - p r i o r i t y i n t e r r u p t , o r t h e S C S I b u s c a n b e b u s y t r a n s f e r r i n g o t h e r d a t a s o t h a t i t i s n o t i m m e d i a t e l y a v a i l a b l e t o  

s e n d a c o m m a n d t o t h e d i s k , o r t h e d i s k c o n t r o l l e r c a n b e b u s y w i t h h o u s e k e e p i n g o p e r a t i o n s s o i t i s s l o w t o a c c e p t  

t h e r e q u e s t . T h e o v e r h e a d a l s o v a r i e s a c r o s s d i e r e n t k i n d s o f r e q u e s t s . F o r e x a m p l e , t h e d i s k c h e c k s i t s c a c h e d u r i n g  

a r e a d c o m m a n d , b u t n o t f o r a s e e k .  

W e d e t e r m i n e a v a l u e f o r   O v e r h e a d   b y m e a s u r i n g t h e t i m e t o s e e k t o t h e t r a c k w h e r e t h e d i s k h e a d a l r e a d y i s  

( a z e r o - l e n g t h s e e k , a n d n o t r a c k s w i t c h ) . T h i s t i m e r a n g e s f r o m 1 . 3 6 t o 1 . 4 5 m s . T h u s , w e u s e 1 . 4 m s f o r t h e  

v a l u e o f   O v e r h e a d   w h e n v a l i d a t i n g t h e m o d e l . A s a s e c o n d c o n r m a t i o n o f t h i s v a l u e , w e m e a s u r e t h e t i m e t o r e a d a  

c a c h e d b l o c k o f s i z e 5 1 2 b y t e s . U s i n g t h e m e a s u r e d m e a n b u s b a n d w i d t h , w e c o m p u t e t h e a m o u n t o f t i m e r e q u i r e d  

t o t r a n s f e r t h e d a t a o v e r t h e b u s , a n d a t t r i b u t e t h e r e m a i n i n g t i m e t o o v e r h e a d . T h i s t e c h n i q u e y i e l d s v a l u e s i n t h e  

r a n g e 1   2 { 1  3 m s .  

1 7 0 

Page 184: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 184/203

T h e s e e k t i m e .   S i n c e w e a r e r e a d i n g r a n d o m b l o c k s , t h e s e e k t i m e c o n t r i b u t i n g t o a p a r t i c u l a r r e a d d u r a t i o n  

d e p e n d s o n t h e h e a d p o s i t i o n j u s t p r i o r t o t h e r e a d . I n p r e d i c t i n g t h e r e a d d u r a t i o n f o r a p a r t i c u l a r b l o c k s i z e w e  

u s e t h e a v e r a g e s e e k t i m e g i v e n i n t h e d i s k d r i v e m a n u a l , a s d e p i c t e d i n T a b l e 6 . 1 . W e e x p e r i m e n t a l l y c o n r m t h i s  

v a l u e b y m e a s u r i n g t h e t i m e n e e d e d t o s e e k o v e r 1 / 3 o f t h e t o t a l n u m b e r o f c y l i n d e r s , w h i c h i s 1 4 . 9 m s .  

T h e r o t a t i o n a l l a t e n c y .   T h e r o t a t i o n a l l a t e n c y i s t h e t i m e r e q u i r e d f o r t h e b e g i n n i n g o f t h e b l o c k t o c o m e u n d e r  

t h e h e a d a f t e r t h e s e e k . O n a v e r a g e t h i s c o r r e s p o n d s t o t h e t i m e f o r h a l f a r o t a t i o n . W e e x p e r i m e n t a l l y c o n r m t h i s  

v a l u e b y m e a s u r i n g r a n d o m w o r k l o a d s w i t h d i e r e n t r e q u e s t s i z e s .  

T h e m e d i a - c a c h e b a n d w i d t h .   W e c a n c a l c u l a t e t h e m e d i a - t o - c a c h e b a n d w i d t h   b a n d w i d t h  

r o t 

| i t i s j u s t t h e b y t e s  

p e r t r a c k d i v i d e d b y t h e r o t a t i o n t i m e o f t h e d i s k . F o r t h e W r e n 7 , t h e a v e r a g e v a l u e i s 2 . 1 3 M B / s e c o n d . T h e W r e n 7  

i s a z o n e d d i s k . T h e t r a n s f e r r a t e r a n g e s f r o m 2 . 3 4 M B / s i n t h e o u t e r - m o s t z o n e t o 1 . 6 2 M B / s i n t h e i n n e r - m o s t  

z o n e .  

T h e t r a c k a n d c y l i n d e r s w i t c h e s .   T h e d i s k m a n u a l C o r 8 9 ] s t a t e s t h a t t h e t i m e f o r a t r a c k s w i t c h i s 2 m s . W e  

m e a s u r e d t h e t i m e f o r a c y l i n d e r c r o s s i n g t o b e 3 . 5 m s .  

T h e s u s t a i n e d S C S I b u s b a n d w i d t h .   W e e x p e r i m e n t a l l y d e t e r m i n e t h e b u s b a n d w i d t h   b a n d w i d t h  

b u s 

b y t h e  

m e t h o d s u g g e s t e d i n W G P W 9 5 ] . W e m e a s u r e t h e m e a n r e a d s e r v i c e t i m e f o r r e q u e s t s i z e s r a n g i n g f r o m 8 K B t o  

1 2 8 K B , w h e r e t h e d a t a t o b e r e a d h a s p r e v i o u s l y b e e n p r e f e t c h e d i n t o t h e d i s k c a c h e . F o r a l l p a i r s o f r e a d s i z e s , w e  

c a l c u l a t e t h e b u s b a n d w i d t h a s t h e m e a n o f   b = t  , w h e r e   b  i s t h e d i e r e n c e b e t w e e n t h e r e a d s i z e s i n b y t e s , a n d   t 

i s t h e d i e r e n c e i n t i m e s . T h e v a l u e s r a n g e d b e t w e e n 3 . 2 2 a n d 3 . 4 6 ; w e u s e 3 . 3 M B / s a s t h e b u s b a n d w i d t h .  

T h e e x p e c t e d m i n i m u m p o s i t i o n i n g t i m e .   W e e x p e r i m e n t a l l y d e t e r m i n e   M P T  (  D  ) , t h e e x p e c t e d m i n i m u m  

p o s i t i o n i n g t i m e f o r   D  c o n c u r r e n t r e q u e s t s , b y i s s u i n g r a n d o m o n e - s e c t o r n o n - b l o c k i n g r e a d s t o   D  d i s k s a n d m e a s u r i n g  

t h e t i m e f o r t h e r s t o n e t o c o m p l e t e . N o t e t h a t t h e s e m e a s u r e m e n t s a r e t h e s u m o f   O v e r h e a d   a n d  M P T  (  D  ) . T h e  

m e a s u r e m e n t s a r e a v e r a g e d o v e r 1 0 0 0 t r i a l s f o r 1 { 5 d i s k s a n d o v e r 2 0 0 t r i a l s f o r 6 a n d 7 d i s k s . T h e r e s u l t s a p p e a r i n  

T a b l e 6 . 2 . W e u s e t h e s e v a l u e s f o r   O v e r h e a d   +  M P T  i n e q u a t i o n s ( 6 . 3 ) a n d ( 6 . 4 ) .  

T a b l e 6 . 2  : T h e a v e r a g e m i n i m u m t i m e t o r e a d o n e s e c t o r o n a W r e n 7 .  

D  1 2 3 4 5 6 7  

m e a n m i n 2 6 . 7 2 2 . 3 2 0 . 0 1 9 . 1 1 8 . 3 1 7 . 2 1 6 . 6  

W e c a n p e r f o r m a b a c k - o f - t h e - e n v e l o p e c a l c u l a t i o n w h e n   D  = 1 t o c h e c k t h e r e a s o n a b l e n e s s o f T a b l e 6 . 2 . F o r o n e  

d i s k , t h i s v a l u e s h o u l d b e t h e s u m o f t h e m e a n s e e k t i m e , t h e m e a n r o t a t i o n a l l a t e n c y , t h e t i m e t o r e a d o n e s e c t o r  

i n t o t h e d i s k c a c h e ( i . e . ,   B    b a n d w i d t h  

r o t 

(  B  ) ) , a n d t h e t i m e t o t r a n s f e r t h e s e c t o r f r o m t h e d i s k c a c h e t o t h e h o s t  

( i . e . ,   B    b a n d w i d t h  

b u s 

(  B  ) ) . F o r t h e W r e n 7 d i s k s , t h e m e a n s e e k t i m e i s 1 5 . 0 m s a n d t h e m e a n r o t a t i o n a l l a t e n c y i s  

8 . 3 m s . T h e t r a n s f e r r a t e f r o m m e d i a t o d i s k c a c h e i s 2 . 1 3 M B / s , g i v i n g u s 0 . 2 5 m s t o t r a n s f e r a 5 1 2 b y t e s e c t o r .  

U s i n g t h e t r a n s f e r r a t e o f 3 . 3 M B / s e c f r o m t h e d i s k c a c h e t o t h e h o s t , w e g e t a t r a n s f e r t i m e o f 0 . 1 m s . I n a d d i t i o n ,  

1 7 1 

Page 185: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 185/203

t h e r e i s s o m e o v e r h e a d t i m e t o g e t t h e S C S I r e q u e s t t o t h e d i s k a n d p r o c e s s i t ; w e h a v e m e a s u r e d t h i s v a l u e a s 1 . 4  

m s . S u m m i n g t h e s e v a l u e s , w e g e t 2 5 . 1 m s . T h u s , t h e m e a s u r e d v a l u e o f 2 6 . 7 m s s e e m s r e a s o n a b l e .  

T a b l e s 6 . 3 { 6 . 6 c o m p a r e t h e p r e d i c t i o n s o f t h e f o u r e q u a t i o n s o f S e c t i o n 6 . 7 w i t h m e a s u r e d v a l u e s , u s i n g 1 , 2 , 4 ,  

a n d 7 W r e n d i s k s o n a S C S I b u s . O u r m o d e l t o p r e d i c t a v e r a g e r e a d d u r a t i o n l e n g t h f o r r e q u e s t s i z e s o f 1 6 K B o r  

m o r e i s a c c u r a t e ; t h e m a x i m u m r e l a t i v e e r r o r i s 8 . 5 % , a n d m o s t a r e b e l o w 3 % .  

F o r p a r a l l e l d i s k s a n d r e q u e s t s o f s i z e 8 K B , t h e e r r o r s a r e l a r g e r ( 2 . 3 { 1 0 . 0 % ) . O u r m o d e l c o u n t s t h e p o s i t i o n i n g  

t i m e o f o n l y o n e d i s k i n t h e r e a d d u r a t i o n , u n d e r t h e a s s u m p t i o n t h a t t h e o t h e r s w i l l b e o v e r l a p p e d w i t h t h e p o s i t i o n i n g  

t i m e a n d b u s t r a n s f e r t i m e o f t h e r s t d i s k . W e b e l i e v e t h a t s o m e t i m e s t h e f a s t e s t r e q u e s t c o m p l e t e s b e f o r e a n y o f  

t h e r e m a i n i n g   D    1 d i s k s b e c o m e s r e a d y t o t r a n s f e r d a t a . W e s u s p e c t t h a t t h i s o c c u r r e n c e m a y a l s o e x p l a i n s o m e  

o f t h e i n a c c u r a c y i n t h e 8 - K B e x p e r i m e n t s o n t h e B a r r a c u d a s a n d C h e e t a h s .  

T a b l e 6 . 3  : V a l i d a t i n g e q u a t i o n ( 6 . 1 ) ( 1 W r e n , f e n c e 0 ) .  

B l o c k s i z e ( K B ) M e a s u r e d ( m s ) E s t i m a t e d ( m s ) R e l a t i v e e r r o r %  

8 3 1 . 6 2 9 . 3 7 . 3  

1 6 3 5 . 1 3 3 . 6 4 . 5  

3 2 4 3 . 2 4 2 . 0 2 . 8  

6 4 6 0 . 8 5 8 . 9 3 . 1  

9 6 7 6 . 0 7 5 . 8 0 . 2  

1 2 8 9 5 . 4 9 2 . 8 2 . 7  

T a b l e 6 . 4  : V a l i d a t i n g e q u a t i o n ( 6 . 2 ) ( 1 W r e n , f e n c e 2 5 5 ) .  

B l o c k s i z e ( K B ) M e a s u r e d ( m s ) E s t i m a t e d ( m s ) R e l a t i v e e r r o r %  

8 3 3 . 5 3 1 . 8 5 . 0  

1 6 4 0 . 6 3 8 . 5 5 . 2  

3 2 5 3 . 6 5 1 . 9 3 . 1  

6 4 8 1 . 3 7 8 . 8 3 . 1  

9 6 1 0 6 . 3 1 0 5 . 6 0 . 6  

1 2 8 1 3 6 . 2 1 3 2 . 5 2 . 7  

T a b l e 6 . 5  : V a l i d a t i n g e q u a t i o n ( 6 . 3 ) ( W r e n d i s k s , f e n c e 0 ) .  

B l o c k   D  = 2  D  = 4  D  = 7 

s i z e M e a s . E s t . R e l . M e a s . E s t . R e l . M e a s . E s t . R e l .  

( K B ) ( m s ) ( m s ) e r r ( % ) ( m s ) ( m s ) e r r ( % ) ( m s ) ( m s ) e r r ( % )  

8 3 1 . 7 2 8 . 5 1 0 . 0 3 2 . 6 3 0 . 3 7 . 0 3 7 . 9 3 5 . 3 6 . 9  

1 6 3 6 . 6 3 4 . 8 5 . 2 4 2 . 5 4 1 . 5 2 . 3 5 9 . 0 5 3 . 9 8 . 5  

3 2 4 6 . 9 4 7 . 2 0 . 8 6 5 . 0 6 3 . 9 1 . 6 9 4 . 9 9 1 . 2 3 . 9  

6 4 6 8 . 3 6 7 . 6 1 . 0 1 0 5 . 8 1 0 4 . 2 1 . 5 1 5 9 . 1 1 6 1 . 3 1 . 4  

9 6 8 9 . 2 8 7 . 5 1 . 9 1 4 5 . 2 1 4 3 . 9 0 . 9 2 2 5 . 0 2 3 0 . 8 2 . 6  

1 2 8 1 1 4 . 8 1 0 7 . 4 6 . 4 1 9 0 . 4 1 8 3 . 6 3 . 5 3 0 5 . 9 3 0 0 . 3 1 . 8  

T h e B a r r a c u d a s  

W e d e t e r m i n e t h e p a r a m e t e r s f o r t h e B a r r a c u d a d i s k b y t h e t e c h n i q u e s p r e v i o u s l y d e s c r i b e d f o r t h e W r e n d i s k s . T h e  

p a r a m e t e r s a r e s h o w n i n T a b l e 6 . 7 .  

1 7 2 

Page 186: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 186/203

F o r t h e B a r r a c u d a s w e d i d n o t m o d i f y t h e f e n c e v a l u e , s o w e o n l y e v a l u a t e t h e m o d e l f o r f e n c e 0 . T a b l e s 6 . 8 a n d  

6 . 9 c o m p a r e t h e p r e d i c t i o n s o f t h e f e n c e = 0 e q u a t i o n s o f S e c t i o n 6 . 7 w i t h m e a s u r e d v a l u e s , u s i n g 1 { 4 B a r r a c u d a d i s k s  

o n a D E C A l p h a S C S I b u s . T h e l a r g e s t e r r o r i s 1 0 . 8 % .  

S e a g a t e C h e e t a h o n S u n S p a r c - 2 0  

F o r t h e C h e e t a h d i s k , w e d e t e r m i n e t h e d i s k p a r a m e t e r s ( T a b l e 6 . 1 0 ) b y t h e t e c h n i q u e s p r e v i o u s l y d e s c r i b e d f o r t h e  

W r e n d i s k .  

T a b l e s 6 . 1 1 { 6 . 1 4 c o m p a r e t h e p r e d i c t i o n s o f t h e f o u r e q u a t i o n s o f S e c t i o n 6 . 7 w i t h m e a s u r e d v a l u e s o n a S u n  

S p a r c - 2 0 M o d e l 6 1 w o r k s t a t i o n , u s i n g 1 { 4 C h e e t a h d i s k s o n a f a s t - w i d e S C S I b u s . T h e r e l a t i v e e r r o r s a r e s m a l l e r  

t h a n 8 % , e x c e p t f o r t h e c a s e o f 8 K B , f e n c e 0 , a n d 4 d i s k s , w h i c h h a s a n e r r o r o f 1 4 % .  

T a b l e 6 . 6  : V a l i d a t i n g e q u a t i o n ( 6 . 4 ) ( W r e n d i s k s , f e n c e 2 5 5 ) .  

B l o c k   D  = 2  D  = 4  D  = 7 

s i z e M e a s . E s t . R e l . M e a s . E s t . R e l . M e a s . E s t . R e l .  

( K B ) ( m s ) ( m s ) e r r ( % ) ( m s ) ( m s ) e r r ( % ) ( m s ) ( m s ) e r r ( % )  

8 3 3 . 7 3 1 . 0 7 . 9 3 4 . 4 3 2 . 8 4 . 7 3 8 . 7 3 7 . 8 2 . 3  

1 6 4 1 . 9 3 9 . 7 5 . 1 4 6 . 2 4 6 . 5 0 . 7 6 3 . 1 5 8 . 9 6 . 6  

3 2 5 7 . 0 5 7 . 2 0 . 2 7 4 . 7 7 3 . 9 1 . 1 1 0 7 . 0 1 0 1 . 2 5 . 5  

6 4 9 1 . 9 9 2 . 0 0 . 2 1 3 1 . 6 1 2 8 . 6 2 . 2 1 8 2 . 5 1 8 5 . 7 1 . 7  

9 6 1 2 8 . 0 1 2 6 . 9 0 . 9 1 8 5 . 0 1 8 3 . 3 0 . 9 2 6 3 . 4 2 7 0 . 2 2 . 6  

1 2 8 1 6 4 . 7 1 6 1 . 8 1 . 7 2 4 1 . 6 2 3 8 . 1 1 . 5 3 5 4 . 6 3 5 4 . 8 0 . 0  

T a b l e 6 . 7   : T h e B a r r a c u d a d e v i c e p a r a m e t e r s .  

p a r a m e t e r v a l u e  

S C S I o v e r h e a d 0 . 7 m s  

e x p e c t e d m i n i m u m p o s i t i o n i n g t i m e 1 0 . 8 { 1 2 . 6 m s  

b a n d w i d t h  

b u s 

1 8 . 7 7 M B / s  

s i n g l e t r a c k s w i t c h t i m e 2 m s  

s i n g l e c y l i n d e r s w i t c h t i m e 2 m s  

T a b l e 6 . 8  : V a l i d a t i n g e q u a t i o n ( 6 . 1 ) ( 1 B a r r a c u d a , f e n c e 0 ) .  

B l o c k s i z e ( K B ) M e a s u r e d ( m s ) E s t i m a t e d ( m s ) R e l a t i v e e r r o r %  

8 1 5 . 2 1 4 . 2 6 . 3  

1 6 1 6 . 8 1 5 . 3 8 . 7  

3 2 1 7 . 8 1 7 . 4 2 . 1  

6 4 2 2 . 4 2 1 . 7 3 . 1  

9 6 2 6 . 6 2 5 . 9 2 . 7  

1 2 8 3 1 . 4 3 0 . 2 3 . 8  

T a b l e 6 . 9  : V a l i d a t i n g e q u a t i o n ( 6 . 3 ) ( B a r r a c u d a d i s k s , f e n c e 0 ) .  

B l o c k   D  = 2  D  = 3  D  = 4 

s i z e M e a s . E s t . R e l . M e a s . E s t . R e l . M e a s . E s t . R e l .  

( K B ) ( m s ) ( m s ) e r r ( % ) ( m s ) ( m s ) e r r ( % ) ( m s ) ( m s ) e r r ( % )  

8 1 4 . 6 1 3 . 9 4 . 9 1 4 . 2 1 3 . 3 6 . 7 1 4 . 4 1 2 . 9 1 0 . 3  

1 6 1 5 . 8 1 5 . 1 4 . 2 1 5 . 7 1 5 . 0 4 . 5 1 5 . 4 1 5 . 1 2 . 4  

3 2 1 7 . 7 1 7 . 6 0 . 2 1 7 . 6 1 8 . 4 4 . 5 1 8 . 0 1 9 . 3 7 . 3  

6 4 2 2 . 4 2 2 . 6 1 . 1 2 3 . 2 2 5 . 1 8 . 4 2 5 . 1 2 7 . 8 1 0 . 8  

9 6 2 7 . 3 2 7 . 0 1 . 2 2 9 . 2 3 1 . 2 6 . 9 3 3 . 5 3 5 . 6 6 . 3  

1 2 8 3 2 . 2 3 0 . 5 5 . 4 3 5 . 5 3 6 . 4 2 . 7 4 1 . 5 4 2 . 6 2 . 7  

1 7 3 

Page 187: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 187/203

S e a g a t e C h e e t a h o n S u n U l t r a - 1  

T h e d e v i c e p a r a m e t e r s f o r t h e C h e e t a h s o n t h e S u n U l t r a - 1 a r e t h e s a m e a s o n t h e S u n S p a r c - 2 0 w i t h t h e e x c e p t i o n  

o f t h e S C S I o v e r h e a d ; w e m e a s u r e d t h i s t o b e 0 . 4 m s .  

T a b l e s 6 . 1 5 { 6 . 1 8 c o m p a r e t h e p r e d i c t i o n s o f t h e f o u r e q u a t i o n s o f S e c t i o n 6 . 7 w i t h m e a s u r e d v a l u e s o n a S u n  

T a b l e 6 . 1 0  : T h e C h e e t a h d e v i c e p a r a m e t e r s .  

p a r a m e t e r v a l u e  

S C S I o v e r h e a d 0 . 8 m s  

e x p e c t e d m i n i m u m p o s i t i o n i n g t i m e 8 . 0 { 1 1 . 5 3 m s  

b a n d w i d t h  

b u s 

1 8 . 6 4 M B / s  

s i n g l e t r a c k s w i t c h t i m e 0 . 2 m s  

s i n g l e c y l i n d e r s w i t c h t i m e 0 . 2 m s  

T a b l e 6 . 1 1  : V a l i d a t i n g e q u a t i o n ( 6 . 1 ) ( 1 C h e e t a h , f e n c e 0 , S p a r c - 2 0 ) .  

B l o c k s i z e ( K B ) M e a s u r e d ( m s ) E s t i m a t e d ( m s ) R e l a t i v e e r r o r %  

8 1 1 . 7 1 2 . 1 3 . 7  

1 6 1 2 . 6 1 2 . 7 1 . 3  

3 2 1 3 . 9 1 3 . 9 0 . 1  

6 4 1 6 . 8 1 6 . 4 2 . 4  

9 6 1 9 . 8 1 8 . 8 5 . 0  

1 2 8 2 2 . 8 2 1 . 2 7 . 0  

T a b l e 6 . 1 2  : V a l i d a t i n g e q u a t i o n ( 6 . 2 ) ( 1 C h e e t a h , f e n c e 2 5 5 , S p a r c - 2 0 ) .  

B l o c k s i z e ( K B ) M e a s u r e d ( m s ) E s t i m a t e d ( m s ) R e l a t i v e e r r o r %  

8 1 1 . 9 1 2 . 6 5 . 7  

1 6 1 3 . 2 1 3 . 6 3 . 1  

3 2 1 5 . 4 1 5 . 7 2 . 0  

6 4 1 9 . 8 1 9 . 9 0 . 5  

9 6 2 4 . 4 2 4 . 0 1 . 6  

1 2 8 2 9 . 4 2 8 . 2 3 . 9  

T a b l e 6 . 1 3   : V a l i d a t i n g e q u a t i o n ( 6 . 3 ) ( C h e e t a h d i s k s , f e n c e 0 , S p a r c - 2 0 ) .  

B l o c k   D  = 2  D  = 4 

s i z e M e a s . E s t . R e l . M e a s . E s t . R e l .  

( K B ) ( m s ) ( m s ) e r r ( % ) ( m s ) ( m s ) e r r ( % )  

8 1 1 . 8 1 0 . 9 7 . 5 1 1 . 5 9 . 9 1 4 . 0  

1 6 1 2 . 6 1 1 . 9 5 . 5 1 2 . 5 1 1 . 8 5 . 3  

3 2 1 4 . 2 1 4 . 0 1 . 9 1 4 . 9 1 5 . 6 4 . 8  

6 4 1 7 . 6 1 8 . 0 2 . 7 2 1 . 6 2 3 . 2 7 . 7  

9 6 2 1 . 1 2 1 . 9 3 . 6 2 8 . 3 3 0 . 6 8 . 0  

1 2 8 2 5 . 9 2 5 . 4 1 . 8 3 7 . 6 3 7 . 6 0 . 1  

T a b l e 6 . 1 4   : V a l i d a t i n g e q u a t i o n ( 6 . 4 ) ( C h e e t a h d i s k s , f e n c e 2 5 5 , S p a r c - 2 0 ) .  

B l o c k   D  = 2  D  = 4 

s i z e M e a s . E s t . R e l . M e a s . E s t . R e l .  

( K B ) ( m s ) ( m s ) e r r ( % ) ( m s ) ( m s ) e r r ( % )  

1 6 1 3 . 2 1 2 . 8 3 . 0 1 3 . 1 1 2 . 7 3 . 5  

3 2 1 5 . 7 1 5 . 7 0 . 3 1 6 . 2 1 7 . 4 7 . 0  

6 4 2 0 . 5 2 1 . 6 5 . 2 2 4 . 5 2 6 . 1 6 . 7  

9 6 2 6 . 1 2 7 . 4 4 . 8 3 4 . 3 3 6 . 1 5 . 3  

1 2 8 3 2 . 9 3 3 . 3 1 . 0 4 6 . 0 4 5 . 5 1 . 3  

1 7 4 

Page 188: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 188/203

U l t r a - 1 w o r k s t a t i o n , u s i n g 1 { 4 C h e e t a h d i s k s o n a f a s t - w i d e S C S I b u s . T h e r e l a t i v e e r r o r i s s m a l l e r t h a n 1 0 % f o r  

r e q u e s t s i z e s 1 6 K B a n d g r e a t e r , a n d s m a l l e r t h a n 1 4 % f o r 8 K B r e q u e s t s .  

T a b l e 6 . 1 5   : V a l i d a t i n g e q u a t i o n ( 6 . 1 ) ( 1 C h e e t a h , f e n c e 0 , U l t r a ) .  

B l o c k s i z e ( K B ) M e a s u r e d ( m s ) E s t i m a t e d ( m s ) R e l a t i v e e r r o r %  

8 1 1 . 8 1 2 . 1 3 . 1  

1 6 1 2 . 3 1 2 . 7 3 . 9  

3 2 1 3 . 6 1 3 . 9 2 . 7  

6 4 1 6 . 0 1 6 . 4 2 . 5  

9 6 1 8 . 8 1 8 . 8 0 . 4  

1 2 8 2 1 . 3 2 1 . 2 0 . 5  

T a b l e 6 . 1 6  : V a l i d a t i n g e q u a t i o n ( 6 . 2 ) ( 1 C h e e t a h , f e n c e 2 5 5 , U l t r a ) .  

B l o c k s i z e ( K B ) M e a s u r e d ( m s ) E s t i m a t e d ( m s ) R e l a t i v e e r r o r %  

8 1 2 . 1 1 2 . 6 3 . 9  

1 6 1 3 . 1 1 3 . 6 3 . 6  

3 2 1 5 . 3 1 5 . 7 2 . 7  

6 4 1 9 . 5 1 9 . 9 1 . 9  

9 6 2 4 . 4 2 4 . 0 1 . 5  

1 2 8 2 8 . 5 2 8 . 2 1 . 0  

T a b l e 6 . 1 7   : V a l i d a t i n g e q u a t i o n ( 6 . 3 ) ( C h e e t a h d i s k s , f e n c e 0 , U l t r a ) .  

B l o c k   D  = 2  D  = 3  D  = 4 

s i z e M e a s . E s t . R e l . M e a s . E s t . R e l . M e a s . E s t . R e l .  

( K B ) ( m s ) ( m s ) e r r ( % ) ( m s ) ( m s ) e r r ( % ) ( m s ) ( m s ) e r r ( % )  

8 1 1 . 4 1 0 . 9 4 . 4 1 1 . 3 9 . 8 1 3 . 7 1 1 . 1 9 . 9 1 1 . 4  

1 6 1 2 . 2 1 1 . 9 2 . 3 1 2 . 3 1 1 . 3 8 . 3 1 2 . 2 1 1 . 8 3 . 4  

3 2 1 3 . 7 1 4 . 0 1 . 6 1 4 . 4 1 4 . 2 1 . 7 1 5 . 1 1 5 . 6 3 . 2  

6 4 1 7 . 4 1 8 . 0 3 . 6 1 9 . 7 2 0 . 0 1 . 9 2 2 . 8 2 3 . 2 1 . 7  

9 6 2 1 . 2 2 1 . 9 0 . 9 2 5 . 6 2 5 . 6 0 . 1 3 0 . 6 3 0 . 6 0 . 3  

1 2 8 2 5 . 2 2 5 . 4 0 . 4 3 1 . 5 3 0 . 9 1 . 8 3 8 . 2 3 7 . 6 1 . 7  

T a b l e 6 . 1 8   : V a l i d a t i n g e q u a t i o n ( 6 . 4 ) ( C h e e t a h d i s k s , f e n c e 2 5 5 , U l t r a ) .  

B l o c k   D  = 2  D  = 3  D  = 4 

s i z e M e a s . E s t . R e l . M e a s . E s t . R e l . M e a s . E s t . R e l .  

( K B ) ( m s ) ( m s ) e r r ( % ) ( m s ) ( m s ) e r r ( % ) ( m s ) ( m s ) e r r ( % )  

8 1 1 . 7 1 1 . 3 3 . 0 1 1 . 6 1 0 . 3 1 1 . 8 1 1 . 4 1 0 . 3 9 . 1  

1 6 1 3 . 0 1 2 . 8 1 . 8 1 3 . 1 1 2 . 2 7 . 3 1 3 . 0 1 2 . 7 2 . 6  

3 2 1 5 . 6 1 5 . 7 1 . 0 1 6 . 0 1 6 . 0 0 . 0 1 6 . 5 1 7 . 4 5 . 4  

6 4 2 0 . 9 2 1 . 6 3 . 1 2 2 . 6 2 3 . 6 4 . 1 2 6 . 3 2 6 . 7 1 . 6  

9 6 2 6 . 6 2 7 . 4 2 . 9 3 1 . 5 3 1 . 2 0 . 9 3 7 . 2 3 6 . 1 3 . 1  

1 2 8 3 2 . 2 3 3 . 3 3 . 1 3 9 . 1 3 8 . 8 0 . 8 4 6 . 2 4 5 . 5 1 . 6  

6 . 8 . 2 C o n c l u s i o n s F r o m E x p e r i m e n t a l V a l i d a t i o n  

B a s e d u p o n t h e a b o v e e x p e r i m e n t s , w e n o w p r e s e n t t h e c o n c l u s i o n s r e g a r d i n g t h e a c c u r a c y o f o u r m o d e l . F o r r e q u e s t  

s i z e s 1 6 K B t o 1 2 8 K B , t h e m a x i m u m r e l a t i v e e r r o r o n t h e W r e n d i s k f o r t h e s i n g l e d i s k m o d e l i s l e s s t h a n 5 . 2 % a n d  

f o r t h e p a r a l l e l d i s k m o d e l , 8 . 5 % . O u r m a x i m u m e r r o r s f o r t h e B a r r a c u d a a r e l a r g e r : 8 . 7 % f o r t h e s i n g l e d i s k m o d e l  

1 7 5 

Page 189: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 189/203

a n d 1 0 . 8 % f o r t h e p a r a l l e l d i s k m o d e l . O u r m a x i m u m e r r o r s f o r t h e C h e e t a h a r e s i m i l a r t o t h e B a r r a c u d a : 7 . 0 % f o r  

t h e s i n g l e d i s k m o d e l a n d 9 . 2 % f o r t h e p a r a l l e l d i s k m o d e l . T h e C h e e t a h m o d e l e r r o r i n c r e a s e s t o 1 4 % w i t h 8 K B  

b l o c k s . W e b e l i e v e t h a t t h e s e d i s k s a r e s o f a s t t h a t t h e t r a n s f e r o f t h e r s t s m a l l b l o c k s o m e t i m e s c o m p l e t e s b e f o r e  

a n y o t h e r d i s k s a r e r e a d y t o u s e t h e b u s , s o t h e m o d e l u n d e r e s t i m a t e s t h e a m o u n t o f b u s i d l e t i m e .  

E q u a t i o n s ( 6 . 1 ) { ( 6 . 4 ) r e q u i r e a n u m b e r o f d i s k - s p e c i c p a r a m e t e r s s u c h a s   O v e r h e a d   ,  b a n d w i d t h  

r o t 

a n d 

b a n d w i d t h  

b u s 

. W e m e a s u r e d s o m e o f t h e s e v a l u e s e x p e r i m e n t a l l y , a n d u s e d t h e d e v i c e s p e c i c a t i o n s f o r o t h e r s .  

6 . 9 P i p e l i n i n g      

W h e n w e e x a m i n e t h e m o d e l e q u a t i o n s ( 6 . 3 ) a n d ( 6 . 4 ) t o l o o k f o r o p p o r t u n i t i e s t o d e c r e a s e t h e r e a d d u r a t i o n , w e  

n o t i c e t h a t o n e p o s s i b i l i t y i s t o d e c r e a s e t h e m i n i m u m p o s i t i o n i n g t i m e , a n d a n o t h e r p o s s i b i l i t y i s t o c o n v e r t t h o s e  

t r a n s f e r s t h a t o c c u r a t   b a n d w i d t h  

r o t 

t o t h e f a s t e r   b a n d w i d t h  

b u s 

A s s u m i n g t h a t d u r i n g i t e r a t i o n   j    1 w e k n o w t h e b l o c k s t h a t w i l l b e r e q u e s t e d d u r i n g i t e r a t i o n   j  , w e p r o p o s e a  

p i p e l i n i n g t e c h n i q u e t o o v e r l a p t h e p o s i t i o n i n g t i m e f o r i t e r a t i o n   j  w i t h t h e t r a n s f e r t i m e o f t h e p r e v i o u s i t e r a t i o n .  

F u r t h e r m o r e , t h i s p i p e l i n i n g t e c h n i q u e s t a g e s d a t a i n t h e o n - d i s k c a c h e s , s o t h a t t h e r s t b l o c k t r a n s m i t t e d d u r i n g  

i t e r a t i o n   j  i s s e n t f r o m c a c h e a t   b a n d w i d t h  

b u s 

, r a t h e r t h a n f r o m t h e d i s k s u r f a c e a t   b a n d w i d t h  

r o t 

L e t  b 

i ; j 

d e n o t e t h e b l o c k t o b e r e t r i e v e d f r o m d i s k   i  i n r o u n d   j  . T h e n t h e p i p e l i n i n g t e c h n i q u e s c h e d u l e s t h e S C S I  

b u s a s f o l l o w s .  

f o r 0     i    D    1 

R e q u e s t L o a d I n t o D i s k B u e r (  b 

i ;  0 

) o n d i s k   i 

f o r 0     j    N u m R e q u e s t s  

f o r 0     i    D    1 

R e a d (  b 

i ; j 

) f r o m d i s k   i  / /  B l o c k s   b 

i ; j 

a r e a l r e a d y i n d i s k b u e r  

R e q u e s t L o a d I n t o D i s k B u e r (  b 

i ; j  + 1 

) o n d i s k   i 

W e a s s u m e t h a t e a c h d i s k d r i v e b e g i n s p r e f e t c h i n g d a t a i n t o i t s c a c h e a s s o o n a s i t r e c e i v e s t h e L o a d I n t o D i s k B u e r  

c o m m a n d . T h e p r e f e t c h i n g i s o v e r l a p p e d w i t h t h e b u s t r a n s m i s s i o n o f b l o c k s f r o m o t h e r d i s k s a n d t h e p r e v i o u s r o u n d .  

T h i s t e c h n i q u e g i v e s u s a s i m p l e w a y t o h i d e d i s k l a t e n c y , e n s u r i n g f a i r p a r a l l e l I / O i n r o u n d s . R a n d o m b l o c k s a r e  

r e t r i e v e d f r o m e a c h d i s k a t c l o s e t o t h e S C S I b u s b a n d w i d t h .  

I n a s e n s e , w e a r e u s i n g t h e d i s k c a c h e s a s a n e x t e n s i o n o f t h e c o m p u t e r ' s m a i n m e m o r y . B u t w e w o u l d n o t a c h i e v e  

t h e s a m e p e r f o r m a n c e g a i n b y a d d i n g m a i n m e m o r y i n t h e c o m p u t e r a n d u s i n g d o u b l e - b u e r e d I / O . D o u b l e b u e r i n g  

o v e r l a p s I / O w i t h c o m p u t a t i o n , b u t d o e s n o t d e c r e a s e t h e t i m e r e q u i r e d f o r t h e I / O . O u r p i p e l i n i n g t e c h n i q u e e e c t s  

a n e x p l i c i t s c h e d u l i n g o f t h e S C S I b u s , t o o v e r l a p v a r i o u s o p e r a t i o n s w i t h i n t h e I / O s u b s y s t e m , t h e r e b y s h o r t e n i n g  

t h e t i m e r e q u i r e d t o c o m p l e t e t h e I / O . I n p a r t i c u l a r , w e o v e r l a p t h e b u s t r a n s f e r w i t h t h e r a n d o m a c c e s s l a t e n c y , a n d  

c a u s e t h e b u s t r a n s f e r t o o c c u r a t t h e h i g h e r c a c h e d a t a r a t e , r a t h e r t h a n t h e s l o w e r d i s k - h e a d r a t e .  

A n i d e a l i m p l e m e n t a t i o n o f o u r p i p e l i n i n g t e c h n i q u e w o u l d u s e o n e S C S I c o m m a n d t o e x e c u t e t h e L o a d I n -  

t o D i s k B u e r s t e p . I n d e e d , t h e r e i s s u c h a c o m m a n d ; i t i s c a l l e d t h e   S C S I P r e f e t c h  . U n f o r t u n a t e l y , i t i s a n o p t i o n a l  

c o m m a n d , a n d i s n o t s u p p o r t e d b y t h e W r e n , B a r r a c u d a , o r C h e e t a h . B u t n e a r l y a l l d i s k s s u p p o r t c a c h e r e a d a h e a d ,  

1 7 6 

Page 190: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 190/203

T a b l e 6 . 1 9  : M B / s f o r n a i v e a n d p i p e l i n e d I / O , f e n c e 0 , W r e n / S u n S p a r c - 2 0 .  

B l o c k s i z e   D  = 2  D  = 4  D  = 7 

( K B ) N a i v e P i p e l i n e % N a i v e P i p e l i n e % N a i v e P i p e l i n e %  

8 0 . 5 2 0 . 4 8 - 8 0 . 9 7 0 . 8 5 - 1 3 1 . 4 3 1 . 2 2 - 1 5  

1 6 0 . 8 9 0 . 8 3 - 7 1 . 5 3 1 . 4 9 - 3 1 . 8 9 1 . 9 3 2  

3 2 1 . 3 7 1 . 4 0 2 1 . 9 7 2 . 1 9 1 1 2 . 3 5 2 . 4 5 4  

6 4 1 . 8 8 2 . 0 5 9 2 . 4 2 2 . 7 2 1 2 2 . 8 0 2 . 9 8 6  

9 6 2 . 1 5 2 . 4 2 1 3 2 . 6 5 2 . 8 9 9 3 . 0 0 3 . 0 9 3  

1 2 8 2 . 2 6 2 . 5 3 1 2 2 . 6 8 2 . 9 8 1 1 2 . 9 3 2 . 9 0 - 1  

a n d a t t h e c o s t o f s o m e o v e r h e a d , w e c a n t r i g g e r t h e r e a d a h e a d t o a c h i e v e t h e e e c t o f a S C S I p r e f e t c h . T h e o v e r h e a d  

o f t r i g g e r i n g t h e r e a d a h e a d i s n o n - n e g l i g i b l e . T h e e x p e r i m e n t a l r e s u l t s d e s c r i b e d b e l o w i n d i c a t e t h e c o n d i t i o n s u n d e r  

w h i c h t h e p e r f o r m a n c e g a i n f r o m p i p e l i n i n g o u t w e i g h s t h e a d d i t i o n a l o v e r h e a d .  

F o r m a n y d i s k s , w e i m p l e m e n t t h e L o a d I n t o D i s k B u e r f o r b l o c k   b  b y a n o n - b l o c k i n g a s y n c h r o n o u s r e a d o f t h e  

d i s k s e c t o r j u s t b e f o r e   b  . T h e a s y n c h r o n o u s r e a d t r i g g e r s t h e d i s k c a c h e r e a d a h e a d m e c h a n i s m t o l o a d   b  i n t o t h e  

d i s k c a c h e . I n t h e   i  t h i t e r a t i o n o f t h e f o r l o o p , d u r i n g t h e   j  t h r o u n d o f I / O , t o c a u s e a L o a d I n t o D i s k B u e r (  b 

i ; j  + 1 

) , 

o u r i m p l e m e n t a t i o n u s e s t h e   a i o r e a d ( )   s y s t e m c a l l t o s e n d a 1 - s e c t o r n o n - b l o c k i n g r e a d f o r t h e s e c t o r i m m e d i a t e l y  

p r e c e d i n g b l o c k   b 

i ; j  + 1 

o f d i s k   i  . I n t h e n e x t r o u n d , b l o c k   b 

i ; j  + 1 

o n d i s k   i  w i l l b e f o u n d i n t h e d i s k ' s c a c h e .  

T a b l e 6 . 1 9 e v a l u a t e s t h e e e c t i v e n e s s o f t h e p i p e l i n i n g t e c h n i q u e w i t h 2 , 4 , a n d 7 W r e n d i s k s o n a S p a r c - 2 0 ,  

u s i n g t r a n s f e r s r a n g i n g f r o m 8 K B t o 1 2 8 K B . T h e m e a s u r e m e n t s a r e a v e r a g e d o v e r 1 0 0 0 I / O s  

. T h e t a b l e c o m p a r e s  

t h e a g g r e g a t e t r a n s f e r r a t e i n M B / s a c h i e v e d b y t h e \ n a i v e " a p p r o a c h ( o n e p r o c e s s p e r d i s k p e r f o r m i n g r a n d o m  

I / O s ) w i t h t h e p i p e l i n e d t e c h n i q u e . T h e c o l u m n l a b e l e d \ % " c o n t a i n s t h e r e l a t i v e i m p r o v e m e n t ( i n p e r c e n t ) o f t h e  

p i p e l i n e d t e c h n i q u e . P e r f o r m a n c e i n t h e e x p e r i m e n t s w i t h s m a l l b l o c k s i z e s i s i n h i b i t e d b y u n h i d d e n p o s i t i o n i n g  

t i m e ; t h i s h a r m s p e r f o r m a n c e b y s e v e r a l p e r c e n t . W i t h 7 d i s k s , t h e b u s i s s o o v e r l o a d e d t h a t t h e r e i s l i t t l e r o o m f o r  

i m p r o v e m e n t . W i t h 2 o r 4 d i s k s a n d m o d e r a t e o r l a r g e b l o c k s i z e s , t h e o v e r l a p s g a i n e d b y t h e p i p e l i n e t e c h n i q u e m o r e  

t h a n c o m p e n s a t e f o r t h e i n c r e a s e d o v e r h e a d . F o r e x a m p l e , w i t h 4 d i s k s a n d 6 4 K B b l o c k s , t h e b a n d w i d t h i m p r o v e s  

f r o m 2 . 4 2 M B / s t o 2 . 7 2 M B / s .  

T a b l e 6 . 2 0 p r e s e n t s t h e r e s u l t s o f t h e c o r r e s p o n d i n g e x p e r i m e n t o n t h e D E C A l p h a w i t h S e a g a t e B a r r a c u d a  

d i s k s . T h e m e a s u r e m e n t s a r e a v e r a g e d o v e r 3 0 0 I / O s ; t h i s n u m b e r o f I / O s i s s m a l l e n o u g h t o t w i t h i n t h e l i m i t e d  

n u m b e r o f u n c l a i m e d   a i o r e a d ( )   s t r u c t u r e s t u b s i n D i g i t a l U n i x . F o r l a r g e t r a n s f e r s a n d m a n y d i s k s s h a r i n g t h e  

b u s , t h e t h r o u g h p u t g a i n a c h i e v e d b y t h e p i p e l i n i n g t e c h n i q u e i s g r e a t e r t h a n t h e o v e r h e a d o f t h e a s y n c h r o n o u s I / O  

o p e r a t i o n s .  

W h e n w e r u n t h e s a m e s e t o f e x p e r i m e n t s o n t h e C h e e t a h d i s k s o n a S u n S p a r c - 2 0 , w e d o n o t s e e i m p r o v e m e n t s  

w i t h t h e p i p e l i n i n g m e t h o d . W e a t t r i b u t e t h i s t o t h e h o s t o v e r h e a d f o r t h e   a i o r e a d ( )   c o m m a n d , w h i c h w e m e a s u r e  

t o b e 2 . 1 { 2 . 3 m s ( a p p r o x i m a t e l y e q u i v a l e n t t o t h e a m o u n t o f t i m e n e e d e d t o r e a d 1 6 { 3 2 K B f r o m d i s k c a c h e t o h o s t ) .  

A s s h o w n i n T a b l e 6 . 2 1 , t h e f a s t e r S u n U l t r a - 1 r e d u c e s t h e o v e r h e a d s u c i e n t l y t o m a k e t h e p i p e l i n i n g t e c h n i q u e  

W e a l s o p e r f o r m e d e x p e r i m e n t s w i t h 3 0 0 I / O s f o r m o s t o f o u r h a r d w a r e c o n g u r a t i o n s a n d r e c e i v e d  

s i m i l a r n u m b e r s .  

1 7 7 

Page 191: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 191/203

T a b l e 6 . 2 0  : M B / s f o r n a i v e a n d p i p e l i n e d I / O , f e n c e 0 , B a r r a c u d a / D E C A l p h a .  

B l o c k s i z e   D  = 2  D  = 3  D  = 4 

( K B ) N a i v e P i p e l i n e % N a i v e P i p e l i n e % N a i v e P i p e l i n e %  

8 1 . 0 5 0 . 9 3 - 1 1 1 . 5 8 1 . 3 6 - 1 3 2 . 1 0 1 . 7 8 - 1 5  

1 6 1 . 9 6 1 . 7 5 - 1 1 2 . 9 5 2 . 6 2 - 1 1 3 . 9 0 3 . 3 0 - 1 5  

3 2 3 . 4 9 3 . 1 5 - 1 0 5 . 1 8 4 . 6 6 - 1 0 6 . 7 8 6 . 0 6 - 1 1  

6 4 5 . 5 1 5 . 1 9 - 6 7 . 9 7 7 . 4 3 - 7 9 . 7 6 9 . 9 2 2  

9 6 6 . 8 7 6 . 4 8 - 7 9 . 5 8 9 . 6 9 1 1 1 . 2 5 1 2 . 5 1 1 1  

1 2 8 7 . 8 7 7 . 6 0 - 3 1 0 . 3 5 1 1 . 1 9 8 1 2 . 1 3 1 4 . 4 0 1 9  

T a b l e 6 . 2 1   : M B / s f o r n a i v e a n d p i p e l i n e d I / O , f e n c e 0 , C h e e t a h / S u n U l t r a - 1 .  

B l o c k s i z e   D  = 2  D  = 3  D  = 4 

( K B ) N a i v e P i p e l i n e % N a i v e P i p e l i n e % N a i v e P i p e l i n e %  

8 1 . 3 2 1 . 2 2 - 8 1 . 9 7 1 . 7 4 - 1 2 2 . 6 3 2 . 3 0 - 1 3  

1 6 2 . 4 8 2 . 3 4 - 6 3 . 6 5 3 . 3 1 - 9 4 . 8 3 4 . 2 8 - 1 1  

3 2 4 . 4 3 4 . 2 7 - 4 6 . 3 2 6 . 0 7 - 4 8 . 0 2 7 . 7 5 - 3  

6 4 7 . 0 8 7 . 0 9 0 9 . 3 8 1 0 . 0 5 7 1 0 . 7 2 1 2 . 4 8 1 6  

9 6 8 . 7 6 9 . 4 8 8 1 0 . 8 5 1 2 . 7 6 1 8 1 2 . 0 9 1 4 . 1 2 1 7  

1 2 8 9 . 8 6 1 1 . 0 1 1 2 1 1 . 7 9 1 4 . 1 9 2 0 1 3 . 0 0 1 4 . 4 5 1 1  

v i a b l e f o r l a r g e b l o c k s i z e s . T h e m e a s u r e m e n t s a r e a v e r a g e d o v e r 1 0 0 0 I / O s . I f t h e d i s k s s u p p o r t e d   S C S I p r e f e t c h  

w i t h a c o m m a n d o v e r h e a d e q u a l t o t h a t o f a s e e k , w e w o u l d e x p e c t t o s e e i m p r o v e m e n t s o f 1 0 { 3 0 % f o r p i p e l i n i n g  

o v e r t h e n a i v e m e t h o d . M o r e o v e r , a s C P U s p e e d s i n c r e a s e i n t h e f u t u r e , a w i d e r v a r i e t y o f w o r k l o a d s m a y b e n e t  

f r o m p i p e l i n i n g .  

C o n s i d e r t h e I / O r e q u e s t s g e n e r a t e d b y I / O - i n t e n s i v e a l g o r i t h m s w i t h   D  p r o c e s s e s o r t h r e a d s r u n n i n g o n m u l t i -  

p r o c e s s o r s o r u n i p r o c e s s o r s . T h e s e I / O r e q u e s t s a l l f u n n e l t h r o u g h t h e d i s k d e v i c e d r i v e r c o d e . D e p e n d i n g u p o n t h e  

I / O s i z e s a n d t h e d i s k c o n g u r a t i o n , i t m a y b e p o s s i b l e t o i m p r o v e t h e p e r f o r m a n c e o f s u c h a l g o r i t h m s b y i n t e r p o s i n g  

a n I / O s c h e d u l i n g t h r e a d t h a t c a u s e s p i p e l i n i n g b y i s s u i n g t h e a p p r o p r i a t e L o a d I n t o D i s k B u e r o p e r a t i o n s . S i m i l a r l y ,  

i t m a y b e p o s s i b l e t o i m p r o v e t h e p e r f o r m a n c e o f a R A I D d i s k a r r a y b y a n i n t e r n a l i m p l e m e n t a t i o n o f t h i s p i p e l i n i n g  

t e c h n i q u e .  

6 . 1 0 C o n c l u s i o n s a n d F u t u r e W o r k      

B a s e d u p o n a n e x t e n s i v e s e r i e s o f m e a s u r e m e n t s , w e h a v e d e v e l o p e d a c c u r a t e m o d e l s o f t h e I / O t h r o u g h p u t a c h i e v e d  

b y m u l t i p l e d i s k s t h a t s h a r e a S C S I b u s f o r a b a l a n c e d r a n d o m - a c c e s s w o r k l o a d .  

T h e p e r f o r m a n c e a d v a n t a g e o f s c h e d u l i n g w i t h i n t h e r e q u e s t q u e u e f o r e a c h d i s k i s w e l l k n o w n . W e h a v e s h o w n  

t h a t c o o r d i n a t i n g t h e a c c e s s e s   a c r o s s   a c o l l e c t i o n o f d i s k s t h a t s h a r e a S C S I b u s c a n a l s o i m p r o v e p e r f o r m a n c e b y  

1 0 { 2 0 % . T h i s c o o r d i n a t i o n a c r o s s d i s k s d o e s n o t h a v e t h e N P - h a r d c o m p l e x i t y o f g e n e r a l s c h e d u l i n g . M o r e o v e r , o u r  

t e c h n i q u e e n a b l e s t h e d i s k s t o b e s e l f - g o v e r n i n g , i n t h a t w e d o n o t n e e d t o p r e d i c t t h e p o s i t i o n i n g t i m e t h a t w i l l b e  

i n c u r r e d b y e a c h I / O r e q u e s t .  

W e h a v e u s e d o u r p e r f o r m a n c e m o d e l s t o d e v e l o p a p i p e l i n i n g t e c h n i q u e a n d h a v e d e s c r i b e d t h e c i r c u m s t a n c e s  

u n d e r w h i c h i t i m p r o v e s t h e a g g r e g a t e d i s k b a n d w i d t h o n t h e s h a r e d S C S I b u s . T h e i m p r o v e m e n t i s a c o n s e q u e n c e  

1 7 8 

Page 192: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 192/203

o f i n c r e a s e d o v e r l a p b e t w e e n d i s k s e e k s a n d d a t a t r a n s f e r s , a n d a n i n c r e a s e i n t h e f r a c t i o n o f t r a n s f e r s t h a t o c c u r a t  

t h e d i s k c a c h e t r a n s f e r r a t e r a t h e r t h a n t h e s l o w e r d i s k - h e a d r a t e .  

W e p e r f o r m e d p r e l i m i n a r y e x p e r i m e n t s t h a t i n d i c a t e t h a t t h e m o d e l r e m a i n s a c c u r a t e w h e n t h e w o r k l o a d e x h i b i t s  

s p a t i a l l o c a l i t y o r h a s m u l t i p l e r e q u e s t s i z e s .  

I n e a c h o f o u r e x p e r i m e n t s t h e r e i s a t m o s t o n e r e q u e s t i n t h e I / O p a t h f o r e a c h d i s k . A s f u t u r e w o r k , w e  

w o u l d l i k e t o e x t e n d o u r t e c h n i q u e t o i n c o r p o r a t e t h e a d v a n t a g e s o f d i s k c o n t r o l l e r c o m m a n d q u e u i n g t o s c h e d u l e  

m u l t i p l e r e q u e s t s p e r d i s k . P r e l i m i n a r y e x p e r i m e n t s s u g g e s t t h a t o u r p i p e l i n i n g t e c h n i q u e m a y b e b e n e c i a l i n t h i s  

e n v i r o n m e n t t o o . T h i s t e c h n i q u e c o u l d b e b e n e c i a l f o r a p p l i c a t i o n s t h a t c a n g e n e r a t e b a t c h e s o f r e q u e s t s f o r e a c h  

d i s k s u c h a s v i d e o - o n - d e m a n d s e r v e r s . W e w o u l d a l s o l i k e t o m o d e l w r i t e r e q u e s t s ; w r i t e s a r e m o r e d i c u l t t o m o d e l  

b e c a u s e o f t h e c o m p l e x i t y o f t h e w r i t e - t o - d i s k p o l i c i e s . O u r m o d e l c o u l d a l s o b e e x t e n d e d t o a p p r o x i m a t e w a l l c l o c k  

t i m e i n a I / O s y s t e m - d e p e n d e n t f a s h i o n , f u r t h e r i n g t h e r e s u l t s o f C H 9 6 ] .  

A A K 9 9 ] S u s a n n e A l b e r s , S a n j e e v A r o r a , a n d S a n j e e v K h a n n a . P a g e r e p l a c e m e n t f o r g e n e r a l c a c h i n g p r o b l e m s .  

P r o c . 1 0 t h A n n u a l S y m p o s i u m o n D i s c r e t e A l g o r i t h m s ( S O D A )  , 1 9 9 9 .  

A A M  

9 8 ] P a n k a j A g a r w a l , L a r s A r g e , T . M . M u r a l i , K a s t u r i V a r a d a r a j a n , a n d J e V i t t e r . I / o - e c i e n t a l g o r i t h m s  

f o r c o n t o u r l i n e e x t r a c t i o n a n d p l a n a r g r a p h b l o c k i n g .   P r o c . 9 t h S y m p o s i u m o n D i s c r e t e A l g o r i t h m s  

( S O D A )  , 1 9 9 8 .  

A B F 9 3 ] B a r u c h A w e r b u c h , Y a i r B a r t a l , a n d A m o s F i a t . H e a t a n d d u m p : R a n d o m i z e d c o m p e t i t i v e d i s t r i b u t e d  

p a g i n g . I n   P r o c . 3 4 t h I E E E S y m p . F o u n d a t i o n s o f C o m p u t e r S c i e n c e  , 1 9 9 3 .  

A B F 9 6 ] B a r u c h A w e r b u c h , Y a i r B a r t a l , a n d A m o s F i a t . D i s t r i b u t e d p a g i n g f o r g e n e r a l n e t w o r k s . I n   P r o c e e d i n g s  

8 t h A n n u a l A C M - S I A M S y m p o s i u m o n D i s c r e t e A l g o r i t h m s  , p a g e s 5 7 4 { 5 8 3 , 1 9 9 6 .  

A B W 9 8 ] J . A b e l l o , A . B u c h s b a u m , a n d J . W e s t b r o o k . A f u n c t i o n a l a p p r o a c h t o e x t e r n a l m e m o r y g r a p h a l g o -  

r i t h m s .   E x t e r n a l M e m o r y A l g o r i t h m s a n d V i s u a l i z a t i o n   , 1 9 9 8 .  

A B Z 9 6 ] M a t h e w A n d r e w s , M i c h a e l B e n d e r , a n d L i s a Z h a n g . N e w a l g o r i t h m s f o r t h e d i s k s c h e d u l i n g p r o b l e m .  

3 7 t h A n n u a l S y m p o s i u m o n F o u n d a t i o n s o f C o m p u t e r S c i e n c e ( F O C S )  , p a g e s 5 8 0 { 5 8 9 , O c t o b e r 1 9 9 6 .  

A D A D C  

9 7 ] A n d r e a C . A r p a c i - D u s s e a , R e m z i H . A r p a c i - D u s s e a u , D a v i d E . C u l l e r , J o s e p h M . H e l l e r s t e i n , a n d  

D a v i d A . P a t t e r s o n . H i g h - p e r f o r m a n c e s o r t i n g o n n e t w o r k s o f w o r k s t a t i o n s .   S I G M O D 9 7  , 1 9 9 7 .  

A F G V 9 8 ] L a r s A r g e , P a o l o F e r r a g i n a , R o b e r t o G r o s s i , a n d J e V i t t e r . O n s o r t i n g s t r i n g s i n e x t e r n a l m e m o r y .  

A C M S y m p o s i u m o n t h e T h e o r y o f C o m p u t i n g ( S T O C )  , 1 9 9 8 .  

1 7 9 

Page 193: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 193/203

A G L 9 8 ] S . A l b e r s , N . G a r g , a n d S . L e o n a r d i . M i n i m i z i n g s t a l l t i m e i n s i n g l e a n d p a r a l l e l d i s k s y s t e m s .   P r o c .  

3 0 t h A n n u a l A C M S y m p o s i u m o n T h e o r y o f C o m p u t i n g ( S T O C 9 8 )  , 1 9 9 8 .  

A H V V 9 9 ] L a r s A r g e , K l a u s H i n r i c h s , J a n V a h r e n h o l d , a n d J e V i t t e r . E c i e n t b u l k o p e r a t i o n s o n d y n a m i c  

r - t r e e s .   A L E N E X ' 9 9  , 1 9 9 9 .  

A K L 9 3 ] L . A r g e , M . K n u d s e n , a n d K . L a r s e n . A g e n e r a l l o w e r b o u n d o n t h e I / O - c o m p l e x i t y o f c o m p a r i s o n -  

b a s e d a l g o r i t h m s . I n   P r o c e e d i n g s o f t h e 3 r d W o r k s h o p o n A l g o r i t h m s a n d D a t a S t r u c t u r e s  , v o l u m e  

7 0 9 , p a g e s 8 3 { 9 4 . L e c t u r e N o t e s i n C o m p u t e r S c i e n c e , S p r i n g e r - V e r l a g , 1 9 9 3 .  

A l b 9 3 ] S . A l b e r s . T h e i n u e n c e o f l o o k a h e a d i n c o m p e t i t i v e p a g i n g a l g o r i t h m s . I n   P r o c e e d i n g s 1 s t A n n u a l  

E u r o p e a n S y m p o s i u n o n A l g o r i t h m s  , p a g e s 1 { 1 2 , 1 9 9 3 .  

A P 9 4 ] A l o k A g g a r w a l a n d C . G r e g P l a x t o n . O p t i m a l p a r a l l e l s o r t i n g i n m u l t i - l e v e l s t o r a g e .   P r o c . F i f t h  

A n n u a l A C M - S I A M S y m p . o n D i s c r e t e A l g o r i t h m s  , p a g e s 6 5 9 { 6 6 8 , 1 9 9 4 .  

A P R  

9 8 ] L a r s A r g e , O c t a v i a n P r o c o p i u c , S r i d h a r R a m a s w a m y , T o r s t e n S u e l , a n d J e V i t t e r . T h e o r y a n d p r a c -  

t i c e o f i / o - e c i e n t a l g o r i t h m s f o r m u l t i d i m e n s i o n a l b a t c h e d s e a r c h i n g p r o b l e m s .   P r o c . 9 t h S y m p o s i u m  

o n D i s c r e t e A l g o r i t h m s ( S O D A )  , 1 9 9 8 .  

A r g 9 4 ] L a r s A r g e . T h e b u e r t r e e : A n e w t e c h n i q u e f o r o p t i m a l I / O - a l g o r i t h m s . T e c h n i c a l R e p o r t R S - 9 4 - 1 6 ,  

B R I C S , U n i v . o f A a r h u s , D e n m a r k , 1 9 9 4 .  

A r g 9 6 ] L a r s A r g e .  E c i e n t E x t e r n a l - M e m o r y D a t a S t r u c t u r e s a n d A p p l i c a t i o n s  . P h D t h e s i s , D e p a r t m e n t o f  

C o m p u t e r S c i e n c e , U n i v e r s i t y o f A a r h u s , 1 9 9 6 .  

A r g 9 7 ] L . A r g e . E x t e r n a l - m e m o r y a l g o r i t h m s w i t h a p p l i c a t i o n s i n g e o g r a p h i c i n f o r m a t i o n s y s t e m s . I n M . v a n  

K r e v e l d , J . N i e v e r g e l t , T . R o o s , a n d P . W i d m a y e r , e d i t o r s ,   A l g o r i t h m i c F o u n d a t i o n s o f G I S   . S p r i n g e r -  

V e r l a g , L N C S 1 3 4 0 , 1 9 9 7 .  

A V 8 8 ] A l o k A g g a r w a l a n d J e r e y S . V i t t e r . T h e i n p u t / o u t p u t c o m p l e x i t y o f s o r t i n g a n d r e l a t e d p r o b l e m s .  

C o m m u n i c a t i o n s o f t h e A C M   , 3 1 ( 9 ) : 1 1 1 6 { 1 1 2 7 , 1 9 8 8 .  

A V 9 6 ] L . A r g e a n d J . S . V i t t e r . O p t i m a l i n t e r v a l m a n a g e m e n t i n e x t e r n a l m e m o r y .   P r o c . o f t h e 3 7 t h A n n u a l  

I E E E S y m p o s i u m o n F o u n d a t i o n s o f c o m p u t e r S c i e n c e ( F O C S ' 9 6 )  , p a g e s 5 6 0 { 5 6 9 , O c t o b e r 1 9 9 6 .  

A l s o a p p e a r e d i n A b s t r a c t s o f t h e F i r s t C G C W o r k s h o p o n C o m p u t a t i o n a l G e o m e t r y , C e n t e r f o r  

G e o m e t r i c C o m p u t i n g , J o h n s H o p k i n s u n i v e r s i t y , B a l t i m o r e , M D , O c t o b e r 1 9 9 6 .  

1 8 0 

Page 194: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 194/203

A V V a r ] L a r s A r g e , D a r r e n E r i k V e n g r o , a n d J e r e y S c o t t V i t t e r . E x t e r n a l - m e m o r y a l g o r i t h m s f o r p r o c e s s i n g  

l i n e s e g m e n t s i n g e o r g r a p h i c i n f o r m a t i o n s y s t e m s .   s p e c i a l i s s u e o n c a r t o g r a p h y a n d g e o g r a p h i c i n f o r -  

m a t i o n s y s t e m s i n A l g o r i t h m i c a  , t o a p p e a r . A s h o r t e n e d v e r s i o n a p p e a r s i n P r o c e e d i n g s o f t h e 3 r d  

A n n u a l E u r o p e a n S y m p o s i u m o n A l g o r i t h m s ( E S A ' 9 5 ) , S e p t e m b e r 1 9 9 5 , p u b l i s h e d i n L e c t u r e N o t e s  

i n C o m p u t e r S c i e n c e , S p r i n g e r - V e r l a g , B e r l i n , 2 9 5 { 3 1 0 .  

B C L 9 3 ] K . P . B r o w n , M . J . C a r e y , a n d M . L i v n y . M a n a g i n g m e m o r y t o m e e t m u l t i c l a s s w o r k l o a d r e s p o n s e  

t i m e g o a l s .   P r o c . 1 9 t h I n t . C o n f . o n V e r y L a r g e D a t a B a s e s  , A u g u s t 1 9 9 3 .  

B e l 6 6 ] A . L . B e l a d y . A s t u d y o f r e p l a c e m e n t a l g o r i t h m s f o r v i r t u a l s t o r a g e c o m p u t e r s .   I B M S y s t e m s J o u r n a l  , 

5 : 7 8 { 1 0 1 , 1 9 6 6 .  

B G H  

9 7 ] R a k e s h B a r v e , P h i l l i p B . G i b b o n s , B r u c e H i l l y e r , Y o s s i M a t i a s , E l i z a b e t h S h r i v e r , a n d J e r e y S c o t t  

V i t t e r . M o d e l i n g a n d o p t i m i z i n g I / O t h r o u g h p u t o f m u l t i p l e d i s k s o n a b u s : t h e l o n g v e r s i o n . T e c h n i c a l  

R e p o r t B L 9 7 . 0 1 5 7 8 , B e l l L a b s , 1 9 9 7 .  

B G H  

9 8 ] R a k e s h B a r v e , P h i l l i p B . G i b b o n s , B r u c e K . H i l l y e r , Y o s s i M a t i a s , E l i z a b e t h S h r i v e r , a n d J e r e y S c o t t  

V i t t e r . R o u n d - l i k e b e h a v i o r i n m u l t i p l e d i s k s o n a b u s : a s t u d y w i t h w r e n 7 d i s k s . T e c h n i c a l r e p o r t ,  

B e l l L a b s , O c t o b e r 1 9 9 8 .  

B G V 9 7 ] R a k e s h D . B a r v e , E d w a r d F . G r o v e , a n d J e r e y S c o t t V i t t e r . S i m p l e r a n d o m i z e d m e r g e s o r t o n p a r a l l e l  

d i s k s . 2 3 ( 4 ) , 1 9 9 7 . S p e c i a l i s s u e o n p a r a l l e l I / O . A n e a r l i e r v e r s i o n a p p e a r s i n P r o c . o f t h e 8 t h A n n u a l  

A C M S y m p o s i u m o n P a r a l l e l A l g o r i t h m s a n d A r c h i t e c t u r e s ( S P A A ' 9 6 ) , P a d u a , I t a l y , J u n e 1 9 9 6 ,  

1 0 9 { 1 1 8 .  

B I R S 9 1 ] A . B o r o d i n , S . I r a n i , P . R a g h a v a n , a n d B . S c h i e b e r . C o m p e t i t i v e p a g i n g w i t h l o c a l i t y o f r e f e r e n c e . I n  

P r o c e e d i n g s o f t h e 2 3 r d A n n u a l A C M S y m p o s i u m o n T h e o r y o f C o m p u t a t i o n  , M a y 1 9 9 1 .  

B K 9 8 ] G . S . B r o d a l a n d J . K a t a j a i n e n . W o r s t - c a s e e c i e n t e x t e r n a l - m e m o r y p r i o r i t y q u e u e s .   S c a n d i n a v i a n  

W o r k s h o p o n A l g o r i t h m i c T h e o r y  , 1 9 9 8 .  

B K V V 9 7 ] R a k e s h D . B a r v e , M a h e s h K a l l a h a l l a , P e t e r J . V a r m a n , a n d J . S . V i t t e r . C o m p e t i t i v e p a r a l l e l d i s k  

p r e f e t c h i n g a n d b u e r m a n a g e m e n t .   P r o c e e d i n g s o f t h e F i f t h A n n u a l W o r k s h o p o n I / O i n P a r a l l e l  

a n d D i s t r i b u t e d S y s t e m s ( I O P A D S )  , 1 9 9 7 .  

B r e 9 5 ] D a n y B r e s l a u e r . O n c o m p e t i t i v e o n l i n e p a g i n g w i t h l o o k a h e a d . ( R S - 9 5 - 5 0 ) , S e p t e m b e r 1 9 9 5 .  

B S G  

9 8 ] R a k e s h B a r v e , E l i z a b e t h S h r i v e r , P h i l l i p B . G i b b o n s , B r u c e K . H i l l y e r , Y o s s i M a t i a s , a n d J e r e y S c o t t  

V i t t e r . M o d e l i n g a n d o p t i m i z i n g I / O t h r o u g h p u t o f m u l t i p l e d i s k s o n a b u s . I n   J o i n t I n t e r n a t i o n a l  

1 8 1 

Page 195: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 195/203

C o n f e r e n c e o n M e a s u r e m e n t a n d M o d e l i n g o f C o m p u t e r S y s t e m s ( S i g m e t r i c s ' 9 8 / P e r f o r m a n c e ' 9 8 )  , 

J u n e 1 9 9 8 . E x t e n d e d a b s t r a c t .  

C A B G 9 8 ] J e r e y S . C h a s e , D a r r e l l A n d e r s o n , R a k e s h B a r v e , a n d S y a m G a d d e . I m p r o v i n g i / o p e r f o r m a n c e w i t h  

b l o c k e d l e m a p p i n g . 1 9 9 8 . I n S u b m i s s i o n .  

C F K L 9 5 ] P e i C a o , E d w a r d F e l t e n , A n n a K a r l i n , a n d K a i L i . A s t u d y o f i n t e g r a t e d p r e f e t c h i n g a n d c a c h i n g  

s t r a t e g i e s .   P r o c e e d i n g s o f t h e A C M S I G M E T R I C S C o n f e r e n c e o n M e a s u r e m e n t a n d M o d e l l i n g o f  

C o m p u t e r S y s t e m s  , M a y 1 9 9 5 .  

C F L 9 4 a ] P . C a o , E . W . F e l t e n , a n d K . L i . A p p l i c a t i o n - c o n t r o l l e d l e c a c h i n g p o l i c i e s . I n   P r o c e e d i n g s o f t h e  

S u m m e r U S E N I X C o n f e r e n c e  , 1 9 9 4 .  

C F L 9 4 b ] P . C a o , E . W . F e l t e n , a n d K . L i . I m p l e m e n t a t i o n a n d p e r f o r m a n c e o f a p p l i c a t i o n - c o n t o l l e d l e c a c h i n g .  

I n  P r o c e e d i n g s o f t h e F i r s t O S D I S y m p o s i u m   , 1 9 9 4 .  

C F M  

9 8 ] A . C r a u s e r , P . F e r r a g i n a , K . M e h l h o r n , U . M e y e r , a n d E . R a m o s . R a n d o m i z e d e x t e r n a l - m e m o r y a l g o -  

r i t h m s f o r g e o m e t r i c p r o b l e m s .   P r o c e e d i n g s o f t h e 1 4 t h A C M S y m p o s i u m o n C o m p u t a t i o n a l G e o m e t r y  , 

J u n e 1 9 9 8 .  

C G G  

9 5 ] Y . - J . C h i a n g , M . T . G o o d r i c h , E . F . G r o v e , R . T a m a s s i a , D . E . V e n g r o , a n d J . S . V i t t e r . E x t e r n a l -  

m e m o r y g r a p h a l g o r i t h m s . I n   P r o c e e d i n g s o f t h e S i x t h A n n u a l A C M - S I A M S y m p o s i u m o n D i s c r e t e  

A l g o r i t h m s  , J a n u a r y 1 9 9 5 .  

C H 9 6 ] T h o m a s H . C o r m e n a n d M e l i s s a H i r s c h l . E a r l y e x p e r i e n c e s i n e v a l u a t i n g t h e p a r a l l e l d i s k m o d e l w i t h  

t h e v i c * i m p l e m e n t a t i o n . T e c h n i c a l R e p o r t P C S - T R 9 6 - 2 9 3 , D e p t . o f C o m p u t e r S c i e n c e , D a r t m o u t h  

C o l l e g e , A u g u s t 1 9 9 6 .  

C h e 8 9 ] P . M . C h e n . A n e v a l u a t i o n o f r e d u n d a n t a r r a y s o f d i s k s u s i n g a n a m d a h l 5 8 9 0 . U C B / C S D 8 9 5 0 6 , U .  

C . B e r k e l e y , M a y 1 9 8 9 .  

C L G  

9 4 ] P e t e r M . C h e n , E d w a r d K . L e e , G a r t h A . G i b s o n , R a n d y H . K a t z , a n d D a v i d A . P a t t e r s o n . R A I D :  

h i g h - p e r f o r m a n c e , r e l i a b l e s e c o n d a r y s t o r a g e .   A C M C o m p u t i n g S u r v e y s  , 2 6 ( 2 ) : 1 4 5 { 1 8 5 , J u n e 1 9 9 4 .  

C L R 9 0 ] T h o m a s H . C o r m e n , C h a r l e s E . L e i s e r s o n , a n d R o n a l d L . R i v e s t .   I n t r o d u c t i o n t o A l g o r i t h m s  . T h e  

M I T P r e s s a n d M c G r a w - H i l l , 1 9 9 0 .  

C o r 8 9 ] C o n t r o l D a t a C o r p o r a t i o n . P r o d u c t s p e c i c a t i o n f o r w r e n v i i s c s i d i s k d r i v e m o d e l 9 4 6 0 1 .   S p e c .  

7 7 7 6 5 4 1 7 , R e v i s i o n A   , S e p t e m b e r 1 9 8 9 .  

1 8 2 

Page 196: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 196/203

C T 9 6 ] S h e n z e C h e n a n d M a n u T h a p a r . I / O c h a n n e l a n d r e a l - t i m e d i s k s c h e d u l i n g f o r v i d e o s e r v e r s . I n  

N O S S D A V ' 9 6  , 1 9 9 6 .  

D a h 9 6 ] M i k e D a h l i n . T h e i m p a c t o f t e c h n o l o g y t r e n d s o n l e s y s t e m d e s i g n .  

h t t p : / / w w w . c s . u t e x a s . e d u / u s e r s / d a h l i n / t e c h T r e n d s / t r e n d s . p s  , 1 9 9 6 .  

d J K H 9 3 ] W . d e J o n g e , M . F . K a a s h o e k , a n d W . C . H s i e h . T h e l o g i c a l d i s k : A n e w a p p r o a c h t o i m p r o v i n g  

l e s y s t e m s .   P r o c . o f t h e 1 4 t h A C M S y m p o s i u m o n O p e r a t i o n S y s t e m s P r i n c i p l e s ( S O S P )  , D e c e m b e r  

1 9 9 3 .  

E C W 9 4 ] V l a d i m i r E s t i v i l l - C a s t r o a n d D e r r i c k W o o d . F o u n d a t i o n s o f e x t e r n a l m e r g i n g .   P r o c . F o u r t e e n t h C o n -  

f e r e n c e o n F o u n d a t i o n s o f S o f t w a r e T e c h n o l o g y a n d T h e o r e t i c a l C o m p u t e r S c i e n c e  , p a g e s 4 1 4 { 4 2 5 ,  

1 9 9 4 .  

E S 9 2 ] R . M . E n g l i s h a n d A . A . S t e p a n o v . L o g e : A s e l f - o r g a n i z i n g s t o r a g e d e v i c e .   P r o c . o f t h e U S E N I X  

W i n t e r ' 9 2 T e c h n i c a l C o n f e r e n c e  , p a g e s 2 3 7 { 2 5 1 , 1 9 9 2 .  

F G 9 5 ] P . F e r r a g i n a a n d R . G r o s s i . A f u l l y - d y n a m i c d a t a s t r u c t u r e f o r e x t e r n a l s u b s t r i n g s e a r c h . I n   P r o c e e d i n g s  

o f t h e 2 7 t h A n n u a l A C M S y m p o s i u m o n T h e o r y o f C o m p u t a t i o n  , M a y 1 9 9 5 .  

F K 9 5 ] A . F i a t a n d A . K a r l i n . R a n d o m i z e d a n d m u l i - p o i n t e r p a g i n g w i t h l o c a l i t y o f r e f e r e n c e . I n   P r o c . o f t h e  

2 7 t h A n n u a l A C M S y m p . o n t h e T h e o r y o f c o m p u t i n g  , p a g e s 6 2 6 { 6 3 4 , 1 9 9 5 .  

F K L  

9 1 ] A . F i a t , R . M . K a r p , M . L u b y , L . A . M c G e o c h , D . D . S l e a t o r , a n d N . E . Y o u n g . O n c o m p e t i t i v e  

a l g o r i t h m s f o r p a g i n g p r o b l e m s .   J o u r n a l o f A l g o r i t h m s  , 1 2 : 6 8 5 { 6 9 9 , 1 9 9 1 .  

F l o 7 2 ] R . W . F l o y d . P e r m u t i n g i n f o r m a t i o n i n i d e a l i z e d t w o - l e v e l s t o r a g e . I n R . M i l l e r a n d J . T h a t c h e r ,  

e d i t o r s ,   C o m p l e x i t y o f C o m p u t e r C o m p u t a t i o n s  , p a g e s 1 0 5 { 1 0 9 . P l e n u m , 1 9 7 2 .  

F N G 8 9 ] D . F e r g u s o n , C . N i k o l a o u , a n d L . G e r g i a d i s . G o a l o r i e n t e d , a d a p t i v e t r a n s a c t i o n r o u t i n g f o r h i g h  

p e r f o r m a n c e t r a n s a c t i o n p r o c e s s i n g s y s t e m s .   P r o c . o f t h e 2 n d I n t . C o n f . o n P a r a l l e l a n d D i s t r i b u t e d  

I n f o r m a t i o n S y s t e m s  , J a n u a r y 1 9 8 9 .  

G K 8 1 ] D a n i e l H . G r e e n e a n d D o n a l d E . K n u t h .   M a t h e m a t i c s f o r t h e A n a l y s i s o f A l g o r i t h m s  . B i r k h  a u s e r ,  

B o s t o n . , 1 9 8 1 .  

G r a 9 3 ] G o e t z G r a e f e . Q u e r y e v a l u a t i o n t e c h n i q u e s f o r l a r g e d a t a b a s e s .   A C M C o m p u t i n g S u r v e y s  , 2 5 ( 2 ) : 7 3 {  

1 7 0 , 1 9 9 3 .  

G S 8 4 ] D . G i o r d a n d A . S p e c t o r . T h e T W A r e s e r v a t i o n s y s t e m .   C o m m . A C M   , 2 7 ( 7 ) : 6 5 0 { 6 6 5 , J u l y 1 9 8 4 .  

1 8 3 

Page 197: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 197/203

G T V V 9 3 ] M . T . G o o d r i c h , J . - J . T s a y , D . E . V e n g r o , a n d J . S . V i t t e r . E x t e r n a l - m e m o r y c o m p u t a t i o n a l g e o m e t r y .  

I n  I E E E F o u n d a t i o n s o f C o m p u t e r S c i e n c e  , p a g e s 7 1 4 { 7 2 3 , 1 9 9 3 .  

G V W 9 6 ] G . A . G i b s o n , J . S . V i t t e r , a n d J . W i l k e s . R e p o r t o f t h e w o r k i n g g r o u p o n s t o r a g e I / O i s s u e s  

i n l a r g e - s c a l e c o m p u t i n g .   A C M C o m p u t i n g S u r v e y s  , 2 8 ( 4 ) , D e c e m b e r 1 9 9 6 . A l s o a v a i l a b l e a s  

h t t p : / / w w w . c s . d u k e . e d u / ~ j s v / r e p o r t . p s  

H G K  

9 4 ] L . H e l l e r s t e i n , G . G i b s o n , R . M . K a r p , R . H . K a t z , a n d D . A . P a t t e r s o n . C o d i n g t e c h n i q u e s f o r  

h a n d l i n g f a i l u r e s i n l a r g e d i s k a r r a y s .   A l g o r i t h m i c a  , 1 2 ( 2 { 3 ) , 1 9 9 4 .  

H K 8 1 a ] J . W . H o n g a n d H . T . K u n g . I / O c o m p l e x i t y : T h e r e d - b l u e p e b b l e g a m e .   P r o c . 1 3 t h A n n u a l A C M  

S y m p . o n T h e o r y o f C o m p u t a t i o n  , p a g e s 3 2 6 { 3 3 3 , m a y 1 9 8 1 .  

H K 8 1 b ] J . W . H o n g a n d H . T . K u n g . I / O c o m p l e x i t y : T h e r e d - b l u e p e b b l e g a m e .   P r o c . 1 3 t h A n n u a l A C M  

S y m p . o n T h e o r y o f C o m p u t a t i o n  , p a g e s 3 2 6 { 3 3 3 , m a y 1 9 8 1 .  

H P 9 6 ] J o h n L . H e n n e s s y a n d D a v i d L . P a t t e r s o n .  C o m p u t e r A r c h i t e c t u r e : A Q u a n t i t a t i v e A p p r o a c h  . M o r g a n  

K a u f m a n n P u b l i s h e r s I n c . , 1 9 9 6 .  

I B M 9 0 ] I B M .  D A T A B A S E 2 , A d m i n i s t r a t i o n G u i d e f o r C o m m o n S e r v e r s  . J u n e 1 9 9 0 .  

I K P 9 2 ] S . I r a n i , A . R . K a r l i n , a n d S . P h i l l i p s . S t r o n g l y c o m p e t i t i v e a l g o r i t h m s f o r p a g i n g w i t h l o c a l i t y o f  

r e f e r e n c e . I n   P r o c e e d i n g s o f t h e 3 r d A n n u a l A C M - S I A M S y m p o s i u m o f D i s c r e t e A l g o r i t h m s  , J a n u a r y  

1 9 9 2 .  

I n c ] S e a g a t e T e c h n o l o g y I n c . S t - 3 4 5 0 1 w / w c u l t r a - s c s i w i d e ( c h e e t a h 4 l p ) d a t a s h e e t . F o u n d a t  

f t p : / / f t p . s e a g a t e . c o m / t e c h s u p p t / s c s i / s t 3 4 5 0 1 w . t x t .  

J W 9 1 ] D . M . J a c o b s o n a n d J . W i l k e s . D i s k s c h e d u l i n g a l g o r i t h m s b a s e d o n r o t a t i o n a l p o s i t i o n . T e c h n i c a l  

R e p o r t H P L { 9 1 { 7 , H e w l e t t - P a c k a r d L a b o r a t o r i e s , F e b r u a r y 1 9 9 1 .  

K k 9 6 ] T r a c y K i m b r e l a n d A n n a k a r l i n . N e a r - o p t i m a l p a r a l l e l p r e f e t c h i n g a n d c a c h i n g .   P r o c . o f t h e 3 7 t h  

A n n u a l I E E E S y m p o s i u m o n F o u n d a t i o n s o f c o m p u t e r S c i e n c e ( F O C S ' 9 6 )  , O c t o b e r 1 9 9 6 .  

K n u 9 7 ] D . E . K n u t h .   F u n d a m e n t a l A l g o r i t h m s  , v o l u m e 1 o f   T h e A r t o f C o m p u t e r P r o g r a m m i n g  . A d d i s o n -  

W e s l e y , R e a d i n g M a . , t h i r d e d i t i o n , 1 9 9 7 .  

K n u 9 8 ] D . E . K n u t h .  S o r t i n g a n d S e a r c h i n g  , v o l u m e 3 o f  T h e A r t o f C o m p u t e r P r o g r a m m i n g  . A d d i s o n - W e s l e y ,  

R e a d i n g M A , s e c o n d e d i t i o n , 1 9 9 8 .  

1 8 4 

Page 198: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 198/203

K o t 9 4 ] D a v i d K o t z . D i s k - d i r e c t e d i / o f o r m i m d m u l t i p r o c e s s o r s .   P r o c . o f 1 9 9 4 S y m p o s i u m o n O p e r a t i n g  

S y s t e m s D e s i g n a n d I m p l e m e n t a t i o n   , N o v e m b e r 1 9 9 4 .  

K P 9 4 ] E . K o u t s o u p i a s a n d C . P a p a d i m i t r i o u . B e y o n d c o m p e t i t i v e a n a l y s i s . I n   P r o c . o f t h e 3 5 t h A n n u a l  

I E E E F o u n d a t i o n s o f C o m p u t e r S c i e n c e  , p a g e s 3 9 4 { 4 0 0 , 1 9 9 4 .  

K P R 9 2 ] A . R . K a r l i n , S . J . P h i l l i p s , a n d P . R a g h a v a n . M a r k o v p a g i n g . I n   P r o c e e d i n g s o f t h e 3 3 r d A n n u a l  

I E E E C o n f e r e n c e o n F o u n d a t i o n s o f C o m p u t e r S c i e n c e  , p a g e s 2 0 8 { 2 1 7 , O c t o b e r 1 9 9 2 .  

K S 9 6 ] V . K u m a r a n d E . S c h w a b e . I m p r o v e d a l g o r i t h m s a n d d a t a s t r u c t u r e s f o r s o l v i n g g r a p h p r o b l e m s i n  

e x t e r n a l m e m o r y .   P r o c e e d i n g s o f t h e 8 t h I E E E S y m p o s i u m o n P a r a l l e l a n d D i s t r i b u t e d P r o c e s s i n g  , 

p a g e s 1 6 9 { 1 7 6 , O c t o b e r 1 9 9 6 .  

K S C 7 8 ] V . F . K o l c h i n , B . A . S e v a s t y a n o v , a n d V . P . C h i s t y a k o v .   R a n d o m A l l o c a t i o n s  . W i n s t o n & S o n s ,  

W a s h i n g t o n , 1 9 7 8 .  

K T P  

9 6 ] T r a c y K i m b r e l , A n d r e w T o m k i n s , R . H u g o P a t t e r s o n , B r i a n B e r s h a d , P e i C a o , E d w a r d F e l t e n , G a r t h  

G i b s o n , A n n a R . K a r l i n , a n d K a i L i . A t r a c e - d r i v e n c o m p a r i s o n s o f a l g o r i t h m s f o r p a r a l l e l p r e f e t c h i n g  

a n d c a c h i n g .   P r o c . o f t h e 1 9 9 6 S y m p o s i u m o n O p e r a t i n g S y s t e m s D e s i g n a n d I m p l e m e n t a t i o n  , 1 9 9 6 .  

L G 9 8 ] P . - A . L a r s o n a n d G o e t z G r a e f e . M e m o r y m a n a g e m e n t d u r i n g r u n g e n e r a t i o n i n e x t e r n a l s o r t i n g .  

S I G M O D 9 8  , J u n e 1 9 9 8 .  

L V 8 5 ] E . E . L i n d s t r o m a n d J . S . V i t t e r . T h e d e s i g n a n d a n a l y s i s o f b u c k e t s o r t f o r b u b b l e m e m o r y s e c o n d a r y  

s t o r a g e .   I E E E T r a n s a c t i o n s o n C o m p u t e r s  , C - 3 4 : 2 1 8 { 2 3 3 , M a r c h 1 9 8 5 .  

M a g 8 7 ] N . B . M a g i n n i s . S t o r e m o r e , s p e n d l e s s : M i d - r a n g e o p t i o n s a b o u n d .   C o m p u t e r w o r l d  , p a g e s 7 1 { 8 2 ,  

N o v e m b e r 1 9 8 7 .  

M D K 9 6 ] T o d d C . M o w r y , A n g e l a K . D e m k e , a n d O r r a n K r i e g e r . A u t o m a t i c c o m p i l e r - i n s e r t e d i / o p r e f e t c h i n g  

f o r o u t - o f - c o r e a p p l i c a t i o n s .   P r o c . o f t h e 1 9 9 6 S y m p o s i u m o n O p e r a t i n g S y s t e m s D e s i g n a n d I m p l e -  

m e n t a t i o n   , 1 9 9 6 .  

M K 9 1 ] L . W . M c V o y a n d S . R . K l e i m a n . E x t e n t - l i k e p e r f o r m a n c e f r o m a u n i x l e s y s t e m . I n   P r o c e e d i n g s  

W i n t e r U s e n i x 1 9 9 1 , D a l l a s , T e x a s  , 1 9 9 1 .  

M N O  

9 8 ] C . M a r t i n , P . S . N a r a y a n , B . O z d e n , R . R a s t o g i , a n d A . S i l b e r s c h a t z . T h e f e l l i n i m u l t i m e d i a s t o r a g e  

s y s t e m .   J o u r n a l o f D i g i t a l L i b r a r i e s  , 1 9 9 8 . T o A p p e a r .  

1 8 5 

Page 199: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 199/203

M S 9 1 ] L . A . M c G e o c h a n d D . D . S l e a t o r . A s t r o n g l y c o m p e t i t i v e r a n d o m i z e d p a g i n g a l g o r i t h m .   A l g o r i t h m i c a  , 

6 : 8 1 6 { 8 2 5 , 1 9 9 1 .  

N i e 9 8 ] N i l s N i e u w e j a a r . P e r s o n a l C o m m u n i c a t i o n . 1 9 9 8 .  

N u t 9 7 ] G a r y N u t t .  O p e r a t i n g S y s t e m s : A M o d e r n P e r s p e c t i v e  . A d d i s o n - W e s l e y P u b l i s h i n g C o m p a n y , 1 9 9 7 .  

N V 9 0 ] M . H . N o d i n e a n d J . S . V i t t e r . L a r g e - s c a l e s o r t i n g i n p a r a l l e l m e m o r i e s . I n   P r o c . 3 r d A C M S y m p . o n  

P a r a l l e l A l g o r i t h m s a n d A r c h i t e c t u r e s  , p a g e s 2 9 { 3 9 , 1 9 9 0 .  

N V 9 3 ] M . H . N o d i n e a n d J . S . V i t t e r . D e t e r m i n i s t i c d i s t r i b u t i o n s o r t i n s h a r e d a n d d i s t r i b u t e d m e m o r y  

m u l t i p r o c e s s o r s .   P r o c . 5 t h A n n u a l A C M S y m p . o n P a r a l l e l A l g o r i t h m s a n d A r c h i t e c t u r e s  , p a g e s 1 2 0 {  

1 2 9 , 1 9 9 3 .  

N V 9 5 ] M . H . N o d i n e a n d J . S . V i t t e r . G r e e d s o r t : A n o p t i m a l s o r t i n g a l g o r i t h m f o r m u l t i p l e d i s k s .   J o u r n a l  

o f t h e A C M   , 4 2 ( 4 ) : 9 1 9 { 9 3 3 , J u l y 1 9 9 5 .  

P C L 9 3 a ] H . P a n g , M . C a r e y , a n d M . L i v n y . M e m o r y - a d a p t i v e e x t e r n a l s o r t s .   P r o c . N i n e t e e n t h I n t e r n a t i o n a l  

C o n f . o n V e r y L a r g e D a t a B a s e s  , 1 9 9 3 .  

P C L 9 3 b ] H . P a n g , M . J . C a r e y , a n d M . L i v n y . P a r t i a l l y p r e e m p t i b l e h a s h j o i n s .   P r o c . 1 9 9 3 A C M - S I G M O D  

C o n f . o n M a n a g e m e n t o f D a t a  , 1 9 9 3 .  

P E K 9 6 ] A . P u r a k a y a s t h a , C . S . E l l i s , a n d D . K o t z . E n w r i c h : A c o m p u t e - p r o c e s s o r w r i t e c a c h i n g s c h e m e f o r  

p a r a l l e l l e s y s t e m s .   F o u r t h W o r k s h o p o n I m p u t / O u t p u t i n P a r a l l e l a n d D i s t r i b u t e d S y s t e m s  , M a y  

1 9 9 6 .  

P G K 8 8 ] D . A . P a t t e r s o n , G . G i b s o n , a n d R . H . K a t z . A c a s e f o r r e d u n d a n t a r r a y s o f i n e x p e n s i v e d i s k s ( r a i d ) .  

P r o c . 1 9 8 8 A C M - S I G M O D C o n f . o n M a n a g e m e n t o f D a t a  , p a g e s 1 0 9 { 1 1 6 , 1 9 8 8 .  

P S V 9 4 ] V . S . P a i , A . A . S c h a e r , a n d P . J . V a r m a n . M a r k o v a n a l y s i s o f m u l t i p l e - d i s k p r e f e t c h i n g s t r a t e g i e s  

f o r e x t e r n a l m e r g i n g .   T h e o r e t i c a l C o m p u t e r S c i e n c e  , 1 2 8 ( 2 ) : 2 1 1 { 2 3 9 , J u n e 1 9 9 4 .  

P V 9 2 ] V . S . P a i a n d P . J . V a r m a n . P r e f e t c h i n g w i t h m u l t i p l e d i s k s f o r e x t e r n a l m e r g e s o r t : S i m u l a t i o n a n d  

a n a l y s i s . I n   8 t h I n t e r n a t i o n a l C o n f e r e n c e o f D a t a b a s e E n g i n e e r i n g   , p a g e s 2 7 3 { 1 8 2 , 1 9 9 2 .  

R e c 8 8 ] S I G M O D R e c o r d . S p e c i a l i s s u e o n r e a l - t i m e d a t a b a s e s y s t e m s . 1 7 ( 1 ) , M a r c h 1 9 8 8 .  

R S 9 4 ] S . R a m a s w a m y a n d S . S u b r a m a n i a n . P a t h c a c h i n g : a t e c h n i q u e f o r o p t i m a l e x t e r n a l s e a r c h i n g .   P r o c .  

1 3 t h A C M C o n f . o n P r i n c . o f D a t a b a s e S y s t e m s  , 1 9 9 4 .  

1 8 6 

Page 200: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 200/203

R W 9 1 ] C h r i s R u e m m l e r a n d J o h n W i l k e s . D i s k s h u i n g . T e c h n i c a l R e p o r t H P L { 9 1 { 1 5 6 , H e w l e t t - P a c k a r d  

L a b o r a t o r i e s , O c t o b e r 1 9 9 1 .  

R W 9 4 ] C . R u e m m l e r a n d J . W i l k e s . A n i n t r o d u c t i o n t o d i s k d r i v e m o d e l i n g .   I E E E C o m p u t e r  , p a g e s 1 7 { 2 8 ,  

M a r c h 1 9 9 4 .  

S a l 8 9 ] B . S a l z b e r g . M e r g i n g s o r t e d r u n s u s i n g l a r g e m a i n m e m o r y .   A c t a I n f o r m a t i c a   , 2 7 : 1 9 5 { 2 1 5 , 1 9 8 9 .  

S C O 9 0 ] M . S e l t z e r , P . C h e n , a n d J . O u s t e r h o u t . D i s k s c h e d u l i n g r e v i s i t e d .   P r o c . o f W i n t e r U S E N I X T e c h n i c a l  

C o n f e r e n c e  , p a g e s 3 1 3 { 3 2 3 , J a n u a r y 1 9 9 0 .  

S h r 9 7 ] E l i z a b e t h S h r i v e r .   P e r f o r m a n c e M o d e l l i n g F o r R e a l i s t i c S t o r a g e D e v i c e s  . P h . d . , N e w Y o r k U n i v e r s i t y ,  

M a y 1 9 9 7 . A v a i l a b l e a t h t t p : / / w w w . b e l l - l a b s . c o m / s h r i v e r .  

S T 8 5 ] D . D . S l e a t o r a n d R . E . T a r j a n . A m o r t i z e d e c i e n c y o f l i s t u p d a t e a n d p a g i n g r u l e s .   C o m m u n i c a t i o n s  

o f t h e A C M   , 2 8 ( 2 ) : 2 0 2 { 2 0 8 , F e b r u a r y 1 9 8 5 .  

S t o 8 1 ] M i c h a e l S t o n e b r a k e r . O p e r a t i n g s y s t e m s u p p o r t f o r d a t a b a s e m a n a g e m e n t .   C o m m u n i c a t i o n s o f t h e  

A C M  , 7 ( 2 4 ) , J u l y 1 9 8 1 .  

S T V 9 6 ] J . B . S i n c l a i r , J . T a n g , a n d P . J . V a r m a n . P l a c e m e n t - r e l a t e d p r o b l e m s i n s h a r e d d i s k i / o . I n R a v i  

J a i n , J o h n W e r t h , a n d J a m e s B r o w n e , e d i t o r s ,   I n p u t / O u t p u t i n P a r a l l e l a n d D i s t r i b u t e d C o m p u t e r  

S y s t e m s  . V o l u m e 3 6 2 , T h e K l u w e r I n t e r n a t i o n a l S e r i e s i n E n g i n e e r i n g a n d C o m p u t e r S c i e n c e , K l u w e r  

A c a d e m i c P u b l i s h e r s , 1 9 9 6 .  

S V 8 7 ] J . E . S a v a g e a n d J . S . V i t t e r . P a r a l l e l i s m i n s p a c e - t i m e t r a d e o s . I n F . P . P r e p a r a t a , e d i t o r ,   A d v a n c e s  

i n C o m p u t i n g R e s e a r c h , V o l u m e 4  , p a g e s 1 1 7 { 1 4 6 . J A I P r e s s , 1 9 8 7 .  

S y s 9 2 ] R e a l - T i m e S y s t e m s . S p e c i a l i s s u e o n r e a l - t i m e d a t a b a s e s . 4 ( 3 ) , S e p t e m b e r 1 9 9 2 .  

T e c 9 7 a ] S e a g a t e T e c h n o l o g i e s . C h e e t a h 4 l p f a m i l y : S t 3 4 5 0 1 n / w / w c / w d / d c .   P r o d u c t M a n u a l , v o l u m e 1 ,  

D o c u m e n t n u m b e r 8 3 3 2 9 1 2 0 , R e v i s i o n A   , A p r i l 1 9 9 7 .  

T e c 9 7 b ] S e a g a t e T e c h n o l o g i e s . S p e c i c a t i o n s f o r s t { 3 2 1 7 1 w .   h t t p : / / w w w . s e a g a t e . c o m /   , J u l y 1 9 9 7 .  

T o r 9 5 ] E r i c T o r n g . A u n i e d a n a l y s i s o f p a g i n g a n d c a c h i n g . I n   P r o c . o f t h e 3 6 t h A n n u a l I E E E F o u n d a t i o n s  

o f C o m p u t e r S c i e n c e  , p a g e s 1 9 4 { 2 0 3 , 1 9 9 5 .  

T P G 9 7 ] A n d r e w T o m k i n s , R . H u g o P a t t e r s o n , a n d G a r t h G i b s o n . I n f o r m e d m u l t i - p r o c e s s p r e f e t c h i n g a n d  

c a c h i n g .   P r o c e e d i n g s o f S I G M E T R I C S ' 9 7  , 1 9 9 7 .  

1 8 7 

Page 201: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 201/203

U n i 8 9 ] U n i v e r s i t y o f C a l i f o r n i a a t B e r k e l e y .   M a s s i v e I n f o r m a t i o n S t o r a g e , M a n a g e m e n t , a n d U s e ( N S F  

I n s t i t u t i o n a l I n f r a s t r u c t u r e P r o p o s a l )  , J a n u a r y 1 9 8 9 . T e c h n i c a l R e p o r t N o . U C B / C S D 8 9 / 4 9 3 .  

U W 9 7 ] J e r e y D . U l l m a n a n d J e n i e r W i d o m .   A F i r s t C o u r s e i n D a t a b a s e S y s t e m s  . P r e n t i c e H a l l , 1 9 9 7 .  

V C 9 0 ] P . V o n g s a t h o r n a n d S . D . C a r s o n . A s y s t e m f o r a d a p t i v e d i s k r e a r r a n g e m e n t .   S o f t w a r e { P r a c t i c e a n d  

E x p e r i e n c e  , 2 0 ( 3 ) : 2 2 5 { 2 4 2 , M a r c h 1 9 9 0 .  

V e n 9 4 ] D a r r e n E r i k V e n g r o . A t r a n s p a r e n t p a r a l l e l I / O e n v i r o n m e n t . I n   P r o c . 1 9 9 4 D A G S S y m p o s i u m o n  

P a r a l l e l C o m p u t a t i o n   , J u l y 1 9 9 4 .  

V e n 9 5 ] D a r r e n E r i k V e n g r o .  T P I E U s e r M a n u a l a n d R e f e r e n c e  . D u k e U n i v e r s i t y , 1 9 9 5 . A v a i l a b l e v i a W W W  

a t  h t t p : / / w w w . c s . d u k e . e d u : ~ d e v / t p i e . h t m l  

V e n 9 6 ] D a r r e n V e n g r o .   T h e T h e o r y a n d P r a c t i c e o f I /   O  A l g o r i t h m s  . P h . d . , B r o w n U n i v e r s i t y , 1 9 9 6 .  

V F 9 0 ] J . S . V i t t e r a n d P h . F l a j o l e t . A v e r a g e - c a s e a n a l y s i s o f a l g o r i t h m s a n d d a t a s t r u c t u r e s . I n J a n v a n  

L e e u w e n , e d i t o r ,   H a n d b o o k o f T h e o r e t i c a l C o m p u t e r S c i e n c e , V o l u m e A : A l g o r i t h m s a n d C o m p l e x i t y  , 

c h a p t e r 9 , p a g e s 4 3 1 { 5 2 4 . N o r t h - H o l l a n d , 1 9 9 0 .  

V i t 9 8 ] J e r e y S . V i t t e r . E x t e r n a l m e m o r y a l g o r i t h m s .   P r o c e e d i n g s o f t h e 1 7 t h A n n u a l A C M  

S y m p o s i u m o n P r i n c i p l e s o f D a t a b a s e S y s t e m s ( P O D S ' 9 8 )  , p a g e s 1 1 9 { 1 7 8 , 1 9 9 8 . S e e  

h t t p : / / w w w . c s . d u k e . e d u / j s v / b i b / j s v b i b o w n . b i b .  

V S 9 4 ] J . S . V i t t e r a n d E . A . M . S h r i v e r . A l g o r i t h m s f o r p a r a l l e l m e m o r y I : T w o - l e v e l m e m o r i e s .   A l g o r i t h m i c a  , 

1 2 ( 2 { 3 ) : 1 1 0 { 1 4 7 , 1 9 9 4 .  

V V 9 5 ] D a r r e n E r i k V e n g r o a n d J e r e y S c o t t V i t t e r . I / O - e c i e n t s c i e n t i c c o m p u t a t i o n u s i n g T P I E . T e c h -  

n i c a l R e p o r t C S { 1 9 9 5 { 1 8 , D u k e U n i v e r s i t y D e p t . o f C o m p u t e r S c i e n c e , 1 9 9 5 .  

V V 9 6 a ] D . E . V e n g r o a n d J . S . V i t t e r . E c i e n t 3 - d r a n g e s e a r c h i n g i n e x t e r n a l m e m o r y .   P r o c . o f t h e 2 8 t h  

A n n u a l A C M S y m p o s i u m o n T h e o r y o f C o m p u t i n g ( S T O C ' 9 6 )  , M a y 1 9 9 6 .  

V V 9 6 b ] D . E . V e n g r o a n d J . S . V i t t e r . I / O - e c i e n t c o m p u t a t i o n : T h e T P I E a p p r o a c h . I n   P r o c e e d i n g s o f t h e  

G o d d a r d C o n f e r e n c e o n M a s s S t o r a g e S y s t e m s a n d T e c h n o l o g i e s  , N A S A C o n f e r e n c e P u b l i c a t i o n 3 3 4 0 ,  

V o l u m e I I , p a g e s 5 5 3 { 5 7 0 , C o l l e g e P a r k , M D , S e p t e m b e r 1 9 9 6 .  

W G P 9 4 ] B r u c e L . W o r t h i n g t o n , G r e g o r y R . G a n g e r , a n d Y a l e N . P a t t . S c h e d u l i n g a l g o r i t h m s f o r m o d e r n d i s k  

d r i v e s .   P r o c e e d i n g s o f t h e A C M S i g m e t r i c s C o n f e r e n c e  , M a y 1 9 9 4 .  

1 8 8 

Page 202: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 202/203

W G P W 9 5 ] B r u c e L . W o r t h i n g t o n , G r e g o r y R . G a n g e r , Y a l e N . P a t t , a n d J o h n W i l k e s . O n - l i n e e x t r a c t i o n o f s c s i  

d i s k d r i v e p a r a m e t e r s .   P r o c e e d i n g s o f t h e A C M S i g m e t r i c s C o n f e r e n c e  , p a g e s 1 4 6 { 1 5 6 , M a y 1 9 9 5 .  

W G W R 9 3 ] D . W o m b l e , D . G r e e n b e r g , S . W h e a t , a n d R . R i e s e n . M a k i n g p a r a l l e l c o m p u t e r i / o p r a c t i c a l .   P r o -  

c e e d i n g s o f t h e 1 9 9 3 D A G S / P C S y m p o s i u m   , p a g e s 5 6 { 6 3 , J u n e 1 9 9 3 .  

Y o u 9 1 ] N e a l Y o u n g .   C o m p e t i t i v e P a g i n g a n d D u a l - G u i d e d O n l i n e W e i g h t e d C a c h i n g a n d M a t c h i n g A l g o -  

r i t h m s  . P h . d . , P r i n c e t o n U n i v e r s i t y , 1 9 9 1 .  

Y o u 9 8 ] N e a l E . Y o u n g . O n l i n e l e c a c h i n g .   A C M - S I A M S y m p o s i u m O n D i s c r e t e A l g o r i t h m s , ( S O D A )  , 1 9 9 8 .  

Z G 9 0 ] H . Z e l l e r a n d J . G r a y . A n a d a p t i v e h a s h j o i n a l g o r i t h m f o r m u l t i u s e r e n v i r o n m e n t s .   P r o c . o f t h e 1 6 t h  

I n t l . C o n f . o n V e r y L a r g e D a t a B a s e s  , 1 9 9 0 .  

Z L 9 6 ] L . Q . Z h e n g a n d P . - A . L a r s o n . S p e e d i n g u p e x t e r n a l m e r g e s o r t .   I E E E T r a n s . K n o w l d e g e a n d D a t a  

E n g i n e e r i n g  , 8 ( 2 ) : 3 2 2 { 3 3 2 , 1 9 9 6 .  

Z L 9 7 ] W . Z h a n g a n d P . - A . L a r s o n . D y n a m i c m e m o r y a d j u s t m e n t f o r e x t e r n a l m e r g e s o r t .   P r o c . T w e n t y - t h i r d  

I n t e r n a t i o n a l C o n f . o n V e r y L a r g e D a t a B a s e s  , 1 9 9 7 .  

Z L 9 8 ] W e i y e Z h a n g a n d P . - A L a r s o n . B u e r i n g a n d r e a d - a h e a d s t r a t e g i e s f o r e x t e r n a l m e r g e s o r t .   P r o c e e d i n g s  

o f t h e 2 4 t h V L D B C o n f e r e n c e  , p a g e s 5 2 3 { 5 3 2 , 1 9 9 8 .  

1 8 9 

Page 203: Algorithmic Techniques to overcome the I/O Bottleneck

8/14/2019 Algorithmic Techniques to overcome the I/O Bottleneck

http://slidepdf.com/reader/full/algorithmic-techniques-to-overcome-the-io-bottleneck 203/203

B i o g r a p h y      

R a k e s h B a r v e w a s b o r n o n M a r c h 4 , 1 9 7 2 i n B o m b a y ( n o w k n o w n a s M u m b a i ) , I n d i a . H e r e c e i v e d a B a c h e l o r o f  

T e c h n o l o g y d e g r e e i n C o m p u t e r S c i e n c e a n d E n g i n e e r i n g f r o m t h e I n d i a n I n s t i t u t e o f T e c h n o l o g y ( I I T ) , B o m b a y i n  

M a y 1 9 9 3 . H e j o i n e d t h e c o m p u t e r s c i e n c e d o c t o r a l p r o g r a m a t D u k e U n i v e r s i t y i n A u g u s t 1 9 9 3 . I n c o u r s e o f h i s  

P h . D . , h e w a s t h e r e c i p i e n t o f a n I B M G r a d u a t e F e l l o w s h i p A w a r d f o r t h r e e a c a d e m i c y e a r s f r o m 1 9 9 5 t h r o u g h 1 9 9 8 .  

H e r e c e i v e d t h e D o c t o r o f P h i l o s o p h y i n C o m p u t e r S c i e n c e f r o m D u k e U n i v e r s i t y i n D e c e m b e r 1 9 9 8 .  

R a k e s h B a r v e i s i n t e r e s t e d i n t h e d e s i g n , a n a l y s i s , a n d i m p l e m e n t a t i o n o f a l g o r i t h m s a n d i n t h e u s e o f p r a c t i c a l  

t e c h n i q u e s a n d d a t a s t r u c t u r e s t o d e s i g n e c i e n t , a p p l i c a t i o n - s p e c i c s o l u t i o n s . H i s r e s e a r c h w o r k h a s f o c u s s e d o n  

t e c h n i q u e s t o o v e r c o m e s l o w a c c e s s s p e e d s o f s e c o n d a r y m e m o r y : T h e s e i n c l u d e e x t e r n a l m e m o r y d a t a s t r u c t u r e s  

a n d a l g o r i t h m s , c a c h i n g , p r e f e t c h i n g , b u e r m a n a g e m e n t , l o a d b a l a n c i n g a c r o s s m u l t i p l e d i s k d r i v e s , a n d o p e r a t i n g  

s y s t e m s i s s u e s p e r t a i n i n g t o I / O p e r f o r m a n c e a n d i m p l e m e n t a t i o n o f e x t e r n a l m e m o r y c o m p u t a t i o n s .  

S e l e c t e d P u b l i c a t i o n s    

1 . \ A p p l i c a t i o n C o n t r o l l e d P a g i n g f o r a S h a r e d C a c h e " , R a k e s h D . B a r v e , E d w a r d F . G r o v e a n d J e r e y S . V i t t e r .  

A c c e p t e d f o r p u b l i c a t i o n i n t h e S I A M J o u r n a l o f C o m p u t i n g . A s h o r t v e r s i o n a p p e a r e d i n t h e   P r o c e e d i n g s o f  

t h e 3 6 t h A n n u a l I E E E S y m p o s i u m o n F o u n d a t i o n s o f C o m p u t e r S c i e n c e ( F O C S 9 5 ) , A u g u s t 1 9 9 5 .  

2 . \ S i m p l e R a n d o m i z e d M e r g e s o r t o n P a r a l l e l D i s k s " , R a k e s h D . B a r v e , E d w a r d F . G r o v e a n d J e r e y . S . V i t t e r ,  

i n  P a r a l l e l C o m p u t i n g   , 1 9 9 7 , V o l u m e 2 3 , N u m b e r 4 , p p 6 0 1 { 6 3 1 . A n e a r l i e r v e r s i o n a p p e a r e d i n   P r o c e e d i n g s o f