Execution of NVRAM Programs with Persistent Stack

Vitaly Aksenov, Ohad Ben-Baruch, Danny Hendler, Ilya Kokorin, Matan Rusanovsky

Abstract

Non-Volatile Random Access Memory (NVRAM) presents a paradigm shift in storage, combining near-DRAM speeds with data persistence. However, the volatility of CPU registers and caches complicates the development of recoverable software. This paper introduces a novel algorithm for a persistent program stack in NVRAM. By utilizing a single-byte "end marker" for atomic updates and offset-based pointers for relocation safety, the proposed framework enables "Nesting Safe Recoverable Linearizability." Evaluation via NVRAM emulation on standard hardware demonstrates the system's resilience to repeated failures and its utility in verifying complex concurrent algorithms.

Introduction: The Volatility Gap

The primary challenge in NVRAM programming is the "volatility gap": while main memory is persistent, the execution state residing in CPU registers and caches is lost upon power failure. Most research has focused on persistent data structures, yet the program stack—essential for tracking nested function calls—remains volatile in typical implementations. Without a persistent stack, a system cannot resume execution from the exact point of failure within a nested call sequence.

Execution of operations on shared vs. local objects.

As shown in Figure 3, while multiple processes can interact with shared non-volatile objects, their local execution state (local objects and stack frames) typically resides in volatile memory. Bridging this gap is critical for building truly resilient persistent systems.

Methodology: The Persistent Stack Algorithm

To address these issues, we propose a custom persistent stack structure designed for crash-consistency and relocation independence.

The One-Byte Marker Technique

Atomic updates to the stack are achieved through a single-byte "end marker" (0x0 or 0x1). The process of adding a new frame involves two steps:

  1. Write: The new frame data is written into the NVRAM space immediately following the current end of the stack.
  2. Flip: The marker byte of the preceding frame is flipped.

Because a single-byte write is guaranteed to be atomic by modern hardware (as it fits within a single cache line), this mechanism ensures that a stack frame is either fully present or completely absent after a crash.

The three-step process for atomic stack frame invocation: (a) initial state, (b) writing the new frame, and (c) flipping the marker to commit.

Relocation and Return Values

To handle memory relocation across reboots, the stack utilizes offset-based pointers relative to the NVRAM base address rather than absolute pointers. Furthermore, since CPU registers like EAX are volatile, functions are instrumented to write their return values directly into designated persistent slots in the NVRAM stack or heap before completion.

Evaluation and Results

The framework was evaluated by emulating NVRAM using memory-mapped files on standard Hard Disk Drives (HDDs). The system supports multiple worker threads, each with its own persistent stack, enabling parallel recovery from crashes. This approach demonstrates that the algorithm's reliance on single-byte atomic flushes allows for rigorous testing on widely available hardware.

Key results include:

  • Resilience: The system successfully recovers from crashes occurring even during the recovery process itself.
  • Correctness: We implemented a persistent Compare-And-Swap (CAS) algorithm and verified its serializability using a tool based on Eulerian circuits.
  • Bug Detection: The framework effectively identified synchronization errors in "incorrect" algorithm variants where persistence barriers were omitted.

Conclusion and Future Directions

This work provides the "missing link" for recoverable nested programs by implementing a concrete, hardware-aware persistent stack. While the current implementation requires manual stack management by the programmer, future developments will focus on compiler plugins (e.g., for LLVM/Clang) to automate the generation of persistent stack frames. This would significantly reduce boilerplate and lower the barrier to entry for developing robust NVRAM applications.

Summary updated

BibTeX
@inproceedings{aksenov2021execution,
  author = {Vitaly Aksenov and Ohad Ben-Baruch and Danny Hendler and Ilya Kokorin and Matan Rusanovsky},
  title = {{Execution of NVRAM Programs with Persistent Stack}},
  booktitle = {PaCT},
  year = {2021},
  doi = {10.1007/978-3-030-86359-3\_9},
}
Figure