KISS-Tree: Smart Latch-Free In-Memory Indexing on Modern ...
Fractal tree-technology-and-the-art-of-indexing
-
Upload
atner-yegorov -
Category
Technology
-
view
346 -
download
0
Transcript of Fractal tree-technology-and-the-art-of-indexing
![Page 1: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/1.jpg)
Fractal Tree® Technology OverviewThe Art of Indexing
Martín Farach-ColtonCo-founder & Chief Technology Officer
![Page 2: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/2.jpg)
The Art of Indexing®
Not all indexing is the same
B-tree is the basis for almost all DB systems• Data structure invented in 1972
• Has not kept up with hardware trends‣ Works poorly on modern rotational disks‣ Works poorly on SSD
Fractal Tree Indexes is the basis of TokuDB• Scales with hardware
• Fast Indexing ➔ More Indexing ➔ Faster Queries
• Great Compression
• No Fragmentation
• Reduced wear on SSDs
![Page 3: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/3.jpg)
How do Fractal Tree Indexes outperform
B-trees?
![Page 4: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/4.jpg)
How do Fractal Tree Indexes outperform
B-trees?
First, some facts about storage systems
![Page 5: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/5.jpg)
The Art of Indexing®
Storage is quirky
Hard disks are slow for random I/O but fast for
sequential I/O
Difference causes problems like fragmentation, ...
![Page 6: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/6.jpg)
The Art of Indexing®
Storage is quirky
Hard disks are slow for random I/O but fast for
sequential I/O
SSDs are fast for random I/O but expensive for
sequential.
Garbage collection causes artefacts: increased
wear, write cliffs...
Difference causes problems like fragmentation, ...
![Page 7: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/7.jpg)
The Art of Indexing®
Storage ♡ Big Reads and Writes
Big I/Os
![Page 8: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/8.jpg)
The Art of Indexing®
Storage ♡ Big Reads and Writes
Big I/Os
Hard Disks: No Fragmentation
![Page 9: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/9.jpg)
The Art of Indexing®
Storage ♡ Big Reads and Writes
Big I/Os
Hard Disks: No Fragmentation SSDs: Less Garbage
Collection & Wear
![Page 10: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/10.jpg)
The Art of Indexing®
Storage ♡ Big Reads and Writes
Big I/Os
Hard Disks: No Fragmentation SSDs: Less Garbage
Collection & Wear
But you only get the goodies if each I/O has lots of new bytes
![Page 11: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/11.jpg)
The Art of Indexing®
Storage ♡ Big Reads and Writes
Big I/Os
Hard Disks: No Fragmentation SSDs: Less Garbage
Collection & Wear
But you only get the goodies if each I/O has lots of new bytes
If you read a big block, change one byte, then write it, you get terrible wear problems
![Page 12: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/12.jpg)
The Art of Indexing®
Storage ♡ Big Reads and Writes
Big I/Os
Hard Disks: No Fragmentation SSDs: Less Garbage
Collection & Wear
Both: Better Compression
But you only get the goodies if each I/O has lots of new bytes
If you read a big block, change one byte, then write it, you get terrible wear problems
![Page 13: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/13.jpg)
The Art of Indexing®
Caching is great• But you can’t cache all your data
• For stuff not in memory, you have to go to disk
Goal: Do the best we can for the stuff on disk
Data is big, RAM is Small
Data
RAM
![Page 14: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/14.jpg)
Now, What’s a B-tree? & a Fractal Tree Index
![Page 15: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/15.jpg)
The Art of Indexing®
What’s a B-tree?
B
B B B... ...
B B……………………………………………….………….
Search Tree
![Page 16: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/16.jpg)
The Art of Indexing®
What’s a B-tree?
B
B B B... ...
B B……………………………………………….………….
Each node has B pivots
Search Tree
![Page 17: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/17.jpg)
The Art of Indexing®
What’s a B-tree?
B
B B B... ...
B B……………………………………………….………….
Each node has B pivots
Search Tree
Fetching pivots as a group saves I/Os
![Page 18: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/18.jpg)
The Art of Indexing®
What’s a B-tree?
B
B B B... ...
B B……………………………………………….………….
Each node has B pivots
Search Tree
Fetching pivots as a group saves I/Os
Most leaves are on disk, not in RAM
![Page 19: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/19.jpg)
The Art of Indexing®
What’s a B-tree?
B
B B B... ...
B B……………………………………………….………….
Each node has B pivots
Search Tree
Fetching pivots as a group saves I/Os
Most leaves are on disk, not in RAM Inserting into a leaf that’s not in memory will require an I/O per insertion
![Page 20: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/20.jpg)
The Art of Indexing®
B-tree Delivery Service
If fast memory is like walking across a room• Each update in a B-tree is a walking trip from ‣ New York
![Page 21: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/21.jpg)
The Art of Indexing®
B-tree Delivery Service
If fast memory is like walking across a room• Each update in a B-tree is a walking trip from ‣ New York to St Louis
![Page 22: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/22.jpg)
The Art of Indexing®
B-tree Delivery Service
If fast memory is like walking across a room• Each update in a B-tree is a walking trip from ‣ New York to St Louis
Each item gets its own round trip!
![Page 23: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/23.jpg)
The Art of Indexing®
Real-world delivery
Keep regional warehouses• Only move stuff when you can move a lot
![Page 24: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/24.jpg)
The Art of Indexing®
Real-world delivery
Keep regional warehouses• Only move stuff when you can move a lot
Each item gets moved several times
![Page 25: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/25.jpg)
The Art of Indexing®
Real-world delivery
Keep regional warehouses• Only move stuff when you can move a lot
Each item gets moved several times
But each trip is vastly cheaper
![Page 26: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/26.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
![Page 27: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/27.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
![Page 28: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/28.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
![Page 29: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/29.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 30: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/30.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 31: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/31.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 32: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/32.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 33: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/33.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 34: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/34.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 35: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/35.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 36: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/36.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 37: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/37.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 38: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/38.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 39: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/39.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 40: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/40.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 41: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/41.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 42: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/42.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 43: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/43.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 44: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/44.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
![Page 45: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/45.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
Flush a buffer when it fills
![Page 46: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/46.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
Flush a buffer when it fills
A flush might take an I/O, but it does lots of useful work
![Page 47: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/47.jpg)
The Art of Indexing®
Fractal Tree Indexes
B
B B BB
Each node has pivots & Buffers
Buffers fill as updates arrive
Flush a buffer when it fills
A flush might take an I/O, but it does lots of useful work
More changes per write ➔ fewer changes for same write
load ➔ less SSD wear
![Page 48: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/48.jpg)
The Art of Indexing®
Fractal Tree Indexes: Queries
B
B B BB
Lots of buffers have messages
![Page 49: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/49.jpg)
The Art of Indexing®
Fractal Tree Indexes: Queries
B
B B BB
Lots of buffers have messages
But query follows root-leaf path
![Page 50: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/50.jpg)
The Art of Indexing®
Fractal Tree Indexes: Queries
B
B B BB
Lots of buffers have messages
But query follows root-leaf path
So every query has the most up-to-date information
![Page 51: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/51.jpg)
The Art of Indexing®
Fractal Tree Indexes: Queries
B
B B BB
Lots of buffers have messages
But query follows root-leaf path
So every query has the most up-to-date information
Messages can be insert, update, delete
![Page 52: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/52.jpg)
The Art of Indexing®
Fractal Tree Indexes: Schema Changes
B
B B BB
Schema Changes are broadcast messages
![Page 53: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/53.jpg)
The Art of Indexing®
Fractal Tree Indexes: Schema Changes
B
B B BB
Schema Changes are broadcast messages
![Page 54: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/54.jpg)
The Art of Indexing®
Fractal Tree Indexes: Schema Changes
B
B B BB
Schema Changes are broadcast messages
![Page 55: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/55.jpg)
The Art of Indexing®
Fractal Tree Indexes: Schema Changes
B
B B BB
Schema Changes are broadcast messages
Insertion into root is fast, changes are immediate
![Page 56: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/56.jpg)
The Art of Indexing®
Fractal Tree Indexes: Schema Changes
B
B B BB
Schema Changes are broadcast messages
Leaves get rewritten when broadcast message
makes it that far
Insertion into root is fast, changes are immediate
Schema change message still on root-
leaf path
![Page 57: Fractal tree-technology-and-the-art-of-indexing](https://reader033.fdocuments.us/reader033/viewer/2022060108/5550966bb4c9058b208b462d/html5/thumbnails/57.jpg)
The Art of Indexing®
Analysis
Delivery system gives goodies:• Messages get moved, but each I/O pays for a lot of
movement
• You get very fast inserts
• You get Hot Schema Changes
Each flush carries lots of useful information• So it’s worth it to make nodes big
• No fragmentation, Better Compression
• Much better wear on SSDs