News for hackers. Stuff that matters.
Re:std::launder: the most obscure new feature of C++17 by kazinator on Thursday April 04, 2024 @05:45PM (#39936149)
> explicitly paged to disk

Example would help. Most paging nowadays is implicit, transparent to the program.

Are you talking about some old-school overlays or something? Multiple objects in mass storage are mapped to the same address in memory, multiplexed in the time domain?

Re:std::launder: the most obscure new feature of C++17 by jandrewrogers on Thursday April 04, 2024 @06:24PM (#39936542)
Paging is not transparent in high-scale and high-performance databases when using direct I/O to disk. It is not possible to make it transparent on many larger servers even if you wanted to because the silicon does not support a large enough virtual address space. This is a pretty common design problem in databases, or anything with huge amounts of data and storage really.

There were magic incantations that compilers informally respected to induce the correct behavior but it wasn’t always reliable and technically not a bug when it wasn’t. This provides an official and simple way to achieve the same effect without obscure magic.

Re:std::launder: the most obscure new feature of C++17 by loeg on Thursday April 04, 2024 @07:09PM (#39936954)
Are high performance databases embedding non-POD C++ objects in explicitly paged memory?
Re:std::launder: the most obscure new feature of C++17 by jandrewrogers on Friday April 05, 2024 @12:38AM (#39938729)
Most of your runtime objects are expected to be pageable in databases designed to support very high storage density because it is necessary as a matter of robustness and persistability. Even single runtime metadata structures may not reasonably fit in RAM in some cases. There are constraints on these objects (e.g. no vtables) but they are typically not PODs.

Even if they were PODs, changing the types and instances of types at a specific memory address without destroying the objects residing there can have side-effects. The compiler does not expect a live memory address to be overwritten with an arbitrary bucket of bits by a DMA operation. DMA doesn't respect lifetime and ownership models as understood by a compiler, so it is a bit of a Deus Ex Machina as far as the compiler is concerned and is assumed to never happen.

Re:std::launder: the most obscure new feature of C++17 by zamalek on Thursday April 04, 2024 @06:05PM (#39936370)
> Example would help.

Almost any database.