data management over flash memory

71
Data management over flash memory Ioannis Koltsidas and Stratis D. Viglas SIGMOD 2011, Athens Greece

Upload: arch

Post on 25-Feb-2016

64 views

Category:

Documents


0 download

DESCRIPTION

Data management over flash memory. Ioannis Koltsidas and Stratis D. Viglas SIGMOD 2011, Athens Greece. Flash: a disruptive technology. Orders of magnitude better performance than HDD Low power consumption Dropping prices Idea: Throw away HDDs and replace everything with Flash SSDs - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Data management over flash memory

Data managementover flash memory

Ioannis Koltsidas and Stratis D. ViglasSIGMOD 2011, Athens Greece

Page 2: Data management over flash memory

Koltsidas and Viglas, SIGMOD 20112

Flash: a disruptive technology

Orders of magnitude better performance than HDD Low power consumption Dropping prices Idea: Throw away HDDs and replace everything with Flash SSDs

Not enough capacity Not enough money to buy the not-enough-capacity

However, Flash fits very well between DRAM and HDD DRAM/Flash/HDD price ratio: ~100:10:1 per GB DRAM/Flash/HDD latency ratio: ~1:10:100

Integrate Flash into the storage hierarchy complement existing DRAM memory and HDDs

Page 3: Data management over flash memory

Koltsidas and Viglas, SIGMOD 20113

Outline Flash-based device design

Flash memory Solid state drives Making SSDs database-friendly

System-level challenges Hybrid systems Storage, buffering and caching Indexing on flash Query and transaction processing

Page 4: Data management over flash memory

Koltsidas and Viglas, SIGMOD 20114

Outline Flash-based device design

Flash memory Solid state drives Making SSDs database-friendly

System-level challenges Hybrid systems Storage, buffering and caching Indexing on flash Query and transaction processing

Page 5: Data management over flash memory

Koltsidas and Viglas, SIGMOD 20115

Flash memory cells

Flash cell: a floating gate transistor Float gate Control Gate Oxide Layer

Electrons get trapped in the float gate Two states: float gate charged or not (‘0’ or ‘1’)

The charge changes the threshold voltage (VT) of the cell

To read: apply a voltage between possible VT values the MOSFET channel conducts (‘1’) or, it remains insulating (‘0’)

After a number of program/erase cycles, the oxide wears out

NSource

NDrain

PP-Type Silicon Substrate

Control Gate

Float Gate

Sour

ce L

ine

Bit L

ine

Oxide Layer

• Single-Level-Cell (SLC): one bit per cell• Multi-Level-Cell (MLC): two or more

bits per cello The cell can sense the amount of

current flowo Programming takes longer, puts more

strain on the oxide

Page 6: Data management over flash memory

Koltsidas and Viglas, SIGMOD 20116

Flash memory arrays NOR or NAND flash depending on how the cells are connected form arrays Flash page: the unit of read / program operations (typically 2kB – 8kB) Flash block: the unit of erase operations (typically 32 – 128 pages)

Before a page can be re-programmed, the whole block has to be erased first Reading much faster than writing a page

It takes some time before the cell charge reaches a stable state Erasing takes two orders of magnitude more time than reading

Consumer MLC(cMLC)

Enterprise MLC(eMLC) SLC

Page Read (μsec) 50 50 25

Page Program (μsec) 900 1500 250

Block Erase (μsec) 2000-5000 2000-5000 1500-2000

Endurance (P/E cycles) ~3K-5K ~30K ~100K

Page 7: Data management over flash memory

Koltsidas and Viglas, SIGMOD 20117

Outline Flash-based device design

Flash memory Solid state drives Making SSDs database-friendly

System-level challenges Hybrid systems Storage, buffering and caching Indexing on flash Query and transaction processing

Page 8: Data management over flash memory

Koltsidas and Viglas, SIGMOD 20118

Flash-based Solid State Drives Common I/O interface

Block-addressable interface No mechanical latency

Access latency independent of the access pattern 30 to 50 times more efficient in IOPS/$ per GB than HDDs

Read / Write asymmetry Reads are faster than writes Erase-before-write limitation

Limited endurance / wear leveling 5 year warranty for enterprise SSDs (assuming 10 complete re-writes per day)

Energy efficiency 100 – 200 times more efficient than HDDs in IOPS / Watt

Physical properties Resistance to extreme shock, vibration, temperature, altitude Near-instant start-up time

Page 9: Data management over flash memory

SSD challenges Host interface

Flash memory: read_flash_page, program_flash_page, erase_flash_block Typical block device interface: read_sector, write_sector

Writes in place would kill performance, lifetime Solution: perform writes out-of-place

Amortize block erasures over many write operations Writes go to spare, erased blocks; old pages are invalidated Device LBA space ≠ PBA space

Flash Translation Layer (FTL) Address translation (logical-to-physical mapping) Garbage collection (block reclamation) Wear-leveling

LBA space

PBA space

device level

flash chip levelFlash Translation Layer

logical page

flash page flash block spare capacity

Koltsidas and Viglas, SIGMOD 20119

Page 10: Data management over flash memory

10

SSD architecture Various form factors

PCI-eSAS (1.8” – 3.5”)SATA (1.8” – 3.5”)

Number of channels4 to 16 or more

RAM buffers1MB up to more than 256MB

Over-provisioning10% up to 40%

Command ParallelismIntra-commandInter-commandReordering / merging (NCQ)

Firmware (Flash Translation Layer – FTL)

SSD Architecture

GarbageCollector

WearLeveling

LBA-to-PBAmapper

Write PageAllocator

Request Handler LBA-to-PBAMap

Free BlockQueue

Bad BlockList

Meta DataCache

HostInterface

Micro-processor

ChannelController

FlashChip

RAM

DataBuffer

ChannelController

FlashChip

FlashChip

FlashChip

ECC

ECC

Koltsidas and Viglas, SIGMOD 2011

Page 11: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201111

LBA-to-PBA mapping

Page-Level Mapping (fully associative map) Each logical page may be mapped to any physical page Large memory footprint: 2MB / GB of Flash* (more RAM, supercaps)

0 1 2 3 4 5 6 …

Block 0

LBA

PBA

62 34

51

Block 1 Block 2 Block 3

62 34

51

• Block-Level Mapping (set-associative map)– Each logical block can be mapped to any physical block– Poor performance, esp. for small random writes

0 1 2 3 4 5 6 …

Block 0

LBA

PBABlock 1 Block 2 Block 3

Footprint: 32 KB/GB of flash*

*Assuming 2KB flash page, 128 KB flash block, 8 TB max. flash capacity

Page 12: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201112

LBA-to-PBA mapping: Logging Hybrid Mapping: two types of blocks (Logging)

Data blocks mapped at block granularity Log blocks mapped at page granularity Updates to data blocks performed as writes to log blocks

0 1 2 3 4 5 6 …

Log Block 0

LBA

PBA

62 3 51

Data Block 0

Data Block 1

Data Block 2

Data Block 3

[Gal & Toledo, ACM Comput. Surv., 37(2), 2005], [Chung et al., EUC 2006], [Kang et al., 2006], [Lee et al., SIGMOD 2008]

Log block sharing?

Log Block 0

Data Block 0

Data Block 1

Data Block 2

Data Block 3

Log Block 1

No : log block thrashingYes : costly garbage collection

Page 13: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201113

LBA-to-PBA mapping: Caching• Dynamically load mapping entries depending on the workload (Caching)– Page-level mapping stored on flash– A portion of the mapping is cached in RAM– Exploits temporal locality of accesses– Uniform block utilization during page updates

[Gupta et al., 2009]

• Data blocks• Translation blocks• Cached mapping

entries• Mapping table for

translation blocks–~ 4 KB / GB of

flash

DFTL, Gupta et. al 2009

Page 14: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201114

Garbage collection (1/3)

Goal: Reclaim a block with invalid pagesInvalid Page

Valid Page

Block i under GCPreviously free block j

(1) relocate

Free block i(2) erase

• Write amplification: the average number of flash writes per user write– Write latency– Device lifetime

• Write amplification heavily affected by:– Garbage Collection algorithm– Degree of over-provisioning– Workload

[Hu et al., SYSTOR 2009]

• Large sequential writes:

• Small random updates:

Page 15: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201115

Garbage collection (2/3)

Goal: Reclaim blocks, keeping write amplification as low as possible

Greedy GC: Always reclaim the block with the least number of valid pages

Too expensive!

Windowed Greedy GC: restrict search in a time window

Only look at the s oldest blocks

[Gal & Toledo, ACM Comput. Surv., 37(2), 2005], [Hu et al., SYSTOR 2009]

Spare factor (over-provisioning) is criticalMore spare blocks → more invalid pages per block → less write amplification

Page 16: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201116

Garbage collection (3/3) Writes are not uniform! Agnostic controller: blocks with mixed pages Separating controller: distinguishes between static / dynamic pages

Blocks with static data: almost no invalid pages Blocks with dynamic data: mostly invalid pages

Agnostic placement Separating placement

[Gal & Toledo, ACM Comput. Surv., 37(2), 2005], [Hu et al., SYSTOR 2009]

Page 17: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201117

Wear leveling Wear leveling and garbage collection have contradictory goals!

Wear leveling aims to reclaim static blocks, swapping them with dynamic blocks

Typical wear-leveling: each block has a cycle budget Upon each erasure, one cycle is consumed Wear-leveling kicks in when a block diverges from the device average

count The block with the max count is swapped with the block with the min

count (swap a dynamic block with a static one) Additional write amplification with each swap!

Albeit, much less than the amplification caused by GC Caveat: excessive wear leveling increases the overall wear

Page 18: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201118

Off-the-shelf SSDsA B C D E

Form Factor PATA Drive SATA Drive SATA Drive SAS Drive PCI-e card

Flash Chips MLC MLC MLC SLC SLC

Capacity 32 GB 100 GB 160GB 140GB 450 GB

Read Bandwidth

53 MB/s 285 MB/s 250 MB/s 220 MB/s 700 MB/s

Write Bandwidth

28 MB/s 250 MB/s 100 MB/s 115 MB/s 500 MB/s

Random 4kB Read IOPS

3.5k 30k 35k 45k 140k

Random 4kB Write IOPS

0.01k 10k 0.6k 16k 70k

Street Price: ~ 15 $/GB(2007)

~ 4 $/GB(2010)

~ 2.5 $/GB(2010)

~18 $/GB(2011)

~ 38 $/GB(2009)

EnterpriseEnterpriseConsumerConsumerConsumer

~ 1 order of magnitude

> 2 orders of magnitude

15k RPM SAS HDD: ~250-300 IOPS7.2k RPM SATA HDD: ~80 IOPS

Page 19: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201119

Read latency

0 20000 40000 60000 80000 100000 120000 140000 1600000

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

BCDE

IOPS

Late

ncy

(ms)

4 KB Random Reads uniformly distributed over the whole medium50% random data

Page 20: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201120

Write latency4 KB Random Writes uniformly distributed over the whole medium

50% random data

0 5000 10000 15000 20000 25000 30000 35000 40000 450000

0.5

1

1.5

2

2.5

3

B C D E

IOPS

Late

ncy

(ms)

Page 21: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201121

Mixed workload – Read latency4 KB I/O operations uniformly distributed over the whole medium

50% random data, Queue depth = 32

0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%0

0.5

1

1.5

2

2.5

3

3.5

4

Average Read Latency

B C D E

% of Writes

Resp

onse

Tim

e (m

s)

Page 22: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201122

Mixed workload – Write latency4 KB I/O operations uniformly distributed over the whole medium

50% random data, Queue depth = 32

0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%0

2

4

6

8

10

12

Average Write Latency

B C D E

% of Writes

Resp

onse

Tim

e (m

s)

0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%0

0.1

0.2

0.3

0.4

0.5

0.6

Average Write LatencyE

% of Writes

Resp

onse

Tim

e (m

s)

Page 23: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201123

uFlip (www.uflip.org)

The SSD is a black box for the system What kind of IO patterns should a flash-based DBMS favor or

avoid? Collection of micro-benchmarks tailored for SSDs Conclusions from experimental study include:

Reads and sequential writes are very efficient Flash-page-aligned I/O requests, request sizes are very beneficial Random writes within a small LBA address window incur almost the

same latency as sequential ones Parallel sequential writes to different partitions should be limited Pauses between requests do not improve overall performance

Benchmarking tool also provided

[Bouganim et al., CIDR 2009]

Page 24: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201124

Outline Flash-based device design

Flash memory Solid state drives Making SSDs database-friendly

System-level challenges Hybrid systems Storage, buffering and caching Indexing on flash Query and transaction processing

Page 25: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201125

In-page logging Page updates are logged Log sector for each DB page

Allocated when page become dirty Log region in each flash block Page write-backs only involve log-

sector writes Until a merge is required

Upon read: Fetch log records from flash Apply them to the in-memory page

Same or more number of writes But, significant reduction of erasures

[Lee & Moon, SIGMOD 2007]

However:– The DBMS needs to control physical placement – Partial flash page writes are involved

Page 26: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201126

SSD designers’ vs DBMS designers’ goals SSD designers assume a generic filesystem above the device

Goals: Hide the complexities of flash memory Improve performance for generic workloads and I/O patterns Protect their competitive advantage, by hiding algorithm and implementation

details

DBMS designers have full control of the I/O issued to the device

Goals:

Predictability for I/O operations, independence of hardware specifics

Clear characterization of I/O patterns

Exploit synergies between query processing and flash memory properties

[Bonnet et al., 2011]

Page 27: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201127

The TRIM command TRIM : a command to communicate logical page deletions to the device

Invalidation of flash pages before they are overwritten

Less write amplification

Improved write performance

Improved lifetime

Gaining adoption by SSD manufacturers, and OS / Filesystem designers

Linux 2.6.28, Windows 7, Mac OS X 10.7

Actual implementation varies across device manufacturers

Page 28: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201128

A richer interface to SSDs Stripped-down FTL, rich interface to the host What kind of interface would allow maximum

performance? Expose the internal geometry of the SSD (alignment,

mapping of pages to blocks, etc.)

Expose logical blocks in addition to logical pages

DMBS respects flash constraints (C1, C2, C3)

Wear-leveling still done by the device firmware

Bimodal FTL: I/O respecting constraints is “tunneled”

Unconstrained I/O

DBMS designer has full control on I/O performance But, a lot of re-writing is required

[Bonnet et al., 2011]

Page 29: Data management over flash memory

Parallelism? Still, some operations are more

efficient on hardware Mapping of the address space to flash planes,

dies and channels

ECC, encryption etc.

Wear-leveling still needs to be done by the device firmware

The internal device geometry is critical to achieve maximum parallelism

The DBMS needs to be aware of the geometry to some degree

ChannelController

FlashChip

ChannelController

FlashChip

FlashChip

FlashChip

ECC

ECC

0Logical block

1 2 3

01

23

Logical block size ≠ Flash block sizeLogical block size relevant to number of channels, pipelining capabilities on each

channel, etc.Koltsidas and Viglas, SIGMOD 201129

Page 30: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201130

SSDs – summary Flash memory has the potential to remove the I/O bottleneck

Especially for read-dominated workloads

“SSD”: multiple classes of devices Excellent random read latency is universal Read and write bandwidth varies widely Dramatic difference across random write latencies Dramatic differences in terms of economics: $/GB cost, power

consumption, expected lifetime, reliability A lot of research to be done towards defining DBMS-specific

interfaces

Page 31: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201131

Outline Flash-based device design

Flash memory Solid state drives Making SSDs database-friendly

System-level challenges Hybrid systems Storage, buffering and caching Indexing on flash Query and transaction processing

Page 32: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201132

Storage, buffering and caching

SSD persistent storage

HDD persistent storage

bufferpool

demandpaging

SSD cache

eviction

Page 33: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201133

Flash memory for persistent storage

SSD persistent storage

HDD persistent storage

bufferpool

SSD cache

Page 34: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201134

Hybrid storage layer

SSD persistent storage

HDD persistent storage

bufferpool

SSD cache

Page 35: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201135

Flash memory as cache

SSD persistent storage

HDD persistent storage

bufferpool

SSD cache

Page 36: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201136

Outline Flash-based device design

Flash memory Solid state drives Making SSDs database-friendly

System-level challenges Hybrid systems Storage, buffering and caching Indexing on flash Query and transaction processing

Page 37: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201137

Hybrid systems Problem setup

SSDs are becoming cost-effective, but still not ready to replace HDDs in the enterprise

Certainly conceivable to have both SSDs and HDDs at the same level of the storage hierarchy

Research questions How can we take advantage of the SSD characteristics when

designing a database? How can we optimally place data across both types of medium?

Methodologies Workload detection for data placement Load balancing to minimize response time Caching data between disks

Page 38: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201138

Storage layer

Workload-driven page placement Flash memory and HDD at the same

level of the storage hierarchy Monitor page use by keeping track of

reads and writes Logical operations (i.e., references only) Physical operations (actually touching

the disk) Hybrid model (logical operations

manifested as physical ones) Identify the workload of a page and

appropriately place it Read-intensive pages on flash Write-intensive pages on HDD Migrate pages when they have

expensed their cost if erroneously placedflash HDD

wSSD

wflash

Read/write operation

2-state task system

rflash (wflash) rSSD (wSSD)

User-level page I/O

Buffer manager

Storage manager

Replacement policy

SSD HDDPage migrations

Logical I/O operations

Requests for physical I/O

Physical I/O operations

[K & V, VLDB 2008]

Page 39: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201139

Object placement Hybrid disk setup Offline tool

Optimal object allocation across the two types of disk

Two phases Profiling: start with all objects on

the HDD and monitor system use Decision: based on profiling

statistics estimate performance gained from moving each object from the HDD to the SSD

Reduce the decision to a knapsack problem and apply greedy heuristics

Implemented in DB2

Database engine Bu

ffer

pool

m

onito

r

Storage system

Object placement

advisor

workload deviceparameters

Read/writes

Performancegain (s)

SSD budget ($)

SSD HDD

Cut-off point

[Canim, Mihaila, Bhattacharjee, Ross & Lang, VLDB 2009]

Page 40: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201140

Write caching SSD for primary storage, auxiliary HDD Take advantage of better HDD write performance to extend SSD

lifetime and improve write throughput Writes are pushed to the HDD

Log structure ensures sequential writes Fixed log size Once log is full merge writes back to the SSD

[Soundararajan, Prabhakaran, Balakrishnan, & Wobber, FAST 2010][Holloway PhD Thesis, UW-Madison, 2009]

write

SSD

HDD-resident log

read merge

Page 41: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201141

Load balancing to maximize throughput Setting consists of a transaction processing system with both types of disk Objective is to balance the load across media

Achieved when the response times across media are equal, i.e., a Wardrop equilibrium

Algorithms to achieve this equilibrium Page classification (hot or cold) Page allocation and migration

Storage ma

Indirect mapping table

Logical addr.

Device Physical addr.

HDD2

SSD2

Operation redirector

Hot/cold data classifier

Device performance monitor

Data (re)locator

Policy configuration

cacheStorage management layer

[Wu & Reddy, MASCOTS 2010]

Page 42: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201142

Outline Flash-based device design

Flash memory Solid state drives Making SSDs database-friendly

System-level challenges Hybrid systems Storage, buffering and caching Indexing on flash Query and transaction processing

Page 43: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201143

Buffering in main memory Problem setup

Flash memory is used for persistent storage Typical on-demand paging

Research questions Which pages do we buffer? Which pages do we evict and when?

Methodologies Flash memory size alignment Cost-based replacement Write scheduling

Page 44: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201144

Block padding LRU (BPLRU) Manages the on disk

RAM buffer Data blocks are organized

at erase-unit granularity LRU queue is on data

blocks On reference, move the

entire block to the head of the queue

On eviction, sequentially write the entire block

6 0

1 4

5

9

11

Blk 0Blk 2 Blk 3 Blk 1MRU block LRU block

9

11

6 4

5

0

1

Blk 2Blk 3 Blk 0 Blk 1

Logical sector 11 referenced

Victim block: logical sectors 4, 5 written

[Kim & Ahn, FAST 2008]

Page 45: Data management over flash memory

45

BPLRU: Further optimizations Use of padding

If a data block to be written has not been fully read, read what’s missing and write sequentially

LRU compensation Sequentially written

blocks are moved to the end of the LRU queue

Least likely to be written in the future

6

8

7

9

11

[Kim & Ahn, FAST 2008]

read

write

FTL readsmissingsectors andreplaces datablock in onesequential write

6

7

8

0

1 4

5

9

11

Blk 0Blk 2 Blk 3 Blk 1M

RU b

lock

LRU block

0

1

9

11

6

7

6

4

5

Blk 3Blk 0 Blk 1 Blk 2Koltsidas and Viglas, SIGMOD 2011

Page 46: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201146

Cost-based replacement Choice of victim depends on probability of reference (as

usual) But the eviction cost is not uniform

Clean pages bear no write cost, dirty pages result in a write I/O asymmetry: writes more expensive than reads

It doesn’t hurt if we misestimate the heat of a page So long as we save (expensive) writes

Key idea: combine LRU-based replacement with cost-based algorithms Applicable both in SSD-only as well as hybrid systems

Page 47: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201147

Clean-first regionWorking region

Clean first LRU (CFLRU) Buffer pool divided into two regions

Working region: business as usual Clean-first region: candidates for eviction Number of candidates is called the window size W

Always evict from clean-first region Evict clean pages before dirty ones to save write cost Improvement: Clean-First Dirty-Clustered [Ou, Harder & Jin, DAMON 2009]

Cluster dirty pages of the clean-first region based on spatial proximity

P2 P3 P4P1 P6 P7 P8P5

MRU LRU

dirty page clean page

Window size W

LRU order: P8, P7, P6, P5

CFLRU order: P7, P5, P8, P6

[Park, Yung, Kang, Kim & Lee, CASES 2006]

Page 48: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201148

Cost-based replacement in hybrid systems Similar to the previous idea, but for

hybrid setups SSD and HDD for persistent storage

Divide the buffer pool into two regions Time region: typical LRU Cost region: four LRU queues, one per

cost class Clean flash Clean magnetic Dirty flash Dirty magnetic

Order queues based on cost Evict from time region to cost region Final victim is always from the cost

region

Cost region

Time region

cost

[K & V, VLDB 2008]

Page 49: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201149

Append and pack Convert random writes to

sequential ones Shim layer between storage

manager and SSD On eviction, group dirty pages,

in blocks that are multiples of the erase unit

Do not overwrite old versions, instead write block sequentially

Invalidate old versions Pay the price of a few extra

reads but save the cost of random writes

[Stoica, Athanassoulis, Johnson & Ailamaki, DAMON 2009]

Shim storage manager layer

SSD persistent storage

random writes

group andwrite

sequentially

invalidate

Page 50: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201150

Caching in flash memory Problem setup

SSD and HDD at different levels of the storage hierarchy Flash memory used as a cache for HDD pages

Research questions When and how to use the SSD as a cache? Which pages to bring into the cache? How to choose victim pages?

Methodologies Optimal choice of hardware configuration SSD as a read cache Flash-resident extended buffer pools

Page 51: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201151

Incorporating SSDs into the enterprise Disciplined way of introducing

SSD storage Migration from HDDs to SSDs

Requirements and models analytically to solve the configuration problem

Simply replacing HDDs with SSDs is not cost-effective

SSDs are best used as a cache 2-tiered architecture Log and read cache on the

SSDs, data on the HDDs But even then the benefits are

limited

[Narayanan, Thereska, Donnelly, Elniketi & Rowstron, EuroSys 2009]

Workload requirements

Device models

Solverconfiguration

objectives

traces

specs

benchmarks

HDD tier

Write-ahead log Read cache SSD tier

write read

Page 52: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201152

The ZFS perspective Multi-tiered architecture Combination of logging and

read caching Flash memory is good for large

sequential writes in an append-only fashion (no updates)

Also good as a read cache for HDD data

Evict-ahead policy Aggregate changes from

memory and predictively push them to flash to amortize high write cost HDD tier

log Read cache SSD tier

Logoperations

Aggregate changes andpredictively push

bufferpool

[Leventhal, Commun. ACM, 51(7) 2008]

Page 53: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201153

DBMS buffer pool extensions Again a multi-tiered

approach Policies and algorithms for

caching in flash-resident buffer pools

SSD as secondary buffer pool Temperature-based eviction

policy from memory to SSD Pages are cached only if hot

enough Algorithms for syncing data

across the caches

[Canim, Mihaila, Bhattacharjee, Ross & Lang, PVLDB 2010][Holloway PhD Thesis, UW-Madison, 2009]

Main memory buffer pool

SSD buffer pool

HDD with logical regions

Temperature-based replacement

CPU/cache

(1) read record (6) write record

(2) read page

(3) read pagenot on SSD

(5) writedirty page

(6) updateSSD copy

(4) write page

Page 54: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201154

Putting it all together Extensive study of using flash memory

as cache Page flow schemes dictate how data

migrates across the tiers Inclusive: data in memory is also on

flash Exclusive: no page is both in memory

and on flash Lazy: an in-memory page may or may

not be on flash depending on external criteria

Cost model predicts how a combination of workload and scheme will behave on configuration

No magic combination; different schemes for different workloads and different HHDs and SSDs

[K & V, ADBIS 2011]

HDD persistent storage

bufferpool

SSD cache

Page 55: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201155

Outline Flash-based device design

Flash memory Solid state drives Making SSDs database-friendly

System-level challenges Hybrid systems Storage, buffering and caching Indexing on flash Query and transaction processing

Page 56: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201156

Indexing Problem setup

While presenting the same I/O interface as HDDs, flash memory has radically different characteristics

I/O asymmetry, erase-before-write limitation Research questions

How should we adapt existing indexing approaches? How can we design efficient secondary storage indexes – potentially

for more than one metric? Methodologies

Avoid expensive operations when updating the index Self-tuning indexing, catering for flash-resident data Combine SSDs and HDDs for increased throughput

Page 57: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201157

Semi-random writes Starting point is studying typical write access patterns in the context of sampling Fact: random writes hurt performance But careful analysis of a typical workload shows that writes are rarely completely

random Rather, they are semi-random

Randomly dispatched across blocks, sequentially written within a block Similar to the locality principles of memory access Take advantage of this at the structure design level and when issuing writes Bulk writes to amortize write cost

Block 1 Block 2 Block 3 Block n

timewrites seemingly randomly dispatched in time…

…but actually written sequentially within a block

[Nath & Gibbons, VLDB 2008]

Page 58: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201158

FlashDB: self-tuning B+-tree Reads are cheap, writes are potentially

expensive if random Two modes for B+-tree nodes

Disk mode: node is primarily read Log mode: node is primarily updated; instead

of overwriting, maintain log entries for the node and reconstruct on demand

Translation layer presents uniform interface for both modes

System switches between modes by monitoring use

Similar logging approach in [Wu, Kuo & Chang, ACM Trans. On Embedded Systems, 6(3), 2007] Difference is in when and how writes are

applied Buffered first, then batched and applied by

the B+-tree FTL

Node data

Log entries

merge B+-tree node

log mode

Disk mode

Log mode

migration costfrom disk to log

migration costfrom log to disk

Read/write operation

2-state task system

[Nath & Kansal, ISPN 2007]

Page 59: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201159

Making B+-trees flash-friendly (the FD-tree) Multiple levels in the index

Each progressive level of double size So long as we are not updating in place, and also performing large sequential writes to

amortize the cost, it’s all good FD-tree levels are sorted runs

Head-tree (first levels) in main memory Once a lower level exceeds its capacity it is merged with the next one Special entries (fences) are used to maintain the structure and deal with potential skew

each level a sorted run

When levelis full,merge withlower and writesequentially

[Li, He, Luo & Yi, ICDE 2009]

Page 60: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201160

Spatial indexing Similar observations as with B+-trees can be made on R-trees

They’re tree indexes after all! Lesson is largely the same: one needs to carefully craft the

structure and its algorithms for the new medium Batch updates to amortize write costs

[Wu, Chang & Kuo, GIS 2003] Trade cheap reads for expensive writes by introducing imbalance

[K & V, SSTD 2011] Systematic study on performance of R-trees on SSDs in

[Emrich, Graf, Kriegel, Schubert & Thoma, DAMON 2010] SSDs not as sensitive as HDDs to page size Capable of addressing higher dimensional data in less time

Page 61: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201161

Hash indexing based on MicroHash Setup is sensor nodes with limited memory

and processing capabilities Similar to extendible hashing techniques

Directory keeps track of bucket boundaries For each bucket maintain the last time it was

used S and the number of times it has been split C

Progressive expansion based on equi-width splitting Expansion triggered when the number of splits

exceeds some threshold Infrequently used buckets are flushed to SSD

Deletion through garbage collection and reorganization Batch updates are helpful

Generalization of linear hashing by lazy splitting in [Xiang, Zhou & Meng, WAIM 2008] Takes advantage of batch updates

directory

[0-10) S: 2C: 1

[10-20) S: 1C: 3

[20-30) S: 0C: 0

[30-40) S: 0C: 0

directory

[0-10) S: 2C: 1

[10-15) S: 1C: 0

[15-20) S: 3C: 1

[20-30) S: 0C: 0

[30-40) S: 0C: 0

evicted to flash

Reorganization(repartitioning)if split threshold is 2

[Zeinalipour-Yazti, Lin, Kalogeraki, Gunopulos & Najjar, FAST 2005]

Page 62: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201162

A design for hybrid systems (FlashStore)

[Debnath, Sengupta & Li, VLDB 2010]

HDD

destaging

Hash table index

Write buffer

Key-value pair

Read cache

Key-value pair

Recency bit vector

1 0 … 1

Disk presence Bloom filter

1 0 … 1 … 0

First valid page

Last valid page

Flash memory: recycled append logorganized as a cyclic list of pages,destaged to HDDbased on recency

RAM memory: write and read buffers and metadata

Keeps track of destaged entries

Page 63: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201163

Protocol

Server 2Server 1

Scalable reliable distributed log

Transaction management on flash: Hyder A different architecture for transaction

management The target is data centers

Shared data, multi-core nodes Need for scale-out Log-structured multi-versioned database

“The log is the database” No partitioning

Raw flash chips used for storage Though SSDs or even HDDs may be used

as well Three-layered architecture

Storage layer maintains shared log Index layer supports lookup and

versioning Transaction layer provides isolation and

continuously refreshes the database cache by running the “meld” algorithm

[Bernstein, Reid & Das, CIDR 2010]

Transaction input snapshot

Transaction intention (RW sets)

Broadcast to servers

Append to log

Forward intention

Assemble local log copy

Roll log forward

Page 64: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201164

Outline Flash-based device design

Flash memory Solid state drives Making SSDs database-friendly

System-level challenges Hybrid systems Storage, buffering and caching Indexing on flash Query and transaction processing

Page 65: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201165

Query and transaction processing Problem setup

Same types of query and transactional workload Different medium; not what existing approaches have been

optimized for Research questions

Are there problems that best fit to SSDs? Does one need radically different approaches, or slight adaptations? Where in the storage hierarchy should we use SSDs and how?

Methodologies Flash-aware algorithms either by design or through adaptation Offload parts of the computation to flash memory Economies of scale

Page 66: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201166

Old stories, new toys Impact of selectivity on predicate evaluation [Myers, MSc

Thesis, MIT, 2007] Overall, as selectivity factor increases performance degrades (needle

in haystack queries) At times HDDs might outperform SSDs

Join processing on SSDs using algorithms designed for HDDs [Do & Patel, DAMON 2009] SSD joins may well become CPU-bound, so ways to improve the CPU

performance become salient Trading random reads for random writes pays off Random writes result in varying I/O and unpredictable performance Blocked I/O still improves performance Block size should be a multiple of the page size

Page 67: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201167

Impact of storage layout: the FlashJoin Storage layout based on PAX No need to retrieve what’s

not necessary Use a specialized operator

(FlashScan) for on-the-fly projections over PAX

Delegate join computation to two steps Fetching data by projecting

relevant (the fetch kernel) Evaluate the join predicate

(through the join kernel) and materialize the result in a join index

FlashScan

FlashScan

R1(A, B, C) R2(D, E, G, H)

Fetch kernel

Join kernelA = D

Fetch kernel

Join kernelG = K

FlashScan

R3(F, K, L)A D

K

B, C

F

E, H

G

B, C, E, H, Fselect R1.B, R1.C, R2.E, R2.H, R3.Ffrom R1, R2, R3where R1.A = R2.D and R2.G = R3.K

[Tsirogiannis, Harizopoulos, Shah, Wiener & Graefe, SIGMOD 2009]

Page 68: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201168

Buffer layer in memory

Filter layer on SSD

Membership queries Motivation: poor locality of Bloom filters

Hurts cache performance in CPU-intensive applications Good candidate for offloading to flash memory Good random read performance compared to HDDs, but we still need to

cross the memory-disk boundary Solution: being lazy pays off

Defer reads and writes and through buffering Introduce hierarchical structure to account for disk-level paging

0110110001011001 1100110001011011 1100110101011010 0011110001011010

Buffer blockskeep trackof deferredreads and writesDisk pages act as

sub-Bloom filters

[Canim, Mihaila, Bhattacharjee, Lang & Ross, ADMS 2010]

Page 69: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201169

Database operations suited for SSDs Given transactional and query processing workloads,

which operations are SSDs better for? Study of the I/O patterns Identify server storage spaces that exhibit SSD-friendly

I/O patterns Tables, indexes, temporary storage, log, rollback segments

Secondary structures are better suited for SSDs Long sequential writes (no updates) and random reads Performance improvement more than one order of magnitude

when logging and rollback segments are delegated to SSDs Factor of two improvement when temporary storage is on SSDs

[Lee , Moon, Park, Kim & Kim, SIGMOD 2008]

Page 70: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201170

Inexpensive logging in flash memory As mentioned, logging is one of the best fits for SSDs

Typically, writes are appended to the log The online version of the log is usually small USB flash memory is cheap and USB ports are abundant Intuition: spread the log across multiple cheap USB flash disks

Provide simple logging interface

[Chen, SIGMOD 2009]

worker

worker

archiver

…In-memory log buffer

Request queue

Interfacewrite, flush, checkpoint;recovery

Page 71: Data management over flash memory

Koltsidas and Viglas, SIGMOD 201171

Outlook SSD is a diverse class of devices

The only common characteristic of all members of the class is the excellent random read performance

Underlying technology affects performance in other operations SSDs do not completely dominate HDDs – not yet

Some types of SSD may be an order of magnitude slower than HDDs in random writes Where do they fit in the database stack?

Persistent storage – maybe in combination with HDDs Read cache of HDD data Transactional logging Using the HDD as a log-structured write-cache for the SSD Temporary storage and staging area Any of the above

More research necessary at the SSD/DB interfaces