-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove mmap backend #536
Remove mmap backend #536
Conversation
The userspace cache backend is now within a factor of about 1.5-2x, and I've given up on proving that the mmap backend is sound. It's just too complex and there was already a soundness bug found in 1293d4f
Hey @cberner 👋 I was wondering if the removal of the mmap backend means that the values are always allocated when retrieved? Which means that keeping too many values for too long can result in OOM? |
No, it should not. There's a cache which holds pages (redb's Page abstraction, not OS pages) and they're evicted when the cache is full. The size is configurable |
Thank you very much for the answer, @cberner. I have a couple of other questions:
I am just thinking about this because I use LMDB and extensively use memory mapping behavior in arroy by keeping pointers to some values and read them in parallel. |
Yes, the pages will be kept for the lifetime of the |
Thank you, @cberner; it seems to be the best alternative. My last question is: Is there a way to read a non-committed transaction in parallel? Like reading the current transaction with multiple read transactions so that I can spawn multiple threads with each transaction and read the table in each (making sure no writes are performed while these read transactions live). table.write(wtxn, "abc", "long embedding")?;
table.write(wtxn, "def", "another long embedding")?;
let rtxn_gen = wtxn.lock_for_read()?;
let rtxn0 = rtxn_gen.read_txn()?;
let rtxn1 = rtxn_gen.read_txn()?;
// not allowed while rtxn_gen lives
// table.write(wtxn, "def", "another long embedding")?;
assert_eq!(table.read(rtxn0, "abc")?, "long embedding");
assert_eq!(table.read(rtxn1, "def")?, "another long embedding");
rtxn0.abort();
rtxn1.abort();
drop(rtxn_gen);
table.write(wtxn, "ghi", "another super long embedding")?; |
Read transactions can only read committed data, so you can't directly do that. The two options would be:
|
Fixes #458
I decided that the maintenance burden of supporting the mmap backend is too high for too small of a performance improvement. This will make redb provably safe and trivial to port to other platforms. Proving that the mmap backend was safe seemed infeasible, and this greatly simplifies the codebase.