https://slatedb.io logo
<@965845316370833408> Mind ✅ on https://github.com...
# general
c
r
can you point me to the deets on the write amplification caused by 1GB SSTs? that's not really making sense to me
c
cc @Pierre
p
Why? If you write stuff with many overlaping keys, you will have to rewrite much more
c
My understanding is that the compactor can only compact in 1g increments. In some cases it'd be better off being more granular especially near L0
@Pierre can you clarify the overlapping key part?
p
@criccomini My understanding is that you have: L1: AA-AB L1: AB-BB ... The larger your ranges, the more you need to rewrite when compacting
c
I don't think the compactor pays any attention to keys. It calculates when to compact by size. Whether it's AA-AB = 1GiB or AA-MM = 1GiB doesn't really matter.. it's looking at the total size of sources (sorted runs or L0's) and compacting if it exceeds a threshold
p
So l1s have overlapping keys?
That's ... surprising to me!
c
No, L0's have overlapping.. the rest are non-overlapping
p
> It calculates when to compact by size. Whether it's AA-AB = 1GiB or AA-MM = 1GiB doesn't really matter.. Then it matters because if you have 1GBs ssts and you have a single overlaping key, you need to rewrite the whole thing
c
When merging L0 into L1, right?
p
Yes
c
Gotcha
K that makes sense to me
r
I guess it depends on the ingest pattern. If it's random then you're probably going to need to read/write the entirety of both runs. If it's (loosely) ordered then what you're saying makes sense. Not sure which is better to optimize for.
p
@Rohan Yeah random is awful
I tried it there other day by hashing my keys
That was... terrible
But thinking about how LSM trees work, random don't really make sense
Almost an anti-pattern
r
why was it terrible? Generally speaking, LSM trees are pretty reasonable for a high volume of writes. Random writes are certainly less efficient than ordered writes (though not in slatedb - we haven't properly optimized that yet). As a data point we've used it as a store for deduping records where the keys are just UUIDs. It's been quite reasonable for that use case. We've also tested it as a store for maintaining windowed aggregates over a large window, where the writes are more or less randomly scattered throughout the key space
c
I think the issue is under very high load, moving stuff from L0 to L1 slows down because of these big file rewrites (64m * 8 L0 -> many 1gig L1) can cause backpressure
But only under large load
p
Or large dbs, right?
Imagine a 1TB database with random keys
Don't you rewrite the full terabyte on each compaction?
c
No
Each SR is a full A-Z sort, but between SRs, you can have duplicate keys
p
This, I didn't know...
Thank you
c
We search from the top down when a read is performed
p
So then, what is the purposed benefits of having more than l0 and l1?
r
yeah my point is just that if the distribution of writes is random enough to have one key in each sst it doesn't matter. It has to compact the whole level, in which case it's the same amount of data read/written whether its 4 256MB ssts or 1 1GB sst
c
Yea.. I suppose the 256MB makes it slightly less likely that it'll be in as many SSTs.. but only on the edges..
r
it lets you tradeoff more read and space amplification for less write amplification - so you're not compacting the whole db whenever l0 fills up
p
Aren't we able to write the 256MBs sst in a more parallel-way though?
r
no that would require being able to do subcompactions that let you compact multiple key ranges in parallel
but in the current impl it's going to compact the whole key range serially so it can only do as many parallel i/os as there are sorted runs parcticipating in the compaction. FWIW I haven't observed i/o being the compaction bottleneck anyway. It's usually saturated on compute from the sort-merge. subcompactions would help there.
this is also kind of moot right now because I don't think we've optimized compaction to avoid rewriting an object if it doesn't intersect with any other objects in the compaction
c
Yea that's why I was saying it just helps on the edge.
the whole middle is just treated as a rewrite
Some of dmvk's range bound stuff might help us there later
@Rohan WDYT? I can roll back to 1gig. I'm fine either way...
p
That's less bad than I though too then
Now that I think about this, I wonder how slatedb would perform with mmaped FSTs (https://github.com/BurntSushi/fst) instead of sstables (when using local storage, obviously not through object_store), I want to experiment with that one day 🙂
The architecture is pretty similar but FSTs are quite... magic?
(They are awfully slow to merge though, but probably not that different from sstables)
r
> @Rohan WDYT? I can roll back to 1gig. I'm fine either way... I'm a little worried about big manifests. On the other hand 1GB SSTs have pretty big filters and indexes which also isn't great. I'm ok to leave it at 256MB
c
We can always change it back .. and users can always adjust
f
sorry for late, LGTM!
p
Yeah so, it seems that small ssts with a large block size results in crazy read amplification (This makes sense, I didn't know that multiple overlaping key ranges could exist within l1)
I'll not use that configuration
😄
I'll stay with lz4 and 4KiB for now
It's crazy but seems that I am getting better compression ratio that way anyway
(Wtf)
I see the same thing you do now that I moved the perf test to object storage