400 likes | 644 Views
Indeksstrukturer til Ekstern Hukommelse. Cache-Oblivious Dynamic Dictionaries with Optimal Update/Query Tradeoff. Gerth Stølting Brodal Aarhus University. Dansk Selskab for Datalogi, Frederiksbjerg , October 13, 2010. Gerth Stølting Brodal. Kurt Mehlhorn. 2007-. 1994-2006.
E N D
Indeksstrukturer til Ekstern Hukommelse Cache-Oblivious Dynamic Dictionaries with Optimal Update/Query Tradeoff GerthStølting Brodal Aarhus University • Dansk Selskab for Datalogi, Frederiksbjerg, October 13, 2010
GerthStølting Brodal Kurt Mehlhorn 2007- 1994-2006 Eric Meineche Schmidt PhD M.Sc. Associate Professor AU MPII MPII AU AU 1969 September 1983 September 1989 August 1993 January 1994 November 1997 January 1998 August 2004 April April M.Sc. Post Doc Faculty PhD
Center of • Lars Arge, Professor, Centerleader • GerthS. Brodal, Associate Professor • 5 Post Docs, 10 PhD students, 4 TAP • Total budget for 5 years ca. 60 million DKR Frankfurt AU MIT MPII ArgeBrodal DemaineIndyk Mehlhorn Meyer
Streaming Algorithms I/O Efficient Algorithms Cache Oblivious Algorithms Algorithm Engineering
The problem... Normal algorithm running time I/O-efficient algorithm input size bottleneck = memory size
MemoryHierarchies CPU R Processor L1 L2 L3 Disk A M bottleneck increasing access times and memory sizes
MemoryHierarkiesvs.Running Time L1 L2 L3 RAM køretid datastørrelse
read/write head read/write arm track magnetic surface Disk Mechanics • I/O is often bottleneck when handling massive datasets • Disk access is 107 times slower than main memory access! • Disk systems try to amortize large access time transferring large contiguous blocks of data • Need to store and access data to take advantage of blocks ! “The difference in speed between modern CPU and disk technologies is analogous to the difference in speed in sharpening a pencil using a sharpener on one’s desk or by taking an airplane to the other side of the world and using a sharpener on someone else’s desk.” (D. Comer)
Bayer og McCreight (1971) B(oing)-Trees One node = one disk block HeightO(logBN)
Internal memory B .... Search path B-trees -The Basic Searching Structure • Searches Practice: 4-5 I/Os • Repeated searching Practice: 1-2 I/Os
The Bad News... Searchinganyexternalmemorydictionary (incl. B-trees) requiresworst-case Ω(logBN) I/Os Proofidea: ? x xxxxx x x xxxx x x N ≥(N - B) / (B + 1)
Internal memory B .... Search path B-trees Best possible • Searches O(logBN) I/Os • UpdatesO(logBN) I/Os ?
Brodal and Fagerberg (2003) d .... B-trees with Buffered Updates B x x x x • Searches cost • O(logdN) I/Os • = O(logBN ∙ 1/ε) I/Os 2 • N updates cost • O(N ∙ logdN ∙ d / B) I/Os • = O(N ∙ logBN ∙ 1/εB1-ε) I/Os = Bε 2 / √B Trade-offbetweensearch and update times – optimal !
Brodal and Fagerberg (2003) B-trees with Buffered Updates
Hedegaard (2004) B-trees with Buffered UpdatesExperimentalStudy • 100.000.000 elements • Search time basicallyunchangedwith buffers • 100 times faster updates
Assumptionsuntilnow : B is known + onelevel is the bottleneck CPU R Processor L1 L2 L3 Disk A M bottleneck increasing access times and memory sizes
Frigo, Leiserson, Prokop, Ramanchandran (1999) Cache-Obliviousnes Model CPU B R Processor L1 L2 L3 Disk A M M Algorithmdoes not knowB and M (assume optimal offline cache-replacementstrategy) increasing access times and memory sizes
B A N I/O Efficient Scanning sum = 0 for i = 1 to N do sum = sum + A[i] O(N/B) I/Os
Bayer og McCreight (1971) B(oing)-Trees One node = one disk block HeightO(logBN)
Frigo (1999) RecursiveSearchTree Layout(Cache-Obliviousness) Searchesrequire O(logBN) I/Os (small subtrees have √B ≤ size≤ B, a pathtraverses at most 2∙logBN trees)
Brodal, Fagerberg, Jacob (2002) Experiments : BinaryTree Layout
Brodal, Fagerberg, Jacob (2002) Searcheswith Pointer Layout • van Emde Boas layout wins, followed by the BFS layout van Emde Boas layout
Brodal, Fagerberg, Jacob (2002) Searcheswith Implicit Layout • BFS layout wins due to simplicity and caching of topmost levels • van Emde Boas layout requires quite complex index computations
Brodal, Fagerberg, Jacob (2002) Searcheswith Pointer Layout - Beyond Main Memory • van Emde Boas layout wins, followed by the BFS layout
Brodal, Fagerberg, Jacob (2002) Optimal Cache-ObliviousStaticIndex= van Emde Boas Layout of CompleteBinaryTree
Brodal, Fagerberg, Jacob (2002) BinarySearchTreesDynamic • Embeda dynamic tree of small height into a complete tree • Static van Emde Boas layout • Rebuild data structure whenever N doubles or halves
Brodal, Fagerberg, Jacob (2002) Brodal, Fagerberg, Jacob (2002) Andersson and Lai (1990) RebalancingSubtreeduringInsertion • If an insertion causes non-small height then rebuildsubtree at nearest ancestor with sufficient few descendants • Insertions require amortized time O(log2N)
Brodal, Fagerberg, Jacob (2002) Optimal Cache-ObliviousDynamicIndex • Search O(logBN) I/Os (optimal) • Updates O(logBN + (log2N) / B) I/Os
Brodal, Demaine, Fineman, Iacono, Langerman, Munro (2010) Cache-ObliviousDynamicDictionarieswithQuery-UpdateTrade-off • Solution matching the I/O complexity of BufferedB-trees • Searches O(logBN ∙ 1/ε) I/Os • N updatesO(N ∙ logBN ∙ 1/εB1-ε) I/Os
Brodal, Demaine, Fineman, Iacono, Langerman, Munro (2010) xDict … 221-box 222-box 22lglgN-box Insert • Insert into smallest box • When a box reaches capacity, Flush it and Batch-Insert into the next box Search • Search in each x-box • O(logBx) cost is dominated by largest box O(logBN)
Brodal, Demaine, Fineman, Iacono, Langerman, Munro (2010) Batch insertx elements x-Box (capacity x2) size-x input buffer Upper level: at most x1/2/4 subboxes √x-box Flush size-x3/2 middle buffer Lower level: at most x /4 subboxes √x-box size-x2 output buffer Memory Layout … … input middle output subboxes stored contiguously in arbitrary order Unused (currently empty) subboxes are preallocated
d .... ExternalMemoryIndex B … • Searches O(logBN ∙ 1/ε) I/Os • N updatesO(N ∙ logBN ∙ 1/εB1-ε) I/Os … = Bε