Log In
Log In

The Address is Not The Place: Object Residency in C++26

Random Access Memory is what you buy when you don’t know what your program will do next.

Until recently, alternative tiers of memory with vastly different latency characteristics were largely speculative. Then DRAM got expensive. CXL memory pools, far memory, even high bandwidth flash moved from blips to serious contenders. C++ has grown its vocabulary for ownership (smart pointers) and lifetimes (RAII); but intelligent memory tiering, specifically object residency, is a word we don’t natively have.

Attempts have been made to solve this issue at an OS-level (Meta’s TPP), or even a compiler/runtime level (OBASE) but they approach the problem transparently by design. And thus…blind by design. You can improve tiered object locality with clever placement within pages, but all these methods are structurally incapable of predicting intent. What if the power was in the developer’s hands?

With reflection (P2996) and annotations (P3394), C++26 finally lets us extend the vocabulary ourselves. Game developers have deeply understood smart data grouping for decades, but much of the work is locked behind game engines; not suitable for general application development. [[likely]] and [[unlikely]] hint hot and cold paths, but the future of high-performance development hints at general purpose object residency to tier-aware allocators.

This talk introduces an open-source C++26 residency library, demonstrating capabilities against current, and even (simulated) future hardware. The pieces are in place for C++ to create durable abstractions for object residency; with the flexibility to accommodate memory tiers that have not been invented yet!

Laurie Kirk is a researcher at Google specializing in C++, reverse engineering, and deobfuscation. She runs a YouTube channel (@LaurieWired) that covers all sorts of in-depth research topics on reverse engineering, programming, and software optimizations. She has spoken at multiple conferences including ACCU on Sea, Strange Loop, DEFCON, REcon, and Objective by the Sea.

Next Post

  • Language Designers Panel
    #Asio
    Panelists: Bjarne Stroustrup, Guido van Rossum, Mads Torgersen; Emma Tracey. C++, Python and C# examined together. C++ and Python co‑use is common. C#’s Windows role is noted. Design trade‑offs discussed. Stewardship covered. Q&A follows.
  • Rotation revisited: Cycle decomposition in clang’s libcxx
    #Bimap
    The implementation of array rotation in clang’s libcxx is discussed, emphasizing that the minimal number of element swaps, roughly half the total size, is achieved. A permutation view of the rotation is employed, and the algorithm is described as traversing each cycle of that permutation. The number of cycles is indicated to be the greatest common divisor of the two segment lengths, denoted a and b. Each k‑th cycle is started at the element offset k from the beginning and proceeds by advancing a positions with wrap‑around until the start is reached again. An example with segment lengths 4 and 6 is provided, illustrating the sequence of positions visited within a single cycle. It is highlighted that this cycle‑based method attains the optimal swap count. The approach is contrasted with simpler but less efficient techniques.