Handling Differences in Execution Environment Nachshon Cohen , EPFL - - PowerPoint PPT Presentation

handling differences in execution environment
SMART_READER_LITE
LIVE PREVIEW

Handling Differences in Execution Environment Nachshon Cohen , EPFL - - PowerPoint PPT Presentation

Handling Differences in Execution Environment Nachshon Cohen , EPFL Durable & Transient Representation Transient Person: doesnt survive restarts class Person{ char *name; Person *spouse; lock plock; virtual research(); } Durable


slide-1
SLIDE 1

Handling Differences in Execution Environment

Nachshon Cohen, EPFL

slide-2
SLIDE 2

Durable & Transient Representation

class Person{ char *name; Person *spouse; lock plock; virtual research(); }

Transient Person: doesn’t survive restarts

slide-3
SLIDE 3

Durable & Transient Representation

class Person{ char *name; Person *spouse; lock plock; virtual research(); } DurablePerson scheme sqlString<30> name; id spouse; int CoffeeLevel;

Transient Person: doesn’t survive restarts Durable Person: survives restarts

slide-4
SLIDE 4

Durable & Transient Representation

Keep two representations Significant effort Can we do better? Sure, use NVM!

slide-5
SLIDE 5

Durable & Transient Representation

Durable NVM person class Person{ PTR<char> name; PTR<Person> spouse; executionLock plock; / / virtual research(); int CoffeeLevel; }

slide-6
SLIDE 6

Durable & Transient Representation

Weird pointers Different lock No virtual methods or function pointers class Person{ PTR<char> name; PTR<Person> spouse; executionLock plock; / / virtual research(); int CoffeeLevel; }

slide-7
SLIDE 7

Durable & Transient Representation

class Person : public nvm_obj{ char *name; Person *spouse; lock plock; virtual research(); REGISTER_CLASS(Person); REGISTER_NVMPTR(name, spouse); REGISTER_TRANSIENT(plock); } NvmReconstruction Person: survives restarts Retains original structure API discussed later

slide-8
SLIDE 8

Outline

Why Durable NVM Person is so complex? How NvmReconstruction solves these problems? Demonstration and measurements

slide-9
SLIDE 9

Why Durable NVM Person is so Complex?

  • 1. Why cannot use virtual methods?
  • 2. Why cannot use standard pointers?
  • 3. Why need special lock?
  • 4. Why cannot use pointers to DRAM?
slide-10
SLIDE 10

Virtual Methods?

Implemented by Virtual Table Pointer (VTP) But: VTPs may move between executions A B virtual research()

slide-11
SLIDE 11

No Virtual Methods!

A call to a virtual method executes arbitrary code. Similar problem for function pointers in C. A B virtual research() Erase filesystem Virtual Table Pointers may be moved

slide-12
SLIDE 12

No Virtual Methods!

NO SUPPORT for virtual methods NO SUPPORT for function pointers If program uses virtual methods Significant programmer effort

slide-13
SLIDE 13

NVM Pointers?

base = mmap(0x1000, …, nvm_fd); But, kernel may mmap to a different address A B

0x1000 0x1200

virtual research()

slide-14
SLIDE 14

No NVM Pointers !?

base = mmap(0x1000, …, nvm_fd); But, kernel may mmap to a different address A E.g., 0x2000 Invalidate pointers

0x2000 0x1200

B v

slide-15
SLIDE 15

Weird NVM Pointers

Store offset instead of virtual address Slower Different signature, dereference via a method MUST NOT have a pointer signature Programmer effort

slide-16
SLIDE 16

Intermixing Volatile and Non- Volatile Fields

Forbid NVM to DRAM pointers [ASPLOS’11] However: shown to be quite common and useful [HotStorage’17] Thus: programmer effort Execution specific lock [ASPLOS’11] Different signature, programmer effort

slide-17
SLIDE 17

Durable Person is Complex

  • 1. Cannot use virtual methods!
  • 2. Cannot use standard pointers!
  • 3. Need special lock!
  • 4. Cannot use DRAM pointers!
slide-18
SLIDE 18

NvmReconstruction

Solve all problems above Simple interface No compiler support needed Zero overhead after recovery

slide-19
SLIDE 19

Main Idea

During re-execution, need to reconstruct objects class Person{ char *name; Person *spouse; lock plock; virtual research(); }

NVM Correct VTP 0xF00D 0xCAFE spouse 0x1200 0x2200 etc. X f(X)

slide-20
SLIDE 20

Main Idea

For each live object: Requires: type of the object (or VTP) field information Fix VTP Rebase pointers Zero transient fields

slide-21
SLIDE 21

Get Object Type

VTP uniquely identify the object type However: VTP is correct for previous execution. Solution: Map VTP to class name. Store on NVM. Get mapping: from previous VTP to class name. Thus: map previous VTP to current VTP. Fix Type.

slide-22
SLIDE 22

Field Information

Use virtual methods to query the object layout reconstructObj(void *obj){ nvm_obj *nobj = (nvm_obj*)obj; pointers = nobj->getNvmPtr(); foreach p in pointers p -= mmap_offset; API: REGISTER_NVMPTR(name, spouse); virtual method common interface

slide-23
SLIDE 23

Lazy Algorithm

Reconstructing entire heap is time consuming Large restart time Lazy reconstruction: reconstruct a page on first access Using memory protection mechanism Immediate restart

slide-24
SLIDE 24

Demonstration and Measurements

Restart time? How easy it is to write recovery?

slide-25
SLIDE 25

Restart time

1GB heap, 50% populated 347µs per MB for first access Tradeoff restart-time and efficiency

slide-26
SLIDE 26

Echo Key-Value Store

Fast Key-Value Store Over 15,000 lines of code Uses function pointers NVM pointers pthread_mutex pointers (in DRAM)

slide-27
SLIDE 27

Echo Key-Value Store + NvmReconstruction

Less than 1.5 days to write recovery code Many crashes in original code Less than 1 hour to apply actual API Easy to use

slide-28
SLIDE 28

Summary: NvmReconstruction

NVM allows to easily persist data But does not preserve the semantics of the data NvmReconstruction: reconstruct durable objects Each to use: persist a class in a few minutes! No weird restrictions