Top Banner
1 NV-Heaps: Making Persistent Objects Fast and Safe with Next-Generation, Non-Volatile Memories Joel Coburn Work done at UCSD with Adrian M. Caulfield, Ameen Akel, Laura M. Grupp, Rajesh K. Gupta, Ranjit Jhala, Steven Swanson
31

Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

Jun 28, 2018

Download

Documents

buikhanh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

1

NV-Heaps: Making Persistent Objects Fast and Safe with Next-Generation, Non-Volatile Memories

Joel Coburn Work done at UCSD with Adrian M. Caulfield, Ameen Akel, Laura M. Grupp, Rajesh K. Gupta, Ranjit Jhala, Steven Swanson

Page 2: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

2

Spin-torque MRAM

Emerging Non-volatile Memories

Phase change memory

Memristor

• Device characteristics – As fast as DRAM – As dense as flash – Non-volatile – Reliable

• Applications

– DRAM replacements – Fast storage

Page 3: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

3

The Future of Storage

Lat.: 7.1ms 1x BW: 2.6MB/s

1x

68us 104x

250MB/s 96x

8.2us 865x

1.6GB/s 669x

1.5us 4733x

14GB/s 5384x

Hard Drives PCIe-Flash 2007

NVM

PCIe-NVM 2013?

NVM

DDR-NVM 2016?

= 2.5x/yr

= 2.6x/yr *Random 4KB reads from user space

Page 4: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

4

Overhead of Software

1

10

100

1000

10000

Disk Flash Fast NVM

Log

Requ

est L

aten

cy (u

s) File System

OSHardware

Page 5: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

5

Redefining Persistence for the Programmer

Physical Storage

Low-level IO

File System

Process Isolation

Applications

Old Way: Treat it like disk

- Build an NVRAM “disk” - Read/Write via the OS

and file system

New Way: Treat it like Memory

-Avoid the OS! -Create classes

-Use pointers/references -Leverage strong types

Physical Storage

Low-level IO

File System

Process Isolation

Applications

Familiar way to build persistent data structures

Page 6: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

6

Overview

• Motivation • Requirements for NV-Heaps • System Implementation • Benchmark performance • Conclusion

Page 7: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

7

Expose NVMs as raw storage

• Map into virtual address space

• Access through loads and stores

DRAM

NV Heap

Volatile Heap

NV Memory

Virtual Physical

Page 8: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

8

The Dangers of Direct Access

• All existing programming errors are still possible – Memory leaks – Multiple frees – Locking errors

• Programmers will get this stuff wrong Rebooting/restarting won’t help!

Page 9: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

9

Volatile Non-Volatile

New Types of Bugs

NV-Heap

NV-Heap

Volatile Heap

Pointer Type V-to-V V-to-NV NV-to-V Inter-heap NV-to-NV Intra-heap NV-to-NV

Valid?

? ?

Page 10: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

10

Existing Primitives are Error Prone

Is a volatile? Is l? Are they in the same heap?

void Insert(Object * a, List<Object> * l) { ... }

One wrong call causes permanent corruption

Page 11: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

11

Memory Management, Locking, and NV Pointers

• Manual memory management and locking disciplines are well-known sources of errors

• Both rely on a program-wide invariant that is… – Not specified in the source – Not enforced by the system

• NV pointer safety relies on a similar invariant • Programmers will get it wrong

Page 12: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

12

How hard is it to get right?

Example: BPFS [SOSP 09] – Transactional file system for NVM on memory bus – Carefully engineered NV data structure – Exploits FS tree structure and limited operations – Well worth the effort for a file system

Methodology does not scale for writing your average application!

Need a persistent object system for fast NVMs

Page 13: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

13

Persistent Object Systems • Slow but safe

– Database frontends (Java Persistence, C# LINQ) – Object-oriented databases (Objectstore [CACM 91], Texas

[POS 92], Quickstore [SIGMOD 94], Thor [SIGMOD 96]) – Transactional storage library (Stasis [OSDI 06]) – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96]

• Fast but unsafe – Recoverable Virtual Memory [SOSP 93] – Rio Vista (battery backed DRAM) [SOSP 97]

• Fast and safer – Mnemosyne (targets NVM) [ASPLOS 11]

Page 14: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

14

NV-Heaps: Safe Persistent Objects 1. Safety

– Garbage collection – Pointer safety – Transactions

2. Performance – Approach raw NVM performance

3. Scalability – Operations are O(touched data) not O(storage size)

4. Easy to use – Familiar interface – Leverage existing file systems and tools – Intuitive separation between volatile and non-volatile data

Page 15: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

15

Overview

• Motivation • Requirements for NV-Heaps • System Implementation • Benchmark performance • Conclusion

Page 16: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

16

Example Code – Linked List

class NVList : public NVObject { DECLARE_POINTER_TYPES(NVList); public: DECLARE_MEMBER(int, value); DECLARE_PTR_MEMBER(NVList::NVPtr, next); };

void remove(int k) { NVHeap * nv = NVHOpen(“foo.nvheap”); NVList::VPtr a = nv->GetRoot<NVList::NVPtr>(); AtomicBegin { while (a->get_next() != NULL) { if (a->get_next()->get_value() == k) { a->set_next(a->get_next()->get_next()); } a = a->get_next(); } } AtomicEnd; }

Page 17: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

17

NV-Heaps

Implementation

Locking, logging, and recovery

Reference counting Pointer assignments Pointer type enforcement Reclamation

Memory mapping Allocation and deallocation Relocatability

NVM Allocation

Garbage Collection Pointer Safety

Transaction Management

Page 18: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

18

NVM Allocator

• Raw allocation and de-allocation – Per-thread free lists – Fixed-sized, write-ahead logging for atomicity and

durability – Epoch barriers for consistency [SOSP 09] or

combination of mfence and clflush • Mapping

– “Execute in place” support in Linux – Relative pointers for relocation

Page 19: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

19

Garbage Collection + Pointer Safety

• Reference-counting – Per-object locks protect reference counts – Weak references for cycles

• Dynamic type system prevents dangerous NV pointers – Wide pointers allow run-time checks on

assignments – A static type system is also possible

Page 20: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

20

Challenge: Scalable locking

• NV-heaps require per-object locks • Volatile locks don’t scale

– Volatile storage rises with NV-heap size

• Non-volatile locks don’t scale – On recovery, all locks need to be released – Recovery time scales with NV-heap size

Page 21: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

21

Generational Locks

< Lock Generation

4 4

Unlocked

Acquire the lock 5

Locked

Open the heap: Move to the next generation

All locks released!

5

Unlocked

Page 22: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

22

General, ACID Transactions

• Software transactional memory system – Object-based, undo logging – Eager conflict detection with locks and version

numbers

• Logging – Per-thread NV write logs and V read logs – Using GC objects and pointers

Page 23: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

23

Overview

• Motivation • Requirements for NV-Heaps • System Implementation • Benchmark performance • Conclusion

Page 24: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

24

0.1

1

10

100

1000

10000

Btree SPS Hash 6-Degrees Average

Log

Spee

dup

Rela

tive

to S

tasi

s Ram

Dis

k Stasis RamDisk

BDB RamDiskNV-Heaps PCMNV-Heaps STTMNV-Heaps DRAM

Comparison to Other Systems

6.5X

13 to 1110X speedup over Stasis 2 to 643X speedup over BDB

Page 25: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

25

NV-Heaps

NVM Allocation

Garbage Collection Pointer Safety

Transaction Management

Layers of Safety

Base

Safe

TX C-TX

Page 26: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

26

Price of Safety

0

0.5

1

1.5

2

2.5

Btre

e Ba

seBt

ree

Safe

Btre

e TX

Btre

e C-

TX

SPS

Base

SPS

Safe

SPS

TXSP

S C-

TX

Hash

Bas

eHa

sh S

afe

Hash

TX

Hash

C-T

X

RBtr

ee B

ase

RBtr

ee S

afe

RBtr

ee T

XRB

tree

C-T

X

6-De

gree

s Bas

e6-

Degr

ees S

afe

6-De

gree

s TX

6-De

gree

s C-T

X

SSCA

Bas

eSS

CA S

afe

SSCA

TX

SSCA

C-T

X

Ave

Base

Ave

Safe

Ave

TXAv

e C-

TX

Spee

dup

vs. B

ase

8 threads4 threads2 threads1 thread

30% 11X 8.4X

Page 27: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

27

0

20000

40000

60000

80000

100000

120000

Memcachedb NV-heapsPCM

NV-heapsSTTM

NV-heapsDRAM

Memcached

Ope

ratio

ns/s

ec

Application: Memcachedb

39X 8 to 28% slowdown

Page 28: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

28

Looking Forward • Worse than DRAM, better than flash

– How do we handle microsecond write times? – What does the new storage hierarchy look like?

• Hardware support for storage on the memory bus

– Virtual memory overhead is high (TLB misses) – Costly memory fences and cacheline flushes

• What else do we need to guarantee safety?

– Language support, program verification, application fsck, etc.

• Distributed storage using fast NVMs – Can we scale this abstraction to networked storage?

Page 29: Coburn ASPLOS2011 NV-Heaps - snia.org · – Single-level stores (as400, Opal, etc.) – Orthogonally persistent Java [SIGMOD 96] • Fast but unsafe – Recoverable Virtual Memory

29

Conclusion

• NV-heaps give us robust non-volatile data structures in fast, non-volatile memory – Provide safe, easy to use, persistent objects – Very large application-level improvements

• Rethinking IO for NVMs is a major win!