Skip to content

Kerollmops/heed-perfs-put-reserved

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

heed-perfs-put-reserved

A small experiment with LMDB's MDB_RESERVE flag and Roaring Bitmaps. This problem has been posted on the Rust SubReddit, and some interesting comments have been made.

What is this for?

While working on some Meilisearch optimizations, I considered reducing the number of memcpy calls when writing into our LMDB key-value store.

LMDB can prepare a slice of bytes and let you write into this uninitialized memory area afterward. What you have to do is give the key you want to insert and the size of the data that you need. It is helpful when you already know the size of it.

The Meilisearch indexation process does many gets and puts into LMDB databases. We mainly use RoaringBitmaps and serialize them into bytes. But as we use the default heed Database::put method, we must provide a slice of bytes to LMDB via a codec. Heed codecs return a Vector of bytes (under a Cow).

So, I was thinking about avoiding those possible multiple allocations of Vecs and memcpy calls from the source to the LMDB page and directly serializing the RoaringBitmap into the LMDB page allocation. I tried to do so in this code example, and I am astonished about the results: they are worse!

Can you help me understand why? I tried debugging the assembly, but I am not the best. It seems related to the available size assumptions that the code is no longer able to validate. I linked the flamegraphs in the flamegraphs folder.

Profile screenshot of the codec vs the put-reserved-uninit-into-slice versions

About

A small experiment with LMDB's MDB_RESERVE flag and Roaring Bitmaps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published