1
Towards ¡Application ¡Driven ¡Storage
Optimizing ¡RocksDB ¡for ¡Open-‑Channel ¡SSDs
Javier ¡González ¡<javier@cnexlabs.com>
LinuxCon ¡Europe ¡2015
Contributors: ¡Matias ¡Bjørling ¡and ¡Florin ¡Petriuc
Towards Application Driven Storage Optimizing RocksDB for - - PowerPoint PPT Presentation
Towards Application Driven Storage Optimizing RocksDB for Open-Channel SSDs Javier Gonzlez <javier@cnexlabs.com> LinuxCon Europe 2015 Contributors: Matias Bjrling and Florin Petriuc 1
1
Contributors: ¡Matias ¡Bjørling ¡and ¡Florin ¡Petriuc
2
RocksDB
Metadata ¡Mgmt. Standard ¡Libraries
User ¡Space Kernel ¡Space
App-‑specific ¡opt. Page ¡cache Block ¡I/O ¡interface FS-‑specific ¡logic
translation ¡layers ¡ ¡
manipulating ¡persistent ¡data ¡
latency, ¡resource ¡utilization, ¡and ¡ data ¡movement ¡(compared ¡to ¡ best-‑effort ¡techniques ¡today)
3
RocksDB
Metadata ¡Mgmt. Standard ¡Libraries
User ¡Space Kernel ¡Space
App-‑specific ¡opt. Page ¡cache Block ¡I/O ¡interface FS-‑specific ¡logic
Generic ¡<> ¡Optimized
➡ Motivation: ¡Give ¡the ¡tools ¡to ¡the ¡applications ¡
that ¡know ¡how ¡to ¡manage ¡their ¡own ¡storage
decisions ¡
storage
4
5
High ¡throughput ¡+ ¡Low ¡latency Parallelism ¡+ ¡Controller
Page 0 Page 1 Page 2 Page n -1 … State OOB Data
6
7
Physical flash exposed to the host (Read, Write, Erase)
8
Key-Value/Object/FS/ Block/etc. Block Target Direct Flash Target File-System Block Manager (Generic, Vendor-specific, ...) Open-Channel SSDs (NVMe, PCI-e, RapidIO, ...) Kernel User-space Block Copy Engine Metadata State Mgmt. Bad Block State Mgmt. XOR Engine ECC Engine Error Handling Etc. GC Engine Raw ¡NAND ¡Geometry Managed ¡Geometry Vendor-Specific Target
Hardware Software LightNVM ¡Framework
space ¡
characteristics ¡
all ¡flash ¡
9
Open%Channel*SSD
get_block(),/, put_block(),/ erase_block()
Block*Manager DFlash*Target
Provisioning,interface Block,device
Applica:on
Provisioning,buffer
Block0 Block1 BlockN …
Applica@on,Logic
Normal,I/O blockNE>bppa,*,PAGE_SIZE
struct&nvm_tgt_type&/_dflash&=&{ &&[…] &&.make_rq&&&&&&=&df_make_rq, &&.&end_io&&&&&&&&=&df_end_io, &&[…] };
FTL sync psync libaio posixaio …
… … … …
CH0 CH1 CHN
Lun0 LunN
Physical,Flash,Layout ,,E,NAND,E,specific ,,E,Managed,by,controller
… … … … vblock
Managed,Flash ,,E,Exploit,parallelism ,,E,Serve,applica@on,needs
type%1 type%2
vblock vblock type%3
KERNEL*SPACE USER*SPACE
Data,placement I/O,scheduling OverEprovisioning Garbage,collection WearEleveling
struct ¡vblock ¡{ ¡ ¡ ¡uint64_t ¡id; ¡ ¡ ¡uint64_t ¡owner_id; ¡ ¡ ¡uint64_t ¡nppas; ¡ ¡ ¡uint64_t ¡ppa_bitmap ¡ ¡ ¡sector_t ¡bppa; ¡ ¡ ¡uint32_t ¡vlun_id; ¡ ¡ ¡ ¡ ¡uint8_t ¡flags ¡ };
structures, ¡file ¡abstractions, ¡algorithms). ¡
10
11
RocksDB ¡Reference: ¡The ¡Story ¡of ¡RocksDB, ¡Dhruba ¡Borthakur ¡and ¡Haobo ¡Xu ¡(link)
The ¡Log-‑Structured ¡Merge-‑Tree, ¡Patrick ¡O'Neil, ¡Edward ¡Cheng ¡ Dieter ¡Gawlick, ¡Elizabeth ¡O’Neil. ¡Acta ¡Informatica, ¡1996.
12
Active MemTable ReadOnly MemTable Log Log sst sst sst sst sst sst
Compaction Flush Switch Switch
LSM
Blooms
13
sst sst sst sst sst sst User Data Metadata DB Log
WAL … WAL
WAL WAL
Manifest Manifest Manifest
…
Current
Other
LOG (Info) LOCK IDENTITY
Storage Backend LSM Logic
Posix HDFS Win
RocksDB LSM
secondary ¡storage ¡
sstable ¡user ¡data ¡and ¡recovery ¡
metadata ¡(e.g., ¡CRC ¡checks)
than ¡levels ¡used ¡for ¡compacted ¡data ¡to ¡maximize ¡persistency ¡in ¡case ¡of ¡power ¡loss)
14
bad ¡pages, ¡bad ¡blocks) ¡
15
Arena&block&(kArenaSize)
(Op3mal&size&~&1/10&of&write_buffer_size)
write_buffer_size
…
Flash'Block'0 Flash'Block'1
nppas'*'PAGE_SIZE
gid:'128 gid:'273 gid:'481
EOF space'amplificaHon (life'of'file)
16
MANIFEST ¡replace ¡size ¡fills ¡up ¡ most ¡of ¡last ¡block
P1:
parameter ¡that ¡is ¡used ¡to ¡optimize ¡“dynamic” ¡ones
17
Block& Ending& Metadata Out$of$ Bound Block& Star+ng& Metadata
First&Valid&Page Intermediate&Page Last&Page
Out&of& Bound Block& Star:ng& Metadata Block& Ending& Metadata
RocksDB(data RocksDB(data RocksDB(data
Out&of& Bound Out&of& Bound
Flash&Block
struct ¡vblock_init_meta ¡{ ¡ ¡ ¡char ¡filename[100]; ¡ ¡ ¡ ¡ ¡ ¡// ¡RocksDB ¡file ¡GID ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡uint64_t ¡owner_id; ¡ ¡ ¡ ¡ ¡ ¡// ¡Application ¡owning ¡the ¡block ¡ ¡ ¡size_t ¡pos; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡// ¡relative ¡position ¡in ¡block ¡ }; ¡ struct ¡vpage_meta ¡{ ¡ ¡ ¡size_t ¡valid_bytes; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡// ¡Valid ¡bytes ¡from ¡offset ¡0 ¡ ¡ ¡uint8_t ¡flags; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡// ¡State ¡of ¡the ¡page ¡ }; ¡ struct ¡vblock_close_meta ¡{ ¡ ¡ ¡size_t ¡written_bytes; ¡ ¡ ¡ ¡ ¡ ¡// ¡Payload ¡size ¡ ¡ ¡size_t ¡ppa_bitmap; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡// ¡Updated ¡valid ¡page ¡bitmap ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡size_t ¡crc; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡// ¡CRC ¡of ¡the ¡whole ¡block ¡ ¡ ¡unsigned ¡long ¡next_id; ¡ ¡// ¡Next ¡block ¡ID ¡(0 ¡if ¡last) ¡ ¡ ¡uint8_t ¡flags; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡// ¡Vblock ¡flags ¡ }; ¡
18
OPCODE ENCODED METADATA OPCODE ENCODED METADATA OPCODE ENCODED METADATA
…
Metadata/Type: 3/Log 3/Current 3/Metadata 3/Sstable !"Private"(Env) Enough/metadata/to/ recover/database/in/a/ new/instance Private"(DFlash): vblocks/forming/the/ DFlash/File
1
BLOCK BLOCK BLOCK
3
Open%Channel*SSD BM
Block& (ownerID) Block& (ownerID) Block& (ownerID) …
Block&List Recovery
2
19
creating ¡a ¡new ¡instance. ¡We ¡append ¡the ¡block ¡metadata ¡that ¡points ¡to ¡the ¡ blocks ¡forming ¡the ¡current ¡MANIFEST ¡(P5)
OPCODE ENCODED METADATA OPCODE ENCODED METADATA OPCODE ENCODED METADATA
…
Metadata/Type: 3/Log 3/Current 3/Metadata 3/Sstable !"Private"(Env) Enough/metadata/to/ recover/database/in/a/ new/instance Private"(DFlash): vblocks/forming/the/ DFlash/File
MANIFEST ¡ (DFlash) CURRENT ¡ (Posix)
Normal ¡Recovery
20
21
22
23
DFlash'Storage'Backend LSM'Logic Open8Channel'SSD'(Fast'Storage) Posix'FS'(Sta>c'Meta.) sst sst sst sst sst sst User%Data DB%Log
WAL …
WAL WAL WAL
Metadata
Manifest
Metadata
CURRENT LOCK IDENTITY LOG' (Info)
Env'DFlash Op2miza2ons Env%Op2ons
(Flash%charac.%on%init)
DFlash'File'Classes DFWritableFile() DFRandomAccessFile() DFSequen2alFile() Persist%opera2ons Environment% Tunning Env'DFlash Private%metadata Metadata,%Close,%Crash
24
Open%Channel*SSD BM DFlash KERNEL*SPACE USER*SPACE
Provisioning)interface Block)device DFlash)File)(blocks) get_block() put_block() DFWritableFile DFSequen?alFile DFRandomAccesslFile
Free)Blocks Used)Blocks Bad)Blocks Sector)Calcula?ons I/O)Path
Manifest
sst
WAL
Data)Placement controlled)by)LSM I/O
Env*DFlash Env*Posix
PxWritableFile PxSequen?alFile PxRandomAccesslFile
CURRENT LOCK IDENTITY LOG* (Info) TradiGonal*SSD File*System
I/O
RocksDB*LSM
Device) Features Env)Op?ons Op?miza?ons Init
Code
25
backend ¡take ¡care ¡of ¡provisioning ¡ flash ¡blocks ¡
stored ¡in ¡the ¡Open-‑Channel ¡SSD, ¡ where ¡we ¡can ¡provide ¡QoS ¡
NVM) ¡and ¡can ¡potentially ¡provide ¡ blocks ¡from ¡different ¡drives ¡-‑> ¡single ¡ address ¡space
Open%Channel*SSD BM DFlash KERNEL*SPACE USER*SPACE
Provisioning)interface Block)device DFlash)File)(blocks) get_block() put_block() DFWritableFile DFSequen?alFile DFRandomAccesslFile
Free)Blocks Used)Blocks Bad)Blocks Sector)Calcula?ons I/O)Path
Manifest
sst
WAL
Data)Placement controlled)by)LSM I/O
Env*DFlash Env*Posix
PxWritableFile PxSequen?alFile PxRandomAccesslFile
CURRENT LOCK IDENTITY LOG* (Info) TradiGonal*SSD File*System
I/O
RocksDB*LSM
Device) Features Env)Op?ons Op?miza?ons Init
Code
26
RocksDB ¡ make ¡release
ENTRY ¡KEYS ¡ ¡ with ¡4 ¡threads DFLASH ¡ (1 ¡LUN) POSIX WRITES ¡ 10000 ¡keys 70MB/s 25MB/s 100000 ¡keys 40MB/s 25MB/s 1000000 ¡keys 25MB/s 20MB/s Page-‑aligned ¡ ¡ write ¡buffer
parameters). ¡Write ¡buffer ¡required ¡by ¡RocksDB ¡due ¡to ¡small ¡WAL ¡writes ¡
it ¡requires ¡lots ¡of ¡experimentation ¡for ¡each ¡configuration
Bare ¡Metal: ¡ ¡~180MB/s
27
RocksDB ¡ make ¡release
ENTRY ¡KEYS DFLASH ¡ (1 ¡LUN) POSIX READ 10000 ¡keys 5MB/s 300MB/s 100000 ¡keys 5MB/s 500MB/s 1000000 ¡keys 5MB/s 570MB/s No ¡page ¡ cache ¡ support
28
RocksDB ¡ make ¡release
ENTRY ¡KEYS DFLASH ¡ (1 ¡LUN) DFLASH ¡ (1 ¡LUN) ¡
(+ ¡simple ¡page ¡cache)
POSIX READ 10000 ¡keys 5MB/s 160MB/s 300MB/s 100000 ¡keys 5MB/s 280MB/s 500MB/s 1000000 ¡ keys 5MB/s 300MB/s 570MB/s
confirmed ¡our ¡hypothesis.
Simple ¡page ¡ cache ¡for ¡reads
29
characteristics ¡
reads ¡(DFSequentialFile) ¡at ¡block ¡granularity ¡
30
0" 200" 400" 600" 800" 1000" 1200" 1400" 1600" 1" 3" 5" 7" 9" 11" 13" 15" 17" 19" 21" 23" 25" 27" 29" 31" 33" 35" 37" 39" 41" 43" 45" 47" 49" 51" 53" 55" 57" 59" 61" 63"
MB/s" LUNs"ac5ve"
Read/Write"Performance"(MB/s)"
Write"KB/s" Read"KB/s"
FPGA ¡Prototype ¡Platform ¡before ¡ASIC: ¡
31
RocksDB ¡ make ¡release
ENTRY ¡ KEYS ¡ ¡ with ¡4 ¡ threads WRITES ¡ ¡ (1 ¡LUN) READS ¡ (1 ¡LUN) WRITES ¡ ¡ (8 ¡LUNS) READS ¡ (8 ¡LUNS) WRITES ¡ ¡ (64 ¡LUNS) READS ¡ ¡ (64 ¡LUNS) RocksDB ¡ DFLASH 10000 ¡keys 21MB/s 40MB/s X X X X 100000 ¡ keys 21MB/s 40MB/s X X X X 1000000 ¡ keys 21MB/s 40MB/s X X X X Raw ¡DFLASH ¡ (with ¡fio) 32MB/s 64MB/s 190MB/s 180MB/s 920MB/s 1,3GB/s
32
RocksDB
Ac#ve& memtable WAL … SST1 SST2 SST3 … SSTN
Merging&&&Compac#on w w w w w w r W R r r r r R/W r
ReadBonly& memtable
r
RO& MT RO& MT …
R R w r W
MANIFEST
W w r w r
Open,Channel1SSD Block1Manager
LUN0 LUN1 LUN2 LUN3 LUN4 LUN5 LUN6 LUN7 LUN8 LUN9 …
DFlash
get_block() put_block() Virtual&LUN Physical&LUN
… … … …
CH0 CH1 CHN
Lun0 LunN
WestLake
(prefetching)
33
does ¡GC ¡when ¡merging ¡sstables ¡in ¡LSM ¡> ¡L0 ¡
available ¡(RocksDB, ¡Kernel, ¡and ¡QEMU). ¡Working ¡on ¡WestLake ¡upstreaming ¡
storage ¡backend ¡(i.e., ¡tune ¡write ¡buffer ¡based ¡on ¡block ¡size) ¡-‑> ¡Upstreaming ¡
34
performance ¡constrains ¡(specially ¡in ¡terms ¡of ¡latency) ¡
35
36