PumpkinDB icon indicating copy to clipboard operation
PumpkinDB copied to clipboard

Problem: working with storage data is not zero-copy

Open yrashk opened this issue 8 years ago • 4 comments

This issue is mentioned in ad6da5243d4f5804592d9bd7fa67306e83a53f63

There was a realization that Env<'a> wants all referenced elements on the stack to allow have the same lifetime of 'a. However, the lifetime of the values extracted through lmdb is limited by the lifetime of the transaction.

Potential solution:

This means that right now we have to resort to copying values. However, I suspect there's still a chance we can have an optimization here. We might be able to have a temporary "transaction context" stack that has a different lifetime. The feasibility and consequences of such an idea are still to be researched. But if defined well, this should definitely improve the overall quiality and performance of PumpkinDB.

yrashk avatar Feb 09 '17 17:02 yrashk

Related: https://github.com/PumpkinDB/PumpkinDB/issues/150

omarkj avatar Mar 02 '17 17:03 omarkj

Another solution is to transmute lifetimes and do "transaction exit" scans, but that's pretty hacky.

yrashk avatar Mar 13 '17 03:03 yrashk

Another solution is to introduce the concept of "linked Envs" where an Env can have a parent Env, effectively separating them by lifetimes.

yrashk avatar Mar 21 '17 15:03 yrashk

Here's a thought. Based on my recent work on the SPDK binding, we can kind of forego this whole zero-copy issue. How so?

SPDK allows to communicate with the NVMe controller bypassing the kernel by pointing to a pinned allocation of host memory directly. Therefore, if we design our own direct storage format (which is, of course, a huge undertaking!) and allocate the heap in such a piece of memory (using spdk::Buffer from the binding), then not only we'll have what essentially amounts to zero-copy reads, but also zero-copy writes!

Obviously, this won't solve the zero-copy reads issue for the lmdb backend, but if we assume that you have to make certain sacrifices if you want performance (like buying a good NVMe SSD), then it's a solution! And if ever get around it, we can still work on the above ideas for adding zero-copy reads to lmdb-based engines.

yrashk avatar Apr 22 '17 21:04 yrashk