I am currently thinking about stating graduate school and this dude "Andy Pavlo" is my hero, the amount of information he pumps (I don't know any other world) to his listeners is outlandish while staying fun and serious and practical at the same time. I watched most of his lectures. I have done some work in industrial reaseach lab with cuda. I did OS a lot and it was my first choice. But after watching his lectures i am seriously considering changing my field to DB. Specially i can do use my Operation Research knowledge in DB much more effective than OS.
Journal files. You can begin a transaction, crash, and lose the transaction. But the thing itself will be consistent.
Perhaps there's something funny about the failure modes of non-volatile memory that's different than a disk. Replication can improve things, sure. there's always a chance of a cosmic ray doing something weird to your stuff. That's (so far) a lot less common than a regular old crash.
I was thinking along the lines of the machine being on the wrong side of a network partition and then disappearing entirely. Cloud services are supposed to survive the loss of any single machine.
Ah, i think you're right, but that's a different problem. The Jepsen talks are enlightening, as so many errors get highlighted. Ultimately, if your algorithm is right, the hardware won't matter at all. Each node could be a person with pencil and paper, and the messages are lossy paper airplanes.
The NVM stuff (i think) just changes parameters to cache size, journal log size, stuff like that. I mean, it's cool tech, and it'll probably make stuff faster. But the reliability comes from the architecture and faithful implementation.
Except, it allows only a single writer and it's not directly byte-addressable, unless you make a request to preallocate a chunk of fixed-size mmap'ed memory.
Ctrl+f through the doc for "MDB_FIXEDMAP" for more details.
So there is _some_ support, where you can expect to have the whole file at a fixed address. What is not handled is that your data may be moved within the file, and there's nothing you can do about it, short of keeping a long-lived read only transaction:
In practice, nobody has wanted support for this so it has remained unimplemented. Note that if your data items are large enough (more than 1/2 a page) they'll go into their own overflow pages, and then won't shift around at all. (But if you delete/modify a value, the new version will of course be in a new overflow page.)
Granted, this could be a case of "if you build it they will come" - before LMDB existed, nobody cared about mmap'd transactional DBs either. And personally, I still see good use cases for it.
Note that the LMDB approach, and especially if you want MDB_FIXEDMAP, limits DB size to the largest mmap()ing you can get at a fixed location. That's not good in a world of 48-bit address spaces.
LMDB is a highly-optimized storage engine. However, it is not a full-featured DBMS (e.g., no support for query optimization). This talk focuses on the potential impact of NVM on different layers of a full-featured DBMS -- not only the storage engine.
There is also MRAM [0] which ships from a company called Everspin [1][2] and is produced by Globalfoundries. Unlike Intels/Microns solution it seems to be as fast as normal RAM, but at much smaller densities.
Eh. None of this is new, and we already anticipated this with LMDB back in 2009.
The fact that NVRAM is directly addressable (and thus can bypass the page cache) will eventually play out as irrelevant. It will always be a fact that slower mass-storage will exist, more cheaply than fast in-core storage, persistent or not. The page cache will still be needed even for NVRAM, and the "page" will still be the necessary atomic unit of memory interchange. (Direct access is of course a great thing, but it will be direct access to virtual addresses. Virtual memory, and paging in/out between primary and secondary storage, is never going away. Every commodity system that has tried to do without PMMUs has failed, for numerous good reasons.)
The continual allusions to "frequent writes can destroy memory cells" seems to mainly relate to the extremely short lifetime of Intel's 3DXpoint memory, which is from every measure a total failure.
It would be best to ignore 3DXpoint and just focus on STT-MRAM, which is already at parity with DRAM for endurance. (But still lacking in density.)
Much of the other stuff in those slides is still off the mark. E.g., LMDB today has perfect crash reliability with zero recovery time. The "write behind logging" they propose still has logging overhead and non-zero crash recovery time - which equals wasted work. Anything that requires logging or any form of compaction or garbage collection is wasted work. It's completely unnecessary, and that has nothing to do with NVM. Treating NVM DB design as if it's an entirely new and different animal is frankly ignorant. The right design works in all scenarios - as LMDB does.
I'm not sure that using mmap(2) is enough. You're still writing pages, so you're writing more than you have to, so writes will not go as fast on NVM as they could.
LMDB does logging since it does copy-on-write -- it just reuses free pages as soon as possible, which means that over time the log disappears. (LMDB is not an append-only DB.)
I agree as to GCs. Having to GC is not just wasted work, it's a performance disaster, and any study that hand-waves about GC without actually measuring its impact on performance is fatally flawed. Assume petabytes of data, and assume performance between SSDs and DRAM: GC will still take enormous amounts of time and I/O that could have been used for something else. Write-behind logging is terrible if it means you need a GC. Why even bother with write-behind logging if a failure means that you must GC anyways.
Only write-ahead logging helps you avoid a GC. A write-ahead log could be optimized to log only (address, length) tuples for each transaction so as to minimize WAL writes.
However, the insights about smaller-than-page I/Os, particularly as to writes, seem likely to be correct. Though having anything like a b-tree on NVM with smaller-than-page writes seems to me to imply in-place writes, but I'm not ready to give up on COW.
> I'm not sure that using mmap(2) is enough. You're still writing pages, so you're writing more than you have to, so writes will not go as fast on NVM as they could.
If you're using the new fangled memory there's a few components in play.
First in Linux there's DAX. DAX lets you mmap in the devices pages directly without going through the page cache. And the processor can handle this like a memory mmaped device (without interactions from the OS) including subpage read/writes.
Second, Intel chose to reuse previously existing operations that you would normally use for flushing cache lines (to main memory). Previously there were going to use additional pcommit operation. https://software.intel.com/en-us/blogs/2016/09/12/deprecate-...
I got that. My point is that merely using this is insufficient to make your DB go fast on NVM. As the presentation says, you need to consider changing the on-disk^W^W^Wpersistent storage format to be one that writes less (not so much because of write cycle limits, but because writes are slower, and to reduce the number of additional writes needed in, say, a COW format.
Meta-observation: LMDB is a highly-optimized storage engine. However, it is not a full-featured DBMS (e.g., no support for query optimization). This talk focuses on the potential impact of NVM on different layers of a full-featured DBMS -- not only the storage engine.
> The fact that NVRAM is directly addressable (and thus can bypass the page cache) will eventually play out as irrelevant. It will always be a fact that slower mass-storage will exist, more cheaply than fast in-core storage, persistent or not.
Well, it depends on the latency of the NVM device. If the NVM device is directly addressable and has DRAM-like access latencies, I suspect that we must re-examine the assumptions underlying storage virtualization. Although I agree that the OS/DBMS would still need to maintain a page cache for data residing on slow block-addressable SSD/HDDs, I suspect that this will not be the case for data residing on fast byte-addressable NVM.
> Anything that requires logging or any form of compaction or garbage collection is wasted work. It's completely unnecessary, and that has nothing to do with NVM. Treating NVM DB design as if it's an entirely new and different animal is frankly ignorant. The right design works in all scenarios - as LMDB does.
If you think about it, logging is equivalent to versioning. To ensure atomicity and durability, a DBMS must maintain BEFORE and AFTER images of tuples. Unless it is a pure append-only system, the DBMS cannot refrain from reclaiming the storage space associated with OLDER tuple images. Note that these images can be stored either in the log or in multi-versioned heap storage. Maintaining a second B+tree to keep track of free pages, as is done is LMDB, is simply an implementation detail.
36 comments
[ 3.7 ms ] story [ 94.1 ms ] threadPerhaps there's something funny about the failure modes of non-volatile memory that's different than a disk. Replication can improve things, sure. there's always a chance of a cosmic ray doing something weird to your stuff. That's (so far) a lot less common than a regular old crash.
The NVM stuff (i think) just changes parameters to cache size, journal log size, stuff like that. I mean, it's cool tech, and it'll probably make stuff faster. But the reliability comes from the architecture and faithful implementation.
http://www.nvmexpress.org/wp-content/uploads/NVMe_Over_Fabri...
https://symas.com/lightning-memory-mapped-database/
Except, it allows only a single writer and it's not directly byte-addressable, unless you make a request to preallocate a chunk of fixed-size mmap'ed memory.
http://www.lmdb.tech/doc/group__mdb__env.html#ga492952277c48...
Ctrl+f through the doc for "MDB_FIXEDMAP" for more details.
So there is _some_ support, where you can expect to have the whole file at a fixed address. What is not handled is that your data may be moved within the file, and there's nothing you can do about it, short of keeping a long-lived read only transaction:
http://www.lmdb.tech/doc/todo.html
In practice, nobody has wanted support for this so it has remained unimplemented. Note that if your data items are large enough (more than 1/2 a page) they'll go into their own overflow pages, and then won't shift around at all. (But if you delete/modify a value, the new version will of course be in a new overflow page.)
Granted, this could be a case of "if you build it they will come" - before LMDB existed, nobody cared about mmap'd transactional DBs either. And personally, I still see good use cases for it.
Oh, I didn't know that's a thing.
http://www.tomshardware.com/news/intel-optane-cascade-lake-d...
XPoint is expected to have performance much higher than Optane.
[0] https://en.wikipedia.org/wiki/MRAM
[1] https://www.everspin.com/ddr3-dram-compatible-mram-spin-torq...
[2] https://www.everspin.com/ddr4-st-mram-products
The fact that NVRAM is directly addressable (and thus can bypass the page cache) will eventually play out as irrelevant. It will always be a fact that slower mass-storage will exist, more cheaply than fast in-core storage, persistent or not. The page cache will still be needed even for NVRAM, and the "page" will still be the necessary atomic unit of memory interchange. (Direct access is of course a great thing, but it will be direct access to virtual addresses. Virtual memory, and paging in/out between primary and secondary storage, is never going away. Every commodity system that has tried to do without PMMUs has failed, for numerous good reasons.)
The continual allusions to "frequent writes can destroy memory cells" seems to mainly relate to the extremely short lifetime of Intel's 3DXpoint memory, which is from every measure a total failure.
http://semiaccurate.com/2017/03/10/intel-mislead-press-xpoin...
It would be best to ignore 3DXpoint and just focus on STT-MRAM, which is already at parity with DRAM for endurance. (But still lacking in density.)
Much of the other stuff in those slides is still off the mark. E.g., LMDB today has perfect crash reliability with zero recovery time. The "write behind logging" they propose still has logging overhead and non-zero crash recovery time - which equals wasted work. Anything that requires logging or any form of compaction or garbage collection is wasted work. It's completely unnecessary, and that has nothing to do with NVM. Treating NVM DB design as if it's an entirely new and different animal is frankly ignorant. The right design works in all scenarios - as LMDB does.
LMDB does logging since it does copy-on-write -- it just reuses free pages as soon as possible, which means that over time the log disappears. (LMDB is not an append-only DB.)
I agree as to GCs. Having to GC is not just wasted work, it's a performance disaster, and any study that hand-waves about GC without actually measuring its impact on performance is fatally flawed. Assume petabytes of data, and assume performance between SSDs and DRAM: GC will still take enormous amounts of time and I/O that could have been used for something else. Write-behind logging is terrible if it means you need a GC. Why even bother with write-behind logging if a failure means that you must GC anyways.
Only write-ahead logging helps you avoid a GC. A write-ahead log could be optimized to log only (address, length) tuples for each transaction so as to minimize WAL writes.
However, the insights about smaller-than-page I/Os, particularly as to writes, seem likely to be correct. Though having anything like a b-tree on NVM with smaller-than-page writes seems to me to imply in-place writes, but I'm not ready to give up on COW.
If you're using the new fangled memory there's a few components in play.
First in Linux there's DAX. DAX lets you mmap in the devices pages directly without going through the page cache. And the processor can handle this like a memory mmaped device (without interactions from the OS) including subpage read/writes.
Second, Intel chose to reuse previously existing operations that you would normally use for flushing cache lines (to main memory). Previously there were going to use additional pcommit operation. https://software.intel.com/en-us/blogs/2016/09/12/deprecate-...
I would like to read about these. Anyone have any pointers?
> The fact that NVRAM is directly addressable (and thus can bypass the page cache) will eventually play out as irrelevant. It will always be a fact that slower mass-storage will exist, more cheaply than fast in-core storage, persistent or not.
Well, it depends on the latency of the NVM device. If the NVM device is directly addressable and has DRAM-like access latencies, I suspect that we must re-examine the assumptions underlying storage virtualization. Although I agree that the OS/DBMS would still need to maintain a page cache for data residing on slow block-addressable SSD/HDDs, I suspect that this will not be the case for data residing on fast byte-addressable NVM.
> Anything that requires logging or any form of compaction or garbage collection is wasted work. It's completely unnecessary, and that has nothing to do with NVM. Treating NVM DB design as if it's an entirely new and different animal is frankly ignorant. The right design works in all scenarios - as LMDB does.
If you think about it, logging is equivalent to versioning. To ensure atomicity and durability, a DBMS must maintain BEFORE and AFTER images of tuples. Unless it is a pure append-only system, the DBMS cannot refrain from reclaiming the storage space associated with OLDER tuple images. Note that these images can be stored either in the log or in multi-versioned heap storage. Maintaining a second B+tree to keep track of free pages, as is done is LMDB, is simply an implementation detail.