Automated Insertion of Flushes and Fences for Persistency
Yutong Guo, Weiyu Luo, Brian Demsky · 2025
Read Automated Insertion of Flushes and Fences for Persistency by Yutong Guo, Weiyu Luo, Brian Demsky (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2509-19459.txt.
Introduction
Some memory keeps its data after a crash, but only if the code forces each save to reach storage. Programmers must add flush and fence steps by hand, and missed steps are a common bug source. Yutong Guo, Weiyu Luo, and Brian Demsky built PMRobust, a compiler that adds those steps on its own. Past tools could flag a missed step only when a test happened to expose it.
PMRobust studies the code as a whole and guards newly made objects with extra care. The team tried it on known memory libraries and data structures. Added cost stayed well under one percent on average next to hand-tuned code. The result is a stronger promise: programs built with it should not lose saved data to a missed flush.
Catalog record
| CREATOR | Yutong Guo, Weiyu Luo, Brian Demsky |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 71 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2509-19459
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Automated Insertion of Flushes and Fences for Persistency Yutong Guo, Weiyu Luo, Brian Demsky Abstract CXL shared memory and persistent memory allow the contents of memory to persist beyond crashes. Stores to persistent or CXL memory are typically not immediately made persistent; developers must manually flush the corresponding cache lines to force the data to be written to the underlying storage. Correctly using flush and fence operations is known to be challenging. While state-of-the-art tools can find missing flush instructions, they often require bug-revealing test cases. No existing tools can ensure the absence of missing flush bugs. In this paper, we present PMRobust , a compiler that automatically inserts flush and fence operations to ensure that code using persistent memory is free from missing flush and fence bugs. PMRobust employs a novel static analysis with optimizations that target newly allocated objects. We have evaluated PMRobust on persistent memory libraries and several persistent memory data structures and measured a geometric mean overhead of 0.26% relative to the original benchmarks with hand-placed flush and fence operations. I Introduction In several different contexts, hardware designers have developed systems in which the contents of memory can survive system crashes. Compute Express Link (CXL) is a new open standard that enables cache coherent shared memory across a network. CXL also supports memory interface to persistent storage [ 42 ] . Finally, the contents of battery-backed NVDIMM’s can survive power outages. In all of these contexts, the in-memory data manipulated by a computation can survive machine crashes, and it can be desirable to ensure that key data structures are crash consistent so that they can be safely accessed after crashes. Achieving crash consistency is complicated by the volatility of CPU caches, necessitating explicit flush and fence instructions to persist data. 1 1 1 CXL can optionally use energy storage to implement flush on failure, though this requires support by both the device and system components. This is not a panacea; many failure modes would still result in lost cache lines. Software developers must use special flush and fence instructions to force data to be written back to the underlying memory. There is a body of work [ 20 , 22 , 36 ] on finding bugs in persistent memory programs that utilize flushes and fences. These tools range from model checkers [ 29 , 21 ] to various dynamic bug finding tools [ 35 , 28 , 38 ] . The prevalence of such bugs, with 183 new bugs reported by various tools [ 21 , 20 , 16 , 13 , 35 , 36 , 38 ] in a small expert-written program set, underscores the difficulty of manual management and motivates automating flush/fence insertion via compilers. We developed a new tool that automatically generates the necessary flush and fence operations. Strict persistency [ 39 ] ensures that the “persistency memory order is identical to volatile memory order”. The observation here is that bugs caused by missing flush and fence operations can be eliminated by making stores become persistent in the same order that they become visible to other threads. Enforcing strict persistency is expensive as it requires threads to stall frequently to wait for previous stores to be persisted. Fortunately, we can further loosen the requirements for strict persistency. If it is impossible for the program to observe that stores were persisted in a different order, we can permit those stores to be reordered, and partly recover from the performance penalties of strict persistency. Robustness leverages this additional degree of freedom and ensures that any execution of a program under a weak persistency model is equivalent to some execution of the program under the strict persistency model [ 20 ] . This suffices to ensure the correct usage of flush and fence operations as additional flush and fence operations will not alter the set of possible post-crash program executions. As missing flushes and fences are a major source of bugs in persistent memory program, a tool that eliminates these concerns greatly simplifies persistent memory programming. Robustness to persistency models has been explored before in the context of bug finding. PSan uses a dynamic analysis combined with random execution or model checking to check robustness. PSan suffers from the same limitations as all dynamic analysis—it requires test cases and may miss bugs that are not revealed by the test cases. Thus, the analysis used by PSan cannot be the foundation of a compiler that automatically inserts flush and fence operations. PMRobust is applicable to CXL shared memory and all non-volatile memory types. We collectively refer to all of these memory types as persistent memory (PM) throughout the paper for convenience. This paper makes the following contributions: • Static Analysis: It presents the first static analysis that can efficiently analyze full programs for missing flushes or fences using robustness as a correctness criteria. • PM Analysis: It presents the first static analysis that can determine which operations will only modify volatile or local memory, reducing analysis and annotation overhead. • Automated Flush Insertion: It presents the first static tool that can both repair missing flush and fence bugs as well as insert any missing fences, freeing the developer from this task. • Eliminates Missing Flush Bugs: It presents the first tool that ensures the absence of missing flush bugs. • Evaluation: It evaluates PMRobust on a wide range benchmarks, incurring minimal runtime overhead. We have made PMRobust ’s source code, benchmarks, and scripts for reproducing evaluation results available at: https://github.com/uci-plrg/PMRobust-docker II Underlying Hardware and Failure Model Persistency semantics are important for a range of new memory hardware. A well-studied example is Px86 [ 41 ] , the semantics of persistent memory for x86 processors, which adds a global persistent buffer that holds stores after they exited the thread-local store buffers. Stores in the persistent buffer are written back to memory in arbitrary order at cache line granularity, and those not written back are lost upon a crash. To avoid inconsistent state caused by crashes under persistency semantics, fence and flushes instructions are often needed to impose persistency ordering between stores. While the problem has received much attention for persistent memory, the same problem exists for CXL shared memory. Figure 1 presents a graphical overview of CXL shared disaggregated memory. In this setting, processing nodes and memory nodes are connected via CXL networking. Memory can be coherently shared between multiple hosts — memory nodes contain directories that track which cache lines have been requested by processing nodes. CXL on x86 is intended to provide TSO ordering guarantees across machines. Failures of compute nodes pose a consistency problem. Compute nodes cache their writes to CXL shared memory and the contents of these caches can be written back in an arbitrary order. The CXL standard provides for global persistent flush (GPF). When GPF is supported, it uses energy reserves to write the contents of the CPU cache back to the underlying storage upon a crash or system shutdown. However, GPF does not cover a wide range of failure modes, e.g. , failed cables, failed CXL transceivers, failed CPUs, failed motherboards, etc, and therefore does not provide a complete solution to the consistency problem. If even a single machine that is