https://slatedb.io logo
For merges, does SlateDB need to read
# general
r
For merges, does SlateDB need to read every SST file which might contain a given key up until the point that it finds a non-merge operator for that key? I'm thinking about the list append scenario. My guess is that it reads a file to find the key being read, sees that it has a dependency on a previous version of the key (it's a merge) and then traverses up a level to read the previous appearance of the key
c
Yea that sounds right. I’d have to double check, but if you look in the rfcs folder, you’ll find the design doc which explains the read path in detail.
If you want to avoid reading too far back, you can periodically rewrite the whole value out.
r
I was thinking that an additional bloom could be used to indicate whether a value included in the SST is a merge value and hence whether read requests for prior SSTs should be issued in parallel to reduce read latency
c
Interesting.. could be worth an experiment. We do already pre-fetch SSTs when doing reads--scans are relatively cheap once fetched. I'm not sure it would make a huge diff.. but I suppose it depends on the workload.
Maybe worth a GH issue 🙂
a
(deleted message, I misread the suggestion)
r
My scenario is that I want to store millions of small state machine logs with occasional snapshots. The structure is that there will be a Value (snapshot) followed by multiple Merges (op log entries) for a given key (state machine id)
c
Yea.. I think this should be fine. The reads will fetch SSTs in parallel and read sequentially, but will use bloom filter and only read up to the latest snapshot
r
Maybe it's not an issue, but wouldn't it over-fetch? I.e if you have files A B C ordered from oldest to newest, A and B contains a Value and C contains a Merge for a given key. Without a way to distinguish Value/Tombstone from Merge in the bloom, how do we know that A is superseded by B?
My idea is that if you have a bloom which tells you which keys have dependencies on older SSTs, and given Blooms are all cached in RAM, you can quickly work out which files need to be read with a very low probability of over-fetching
This scenario would likely work well for a bottomless Redis where you have some keys which have complex values which are built up over time like hashmaps, lists, etc.
c
> how do we know that A is superseded by B? We don't, but we have a max pre-fetch of 4, I believe. So we'd waste some bandwidth but since we read serially, we'd read C, see that it's a merge, then read B, see it's a value, and stop there.
Hah! I was just looking at https://crates.io/crates/redis-protocol yesterday. If you're playing with something like this, I'd be quite interested.
Yea, I think the bloom filter you're describing would be more efficient. The thing I'm weighing is the value vs. the added complexity/overhead.
I think I'd want empirical proof that it provided significant improvements in speed for this kind of use case.