rethinking applications in the nvm era
play

Rethinking Applications in the NVM Era Amitabha Roy ex- Intel - PowerPoint PPT Presentation

Rethinking Applications in the NVM Era Amitabha Roy ex- Intel Research NVM = Non Volatile Memory Like DRAM, but retains its contents across reboots Past: Non Volatile DIMMs Memory DIMM + Ultra-capacitor + Flash Contents


  1. Rethinking Applications in the NVM Era Amitabha Roy ex- Intel Research

  2. NVM = Non Volatile Memory ● Like DRAM, but retains its contents across reboots ● Past: Non Volatile DIMMs ○ Memory DIMM + Ultra-capacitor + Flash ○ Contents dumped on power fail, restored on startup ○ DRAM style access and performance but non-volatile ● Future: New types of non volatile memory media ○ Memristor, Phase Change Memory, Crossbar resistive memory, 3DXPoint ○ 3DXPoint DIMMS (Intel and Micron), demoed at Sapphire NOW 2017 ○ Non Volatile without extra machinery - practical

  3. Software Design ● New level in the storage hierarchy Disk/SSD NVM DRAM Persistent Persistent Volatile Block oriented Byte oriented Byte oriented Slow Fast Fast ⇒ Fundamental breakthroughs in how we design systems

  4. Use Case: Rocksdb ● Rocksdb - open source persistent key value store ● Optimized for Flash SSDs ● persistent map<key:string, value:string> ● Two levels (LSM tree) - sorted by key PUT(<K, V>) Absorb updates quickly L0: DRAM OK Flush large batches to SSD L1: SSD

  5. Use Case: Rocksdb ● Problem: Lose all data in DRAM on power fail ● Durability guarantee requires a write ahead log ● Solution: synchronously append to a write ahead log PUT(<K, V>) Absorb updates quickly L0: DRAM WAL.Append(<K, V>) OK Flush large batches to SSD Write Ahead Log: SSD L1: SSD

  6. Rocksdb + WAL Synchronous == 10X GAP Have to choose between safety and performance

  7. Rocksdb WAL Flow PUT(<K, V>) 20 us round trip to SSD WAL.Append(<K, V>) OK Small KV pairs ~ 100 bytes Synchronous writes => 5 MB/s SSD is not the problem. SSD Sequential SSD BW => 1 GB/s Problem: Persistence is block oriented Most efficient path to SSD is 4KB units not 100 bytes Have to pay fixed latency cost for only 100 byte IO

  8. Rocksdb WAL Flow Solution: Use byte oriented persistent memory PUT(<K, V>) WAL.Append(<K, V>) OK ~100 ns round trip to NVDIMM Small KV pairs ~ 100 bytes Synchronous writes => 1GB/s NVM Sequential SSD BW => 1 GB/s OK Drain 4KB SSD

  9. Rocksdb + WAL + WAL + NVM NVM removes the need for a safety vs performance choice NVM = No more synchronous logging pain for KV stores, FS, Databases...

  10. Software Engineering for NVM ● Building software for NVM has high payoffs ○ Make everything go much faster ● Not as simple as writing code for data in DRAM ○ Even though NVM looks exactly like DRAM for access ● Writing correct code to maintain persistent data structures is difficult ○ Part 2 of this talk ● Getting it wrong has high cost ○ Persistence = errors do not go away with reboot ○ No more ctrl+alt+del to fix problems ● Software engineering aids to deal with persistent memory ○ Part 3 of this talk

  11. Example: Building an NVM log ● Like the one we need for RocksDB ● Start from DRAM version int * entries; int tail; void append(int value) { tail++; entries[tail] = value; }

  12. Making it Persistent Persistent devices are block oriented Hide block interface behind mmap abstraction … entries = mmap(fd, ...); ... entries OS VMM int * entries; DRAM IO Device int tail; (pagecache) void append(int value) { page_out( ) tail++; entries[tail] = value; } page_in( )

  13. Persistent Data Structures Tomorrow Does not work for NVM Wasteful copying - NVM is byte oriented and directly addressable OS VMM DRAM NVM (pagecache) page_out( ) page_in( )

  14. Direct Access (DAX) # Most Linux filesystems support for NVM # mount -t ramfs -o dax ,size=128m ext2 /nvm fd = open(“/nvm/log”, …); int *entries = mmap(fd, ...); entries int tail; NVM void append(int value) { tail++; entries[tail] = value; }

  15. Tolerating Reboots fd = open(“/nvm/log”, …); int entries = mmap(fd, ...); int tail; void append(int value) { tail++; entries[tail] = value; } Persistent data structures live across reboots

  16. Thinking about Persistence void * area = mmap(.., fd, ..); Page Table NVM In NVM Virtual Physical 0xabc 0xdef int *entries=0xabc ... ... 0xdef

  17. Thinking about Persistence After reboot Page Table NVM Virtual Physical 0xbbb 0xdef 0xabc NULL In NVM CRASH int *entries=0xabc 0xdef Persistent data structures live across reboots. Address mappings do not.

  18. Persistent Pointers Solution: Make pointers base relative. Base comes from mmap. fd = open(“/nvm/log”, …); nvm_base: nvm_base = mmap(fd, ...); #define VA(off) ((off) + nvm_base) offset_t entries; int tail; entries void append(int value) { tail++; VA(entries)[tail] = value; }

  19. Power Failure Entries tail value Before fd = open(“/nvm/log”, …); garbage nvm_base = mmap(fd, ...); #define VA(off) ((off) + nvm_base) offset_t entries; Entries int tail; value void append(int value) { tail++ garbage tail tail++; VA(entries)[tail] = value; } Entries value .. = value tail value

  20. Power Failure Entries tail value Before fd = open(“/nvm/log”, …); garbage nvm_base = mmap(fd, ...); #define VA(off) ((off) + nvm_base) offset_t entries; Entries int tail; value void append(int value) { tail++ garbage tail tail++; VA(entries)[tail] = value; } Entries value tail value

  21. Reboot after Power Failure fd = open(“/nvm/log”, …); nvm_base = mmap(fd, ...); #define VA(off) ((off) + nvm_base) offset_t entries; Entries int tail; value void append(int value) { reboot garbage tail tail++; VA(entries)[tail] = value; }

  22. Ordering Matters Entries tail value Before fd = open(“/nvm/log”, …); garbage nvm_base = mmap(fd, ...); #define VA(off) ((off) + nvm_base) offset_t entries; Entries int tail; tail value void append(int value) { .. = value VA(entries)[tail + 1] = value; value tail++; } OK to fail ! Entries value tail++ garbage tail

  23. The last piece: CPU caches Transparent processor caches reorder your updates to NVM fd = open(“/nvm/log”, …); nvm_base = mmap(fd, ...); #define VA(off) ((off) + nvm_base) 1 2 CPU Cache NVM offset_t entries; core int tail; void append(int value) { Cache: NVM: VA(entries)[tail + 1] = value; {tail, entries[tail]} {} tail++; } Cache: NVM: {entries[tail]} {tail}

  24. Explicit Cache Control Use explicit instructions to control cache behavior fd = open(“/nvm/log”, …); nvm_base = mmap(fd, ...); #define VA(off) ((off) + nvm_base) 1 2 CPU offset_t entries; Cache NVM core int tail; void append(int value) { tail++; Cache: NVM: sfence(); {tail} {entries[tail]} clflush(&tail); VA(entries)[tail] = value; sfence(); clflush(&VA(entries)[tail]); }

  25. Getting NVM Right fd = open(“/nvm/log”, …); nvm_base = mmap(fd, ...); #define VA(off) ((off) + nvm_base) offset_t entries; int tail; COMPLEXITY !!! void append(int value) { tail++; sfence(); clflush(&tail); VA(entries)[tail] = value; sfence(); clflush(&VA(entries)[tail]); }

  26. Software Toolchains for NVM ● Correctly manipulating NVM can be difficult. ● Bugs and errors propagate past the lifetime of the program ○ Fixing errors with DRAM is easy - ctrl + alt + del ○ Your data structures will outlive your code ○ New reality for software engineering ● People will still do it (this talk encourages you to) ● Need automation to relieve software burden ○ Testing ○ Libraries

  27. Software Testing for NVM fd = open(“/nvm/log”, …); nvm_base = mmap(fd, ...); #define VA(off) ((off) + nvm_base) offset_t entries; int tail; TEST { append(42); void append(int value) { ASSERT(entries[1] == 42); tail++; } sfence(); clflush(&tail); VA(entries)[tail] = value; sfence(); clflush(&VA(entries)[tail]); }

  28. Software Testing for NVM fd = open(“/nvm/log”, …); nvm_base = mmap(fd, ...); TEST { #define VA(off) ((off) + nvm_base) append(42); ASSERT(entries[1] == 42); offset_t entries; } int tail; void append(int value) { tail++; sfence(); clflush(&tail); // BUG!! VA(entries)[tail] = value; Thousands of executions….. sfence(); ASSERT nevers fires �� clflush(&VA(entries)[tail]); }

  29. Software Testing for NVM fd = open(“/nvm/log”, …); nvm_base = mmap(fd, ...); TEST { #define VA(off) ((off) + nvm_base) append(42); REBOOT; offset_t entries; ASSERT(entries[1] == 42); int tail; } void append(int value) { tail++; sfence(); clflush(&tail); // BUG!! VA(entries)[tail] = value; Thousands of executions….. sfence(); ASSERT maybe fires � clflush(&VA(entries)[tail]); }

  30. YAT Automated testing tool for NVM software Yat: A Validation Framework for Persistent Memory. Dulloor et al. USENIX 2014 Idea: Test power failure without really pulling the plug

  31. 1. Extract possible store orders to NVM fd = open(“/nvm/log”, …); nvm_base = mmap(fd, ...); YAT { #define VA(off) ((off) + nvm_base) append(42); ASSERT(entries[1] == 42); offset_t entries; } int tail; void append(int value) { tail=1; ..=42; tail++; ..=42; tail=1; sfence(); clflush(&tail); // BUG!! VA(entries)[tail] = value; sfence(); clflush(&VA(entries)[tail]); } Use a hypervisor or instrumentation via binary instrumentation (eg. PIN, Valgrind) Use understanding of x86 memory ordering model

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend