nvmove: helping programmers move to byte-based...

51
NVMOVE NVMOVE: Helping Programmers Move to Byte-based Persistence Himanshu Chauhan with Irina Calciu, Vijay Chidambaram, Eric Schkufza, Onur Mutlu, Pratap Subrahmanyam

Upload: others

Post on 18-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

NVMOVE

NVMOVE: Helping Programmers Move to Byte-based Persistence

Himanshu Chauhan

withIrina Calciu, Vijay Chidambaram,

Eric Schkufza, Onur Mutlu, Pratap Subrahmanyam

Page 2: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Fast, but volatile.

Persistent, but slow.

Cache

DRAM

SSD

Hard Disk

Critical Performance Gap

Page 3: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Fast, but volatile.

Persistent, but slow.

Cache

DRAM

SSD

Hard Disk

Non-Volatile MemoryFast, and persistent.

Page 4: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Cache

DRAM

SSD

Hard Disk

Page 5: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Persistent Programs

1. allocate from memory

2. data read/write + program logic

3. save to storage

typedef struct {

} node

Page 6: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Persistence TodayPersistence Today

In-memory binary search tree

Flat Buffer

File

Block-based Storage

Serialization

Block-sized Writes

sprintf(buf, “%d:%s”, node->id, node->value)

write(fd, buf, sizeof(buf)) fsync(fd)

Page 7: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Persistence with NVMIdeal Persistence on NVM

In-memory binary search tree

Byte-based NVM Byte-sized Writes

node->id = 10 pmemcopy(node->value, myvalue)

pmemobj_persist(node)

Page 8: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Changing Persistence Code

/* allocate from volatile memory*/node n* = malloc(sizeof(…))

node->value = val //volatileupdate

/* allocate from non-volatile memory*/node n* = pmalloc(sizeof(…))

node->value = val //persistent update

/* flush cache and commit*/__cache_flush + __commit

Present NVM

/* persist to block-storage*/char *buf= malloc(sizeof(…));int fd = open("data.db",O_WRITE);sprintf(buf,"…", node->id,

node->value);write(fd, buf, sizeof(buf));

Page 9: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Porting to NVM: Tedious

• Identify data structures that should be on NVM

• Update them in a consistent manner

Redis: simple key-value store (~50K LOC)- Industrial effort to port Redis is on-going after two years

- Open-source effort to port Redis has minimum functionality

Page 10: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Changing Persistence Code

/* allocate from volatile memory*/node n* = malloc(sizeof(…))

node->value = val //volatileupdate

/* allocate from non-volatile memory*/node n* = pmalloc(sizeof(…))

node->value = val //persistent update

/* flush cache and commit*/__cache_flush + __commit

Present NVM

/* persist to block-storage*/char *buf= malloc(sizeof(…));int fd = open("data.db",O_WRITE);sprintf(buf,"…", node->id,

node->value);write(fd, buf, sizeof(buf));

Page 11: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Goal:Port existing applications to

NVM with minimal programmer involvement.

Page 12: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile
Page 13: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

By Kiko Alario Salom [CC BY 2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons

Page 14: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Persistent Types in Source

User defined source types (structs in C)that are persisted to block-storage.

Block Storage

Application Code

Page 15: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

First Step:Identify persistent types in

application source.

Page 16: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Solution: Static Analysis

Page 17: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Current Focus: C

types = structs

Page 18: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Block Storage

Application Code

write system call

Page 19: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

write system call

/* persist to block-storage*/char *buf= malloc(…))int fd = open(…)

sprintf(buf,”…”,node->value)

write(fd, buf, …)

node *n = malloc(sizeof(node))

iter *it = malloc(sizeof(iter))

node

Page 20: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

write system call

/* persist to block-storage*/char *buf= malloc(…))int fd = open(…)

sprintf(buf,”…”,node->value)

write(fd, buf, …)

node *n = malloc(sizeof(node))

iter *it = malloc(sizeof(iter))

node

Page 21: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

iter

write system call

/* persist to block-storage*/char *buf= malloc(…))int fd = open(…)

sprintf(buf,”…”,node->value)

write(fd, buf, …)

node *n = malloc(sizeof(node))

iter *it = malloc(sizeof(iter))

node

Page 22: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

write system call/* persist to block-storage*/…

write(fd, buf, …)

node

/* write to error stream*/…

write(stderr, “All is lost.”, …)

/* write to network socket*/…

write(socket, “404”, …)

Storage NetworkPipe

Page 23: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Block Storage

Save to block-storage

node

Page 24: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Block Storage

Save to block-storage Load/recover

node

Page 25: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

“rdbLoad” is the load/recovery function.

Page 26: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Mark every type that can be created during the recovery.

*if defined in application source.

Page 27: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

rdbLoad

externallibrary

Call Graph from Load

Page 28: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

rdbLoad

externallibrary

BFS on Call Graph from Load

Page 29: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

externallibrary

BFS on Call Graph from Load

Application type created/modified

Page 30: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

NVMovE Implementation

• Clang- Frontend Parsing

• Parse AST and Generate Call Graph- Find all statements that create/modify application types in graph

• Currently supports C applications

Page 31: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Evaluation

Page 32: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

• In-memory data structure store- strings, hashes, lists, sets, indexes

• On-disk persistence— data-snapshots(RDB),

— command-logging (AOF)

• ~50K lines-of-code

Page 33: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Identification Accuracy

122 types (structs) in Redis Source

Page 34: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Identification Accuracy

Page 35: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Identification Accuracy

Page 36: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Identification Accuracy

Total types 122NVMOVE identified persistent types 25True positives (manually identified) 14False positives 11False negatives 0

Page 37: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Performance Impact

Page 38: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Redis Persistence

Snapshot (RDB) Logging (AOF)

• Data snapshot per

second

• Not fully durable

• Append each update

command to a file

• Slow

Both performed by forked background process.

Page 39: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

NVM Emulation

• Emulate allocation of NVMovE identified

types on NVM heap

- Slow and Fast NVM

- Inject delays for load/store of all NVM allocated types.

- Worst-case performance estimate.

• Compare emulated NVM throughput against

logging, and snapshot based persistence.

Page 40: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

YCSB Benchmark Results

Fraction of in-memory throughput

write-heavy (90% updated, 10% read ops)

0.11

0.24

0.36

0.45

0.98

Logging (disk) Logging (ssd) NVM (slow) NVM (fast) Snapshot (ssd)

in-memory (=1.0)

Possible Data loss111 MB

Page 41: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Performance without False-Positives

Speedup in throughput

1.04x

1.49x

Slow NVM

Fast NVM

1.0

Page 42: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

First Step:Identify persistent types in

application source.

Page 43: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Next steps:

• Improve identification accuracy. • Evaluate on other applications.

Page 44: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Backup

Page 45: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Throughputs (ops/sec)

readheavy balance writeheavy

PCM 28399 25,302 9759

STTRam 41213 38,048 12155

AoF (disk) 15634 6,457 2868

AoF (SSD) 27946 17,612 6605

RDB 46355 47,609 26605

Memory 50163 48,360 27156

Page 46: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

NVM Emulation

Read Latency

Cache-lineFlush Latency

PCOMMITLatency

STT-RAM(Fast NVM)

100 ns 40 ns 200 ns

PCM(Slow NVM)

300 ns 40 ns 500 ns

*Xu & Swanson, NOVA: A Log-structured File System for Hybrid Volatile/Non-volatile Main Memories, FAST16.

Page 47: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

YCSB Benchmark Results

Fraction of in-memory throughput

in-memory (=1.0)

PCM STT AOF(disk)

AOF(ssd)

RDB PCM STT AOF(disk)

AOF(ssd)

RDB

read-heavy

PCM STT AOF(disk)

AOF(ssd)

RDBNVM

Page 48: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

YCSB Benchmark Results

Fraction of in-memory throughput

in-memory (=1.0)

PCM STT AOF(disk)

AOF(ssd)

RDB PCM STT AOF(disk)

AOF(ssd)

RDB PCM STT AOF(disk)

AOF(ssd)

RDB

read-heavy balanced

NVM NVM

Page 49: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

YCSB Benchmark Results

Fraction of in-memory throughput

in-memory (=1.0)

PCM STT AOF(disk)

AOF(ssd)

RDB PCM STT AOF(disk)

AOF(ssd)

RDB PCM STT AOF(disk)

AOF(ssd)

RDB

read-heavy balanced write-heavy

NVM NVM NVM

Page 50: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

RDB Data Loss

read-heavy balanced write-heavy

26 MB111 MB42 MB

Page 51: NVMOVE: Helping Programmers Move to Byte-based Persistencevijay/papers/inflow16-nvmove-slides.pdf · Fast, but volatile. Persistent, but slow. Cache DRAM SSD Hard Disk Non-Volatile

Performance without False-Positives

Speedup in

throughput

PCM STT PCM STT AOF(disk)

AOF(ssd)

PCM STT AOF(disk)

AOF(ssd)

read-heavy balanced write-heavy

RDB(disk)

RDB(disk)

1.0

1.13x1.04x1.03x

1.15x

1.49x

1.09x

PCM PCM PCMSTT STT STT