Skip to content
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

LMDB comparison benchmark improvements #928

Merged
merged 2 commits into from
Dec 31, 2024

Conversation

Kerollmops
Copy link
Contributor

@Kerollmops Kerollmops commented Dec 31, 2024

In this PR, I introduce the compaction of the LMDB database. It requires compacting the data into another file and reopening the environment afterward.

The following results were run on my iMac M3 computer. I do not understand how the individual writes of LMDB and RocksDB are so low compared to the README you provided on GitHub 🤔

redb lmdb rocksdb sled sanakirja
bulk load 2652ms 1513ms 8188ms 7168ms 1346ms
individual writes 405ms 7ms 4ms 426ms 68ms
batch writes 4880ms 2776ms 324ms 1338ms 4478ms
len() 0ms 0ms 273ms 727ms 54ms
random reads 1051ms 1130ms 3251ms 1484ms 1293ms
random reads 1034ms 1117ms 3113ms 1488ms 1271ms
random range reads 2538ms 1651ms 5648ms 5844ms 1820ms
random range reads 2524ms 1658ms 5655ms 5909ms 1827ms
random reads (4 threads) 370ms 333ms 1281ms 516ms 623ms
random reads (8 threads) 247ms 179ms 787ms 385ms 778ms
random reads (16 threads) 245ms 172ms 800ms 338ms 790ms
random reads (32 threads) 239ms 163ms 583ms 322ms 772ms
removals 4124ms 1221ms 3042ms 2234ms 1236ms
compaction 2077ms 114ms 522ms N/A N/A
size after bench 311.23 MiB 283.01 MiB 106.26 MiB 445.50 MiB 4.00 GiB

@cberner
Copy link
Owner

cberner commented Dec 31, 2024

I do not understand how the individual writes of LMDB and RocksDB are so low compared to the README you provided on GitHub 🤔

Ah ya, that's probably a bug in the durability of LMDB & RocksDB on OSX. On OSX you need to call libc::fcntl(fd, libc::F_FULLFSYNC) instead of msync / fsync -- std::File does this correctly. I fixed a similar issue with sled here:

// Workaround for sled durability
Looks like I need to add similar code for lmdb & rocksdb

@cberner cberner merged commit 49ba8e7 into cberner:master Dec 31, 2024
3 checks passed
@Kerollmops
Copy link
Contributor Author

Kerollmops commented Jan 1, 2025

Ah ya, that's probably a bug in the durability of LMDB & RocksDB on OSX. On OSX you need to call libc::fcntl(fd, libc::F_FULLFSYNC) instead of msync / fsync -- std::File does this correctly. I fixed a similar issue with sled here:

// Workaround for sled durability
Looks like I need to add similar code for lmdb & rocksdb

Wow! Shouldn't this be directly fixed in LMDB and RocksDB source code? It seems to be a real issue, right? If you commit and you cannot be sure it's durable.

I'm wondering what @hyc thinks about this?

@Kerollmops
Copy link
Contributor Author

Ho! BTW @cberner, you forgot to update the README 😅

@hyc
Copy link

hyc commented Jan 1, 2025

Ah ya, that's probably a bug in the durability of LMDB & RocksDB on OSX. On OSX you need to call libc::fcntl(fd, libc::F_FULLFSYNC) instead of msync / fsync -- std::File does this correctly. I fixed a similar issue with sled here:

// Workaround for sled durability

Looks like I need to add similar code for lmdb & rocksdb

Wow! Shouldn't this be directly fixed in LMDB and RocksDB source code? It seems to be a real issue, right? If you commit and you cannot be sure it's durable.

I'm wondering what @hyc thinks about this?

Looks legit, feel free to open a ticket on bugs.openldap.org with the patch. Thanks.

@Kerollmops Kerollmops deleted the lmdb-compaction branch January 9, 2025 14:49
@Kerollmops
Copy link
Contributor Author

For your information, @cberner and Howard 👋

I proposed a patch to LMDB to be applied to the mdb.master and mdb.master3 branches.

Thank you again for the information and for the help cberner,
very appreciated 💟
kero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants