Building an Efficient Key-Value Store in a Flexible Address Space
Chen Chen1, Wenshao Zhong1, Xingbo Wu2
1 University of Illinois at Chicago
2 Microsoft Research Cambridge
1
KV Stores
2
KV Stores
3
Point Query
Range Query
Write
KV Stores
4
Point Query
Range Query
Write
Managing Sorted Data
5
(Simplified) File
foo
abcd
bar
0xbee
cat
2022
Managing Sorted Data
6
(Simplified) File
foo
abcd
bar
0xbee
cat
2022
Managing Sorted Data
7
(Simplified) File
foo
abcd
bar
0xbee
cat
2022
art
18
Managing Sorted Data
8
(Simplified) File
foo
abcd
bar
0xbee
cat
2022
art
18
Rewrite the whole file
Managing Sorted Data
9
(Simplified) File
foo
abcd
bar
0xbee
cat
2022
art
18
Managing Sorted Data
10
(Simplified) File
foo
abcd
bar
0xbee
cat
2022
art
18
Indirection
Application
Managing Sorted Data
11
(Simplified) File
foo
abcd
bar
0xbee
cat
2022
art
18
Indirection
Application
Managing Sorted Data
12
(Simplified) File
foo
abcd
bar
0xbee
cat
2022
art
18
Indirection
Application
Maintaining large index
Managing Sorted Data
Log-structured sort-merge approach (e.g., LSM)
13
(Simplified) File
foo
abcd
bar
0xbee
cat
2022
art
18
Indirection
Application
Maintaining large index
Managing Sorted Data
Log-structured sort-merge approach (e.g., LSM)
14
(Simplified) File
foo
abcd
bar
0xbee
cat
2022
art
18
Indirection
Application
Maintaining large index
Repeated rewrites
Managing Sorted Data
Log-structured sort-merge approach (e.g., LSM)
15
(Simplified) File
foo
abcd
bar
0xbee
cat
2022
art
18
Indirection
Application
Maintaining large index
Semantic gap:
Cannot insert data in-place
Repeated rewrites
Managing Sorted Data
16
(Simplified) File
foo
abcd
bar
0xbee
cat
2022
Address Space
0
3
11
14
22
25
29
What if we can sort data here?
Managing Sorted Data
17
insert
shift
(Simplified) File
Address Space
art
18
bar
0xbee
foo
abcd
cat
2022
0
3
11
14
22
25
33
36
40
Managing Sorted Data
18
insert
shift
(Simplified) File
Address Space
art
18
bar
0xbee
foo
abcd
cat
2022
0
3
11
14
22
25
33
36
40
Straightforward
Managing Sorted Data
19
(Simplified) File
Address Space
art
18
bar
0xbee
foo
abcd
cat
2022
0
3
11
14
22
25
33
36
40
Managing Sorted Data
20
(Simplified) File
Address Space
art
18
bar
0xbee
foo
abcd
cat
2022
0
3
11
14
22
25
33
36
40
Logical offset -> physical address
Managing Sorted Data
21
Updating O(N) extents’ metadata
(Simplified) File
Address Space
art
18
bar
0xbee
foo
abcd
cat
2022
0
3
11
14
22
25
33
36
40
Managing Sorted Data
22
(Simplified) File
Address Space
art
18
bar
0xbee
foo
abcd
cat
2022
0
3
11
14
22
25
33
36
40
3 orders of magnitude gap
Managing Sorted Data
23
(Simplified) File
Address Space
art
18
bar
0xbee
foo
abcd
cat
2022
0
3
11
14
22
25
33
36
40
Managing Sorted Data
24
(Simplified) File
Address Space
art
18
bar
0xbee
foo
abcd
cat
2022
0
3
11
14
22
25
33
36
40
The offsets can easily change
Managing Sorted Data
25
(Simplified) File
Address Space
art
18
bar
0xbee
foo
abcd
cat
2022
0
3
11
14
22
25
33
36
40
A more flexible storage abstraction to manage sorted data!
Our Idea: Flexible Address Space
26
Our Idea: Flexible Address Space
27
Our Idea: Flexible Address Space
28
Our Idea: Flexible Address Space
Managing shifting data
No alignment requirements
Index with efficient shifting
29
FlexDB
FlexSpace
FlexTree
Persistent
Address
Space
Application
Our Idea: Flexible Address Space
Managing shifting data
No alignment requirements
Index with efficient shifting
30
FlexDB
FlexSpace
FlexTree
Persistent
Address
Space
Application
Starting from B+-Tree
31
51
23
64
0
23
51
64
Keys are logical offsets
Starting from B+-Tree
32
51
23
64
0
23
51
64
Keys are logical offsets
Starting from B+-Tree
33
51
23
64
0
23
51
64
Insert a new extent (length = 10) at offset 0
Keys are logical offsets
Starting from B+-Tree
34
51
23
64
23
51
64
Insert a new extent (length = 10) at offset 0
0
Insert
Starting from B+-Tree
35
51
23
64
0
23
51
64
Insert a new extent (length = 10) at offset 0
0
+10
+10
+10
+10
+10
+10
+10
Shift
FlexTree: Structure
36
51
23
64
0
23
51
64
FlexTree: Structure
37
51
+0
+0
23
+0
+0
64
+0
+0
0
23
51
64
A shift value associated with a pointer
FlexTree: Structure
38
51
+0
+0
23
+0
+0
64
+0
+0
0
23
51
64
23 + (+0) + (+0) = 23
Adding all the shift values on the path
A shift value associated with a pointer
FlexTree: Operations
39
51
+0
+0
23
+0
+0
64
+0
+0
0
23
51
64
Insert a new extent (length = 10) at offset 0
FlexTree: Operations
40
51
+0
+0
23
+0
+0
64
+0
+0
0
23
51
64
0
Insert
FlexTree: Operations
41
51
+0
+0
23
+0
+0
64
+0
+0
0
23
51
64
0
Shift
+10
+10
+10
+10
+10
FlexTree: Operations
42
61
+0
33
+0
64
+0
+0
0
23
51
64
10
Shift
+10
+10
Nodes on the path updated
-> O(logN) cost
Logical logging
FlexTree: Operations
43
61
+0
33
+0
64
+0
+0
0
23
51
64
10
Shift
+10
+10
23 + (+10) + (+0) = 33
FlexTree: Operations
44
61
+0
33
+0
64
+0
+0
0
23
51
64
10
Shift
+10
+10
51 + (+0) + (+10) = 61
search key = 61
search key = 51
search key = 51
Based on FlexTree
45
FlexDB
46
Flexible Address Space
Key Space
Device Address Space
FlexTree
Sparse Index
FlexDB: Sparse Index
47
47
ink
FlexSpace
foo
abcd
bar
0xbee
cat
2022
Address Space
0
3
11
14
22
25
29
…
Interval 1
Interval 2
Interval 3
FlexDB: Sparse Index
48
48
ink
FlexSpace
foo
abcd
bar
0xbee
cat
2022
Address Space
0
3
11
14
22
25
29
foo
+0
+0
cat
0
11
ink
22
29
FlexDB: Sparse Index
49
49
ink
FlexSpace
foo
abcd
bar
0xbee
cat
2022
Address Space
0
3
11
14
22
25
29
foo
+0
+0
cat
0
11
ink
22
29
Inserting a new key “bot” into an interval
FlexDB: Sparse Index
50
50
FlexSpace
bar
0xbee
Address Space
0
3
11
14
22
25
33
foo
+0
cat
0
11
ink
22
29
Inserting a new key “bot” into an interval
ink
foo
abcd
cat
2022
bot
0xfff
36
40
+0
+11
+11
FlexDB: Sparse Index
51
51
FlexSpace
bar
0xbee
Address Space
0
3
11
14
22
25
33
foo
+0
cat
0
22
ink
22
29
Inserting a new key “bot” into an interval
ink
foo
abcd
cat
2022
bot
0xfff
36
40
+11
FlexDB: Sparse Index
52
52
FlexSpace
bar
0xbee
Address Space
0
3
11
14
22
25
33
foo
+0
cat
0
22
ink
22
29
ink
foo
abcd
cat
2022
bot
0xfff
36
40
+11
Elastic
In-memory
Easy recovery
FlexDB: Sparse Index
53
53
FlexSpace
bar
0xbee
Address Space
0
3
11
14
22
25
33
ink
foo
abcd
cat
2022
bot
0xfff
36
40
Extent
Extent
Extent
?
FlexDB: Sparse Index
54
54
FlexSpace
bar
0xbee
Address Space
0
3
11
14
22
25
33
ink
foo
abcd
cat
2022
bot
0xfff
36
40
Extent
Extent
Extent
flexspace_read_extent(fs, 30)
-> extent at 22
FlexDB: Sparse Index
55
55
FlexSpace
bar
0xbee
Address Space
0
3
11
14
22
25
33
ink
foo
abcd
cat
2022
bot
0xfff
36
40
cat
0
22
Recap
56
Evaluation: Setup
57
* Zhichao Cao, Siying Dong, Sagar Vemuri, and David H. C. Du. “Characterizing, Modeling, and Benchmarking RocksDB Key-Value Workloads at Facebook”. In: 18th USENIX Conference on File and Storage Technolo gies (FAST’20). 2020, pp. 209–223.
** Berk Atikoglu, Yuehai Xu, Eitan Frachtenberg, Song Jiang, and Mike Paleczny. “Workload Analysis of a Large-Scale Key-Value Store”. In: SIGMETRICS Per form. Eval. Rev. 40.1 (2012), pp. 53–64.
Evaluation: Disk I/O
58
Evaluation: YCSB
59
Write
Mostly
Read
Only
Read
Latest
Scan
Mostly
Read-modify-write
(RMW)
Read
Mostly
60 sec per
workload
Evaluation: YCSB
60
Write
Mostly
Read
Only
Read
Latest
Scan
Mostly
Read-modify-write
(RMW)
Read
Mostly
60 sec per
workload
50% Update
50% Read
Evaluation: YCSB
61
Write
Mostly
Read
Only
Read
Latest
Scan
Mostly
Read-modify-write
(RMW)
Read
Mostly
60 sec per
workload
5% Update
95% Read
Evaluation: YCSB
62
Write
Mostly
Read
Only
Read
Latest
Scan
Mostly
Read-modify-write
(RMW)
Read
Mostly
60 sec per
workload
5% Insert
95% Scan
Summary
63