SLIDE 1
Handling Differences in Execution Environment
Nachshon Cohen, EPFL
SLIDE 2 Durable & Transient Representation
class Person{ char *name; Person *spouse; lock plock; virtual research(); }
Transient Person: doesn’t survive restarts
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
Durable & Transient Representation
Keep two representations Significant effort Can we do better? Sure, use NVM!
SLIDE 5
Durable & Transient Representation
Durable NVM person class Person{ PTR<char> name; PTR<Person> spouse; executionLock plock; / / virtual research(); int CoffeeLevel; }
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
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
Outline
Why Durable NVM Person is so complex? How NvmReconstruction solves these problems? Demonstration and measurements
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
Virtual Methods?
Implemented by Virtual Table Pointer (VTP) But: VTPs may move between executions A B virtual research()
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
No Virtual Methods!
NO SUPPORT for virtual methods NO SUPPORT for function pointers If program uses virtual methods Significant programmer effort
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 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
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
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 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
NvmReconstruction
Solve all problems above Simple interface No compiler support needed Zero overhead after recovery
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
Main Idea
For each live object: Requires: type of the object (or VTP) field information Fix VTP Rebase pointers Zero transient fields
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
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
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
Demonstration and Measurements
Restart time? How easy it is to write recovery?
SLIDE 25
Restart time
1GB heap, 50% populated 347µs per MB for first access Tradeoff restart-time and efficiency
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
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
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