https://slatedb.io logo
https://github.com/slatedb/slatedb/pull/540 could ...
# general
m
https://github.com/slatedb/slatedb/pull/540 could someone please review this small PR,Tanks.
c
I took a look. Thanks for doing this work!
I left a bunch of notes.
In general, I followed the code fairly well. @flaneur233 I suspect the code you're concerned about is the
reader.rs
implementation. I agree with you that it's complex, however most of it is a copy/paste of the
get_with_options
method with a couple of tweaks to make it work for multiple keys. The part that really does concern me is the sorted run part at the bottom of the
multi_get_with_options
method. That logic is net-new and does indeed look quite complex. I confess I don't fully follow it without comments. I am hoping @maomeng8344 can simplify just that part. I left an idea that might work (not 100% sure, since I don't fully understand the code).
Ahh.. I see more of the complexity that @flaneur233 mentioned now.. https://github.com/slatedb/slatedb/pull/537 Refactored the getter into get_memtable, get_l0, and so on.. Need to think about how that would mix with @maomeng8344's work.. @maomeng8344 do you have any thoughts? #537 is worht a look for context.
This work is definitely what I was getting at in my comment on #540.. namely that it seems like a lot of the memtable/l0/compacted reads are duplicated...
f
have get_l0 and get_compacted extracted may help us make the code duplication obvious, i think we can further make
get_l0
and
get_compacted
unified in something like a
get_sst
i found the code in 540 simplified a lot after my comment.. it was modifying
get()
in place in the earlier code with some other modifications, which is what i worried the complexity most, now it's a stand-alone
mget()
code path. i think it will be easier to reason about the correctness of implementation with
get_l0
get_compacted
extracted, to change them into a multi-key implmentation in local places.
m
The complexity in my implementation stems from my desire to process all keys in a single SST query. Theoretically, the overhead cost of multiple get operations compared to my implementation mainly lies in the additional SST reads caused by Bloom filter false positives. From this perspective, my implementation doesn’t offer significant performance improvements over multiple get calls.
f
having a baseline & benchmark may help us understand the characteristic of the `mget()`'s performance i think 🤔, implementing a baseline is a no-brainer correctness, on the other side, it's hard for us to predict the performance gain or lose without the help of benchmark
would you mind having a multiple keys get impl on top of #537? i guess it'll become easier to review the "all keys in a single SST query" in the local "get_l0" and "get_compacted"
m
i agree
f
the earlier code of
get()
has bugs on handling expiration, #537 contains a fix for it. so i'm afraid that making multiple get based on the earlier codebase, may risks to replicate the expiration handling bug
m
After a full day of testing yesterday, my conclusion is: With Bloom filter hits, performance improves by 10%~20% With pre-sorted keys, we could gain another 10% boost I prioritized this optimization over concurrency because: 1、Batch get operations on memtable/sort-run/L0 SSTs align with intuition and are easier to implement 2、RocksDB adopts a similar approach (though with further optimizations) 3、Adding concurrency after this optimization is simpler than the reverse
Actually, the dataset I constructed was overly ordered (I sequentially inserted keys from 0 to key_nums), which caused all Bloom filter queries to be blocked by range_check. Even so, we still achieved a 10% performance improvement.
c
This is awesome. I suppose we should merge 537 now 🙂
@flaneur233 LMK when it’s ready for a final pass. /cc @ableegoldman
f
i think #537 is ready now 🫡
m
when to merge #537?I see you have approved @criccomini
f
with two approvals, I've proceeded this merge by myself 🫡