| Disclaimer: I work at Intel on PMDK (pmem.io) It is the game changer that you wish for, since the marshaling logic that you mention is gone. Persistent Memory can be accessed directly through memory mapped file, bypassing the traditional read()/write() I/O paths. Recent file systems have also been modified to a) skip the page cache layer and b) forgo the msync() call that would be otherwise required to synchronize the modified pages. This is what's called DAX (Direct Access [0]). In the place of msync() you can now just use CPU cache flush instructions. These two file system changes entirely eliminate kernel code from the I/O path (apart from the initial page faults). Persistent Memory Development Kit contains libpmemobj [1], which is almost exactly what you are imagining ;) It's a persistent heap, with transactions for durability. It's not as nice (yet) as your code snippet, but here's C++ example [2] of a persistent queue push: obj::transaction::exec_tx(pool, [this, &value] {
auto n = obj::make_persistent<Node>(value, nullptr);
if (head == nullptr) {
head = tail = n;
} else {
tail->next = n;
tail = n;
}
});
`make_persistent` is, akin to `make_unique`, a memory allocation of a "Node" class. Once allocated, we can just assign the newly allocated object to a different persistent variable. No kernel code executing, no serialization ;)[0]- https://www.kernel.org/doc/Documentation/filesystems/dax.txt [1] - https://github.com/pmem/pmdk [2] - https://github.com/pmem/pmdk/blob/master/src/examples/libpme... |