https://slatedb.io logo
This is an interesting one: https://github.com/sl...
# general
c
a
oh I'd love to take that one if it's not super urgent, love digging into these kind of issues
c
Ah, I'm working through it right now
a
👍 haha nice, curious to see what you find
c
But I can tell you where I'm at. We can spitball the solution
The issue appears to be that the bencher, by default, does not await durable.
So it blasts through a ton of writes. The current WAL table grows very large before it's beven frozen
a
😅 so you're telling me it can push so much traffic that the memory doesn't get freed fast enough? that's actually a pretty great problem haha
c
Kinda.. it doesn't get flushed to L0 fast enough
The WALs are flushed like this: -rw-r--r-- 1 chrisriccomini wheel 80B Nov 1 09:21 00000000000000000001.sst -rw-r--r-- 1 chrisriccomini wheel 236M Nov 1 09:21 00000000000000000002.sst -rw-r--r-- 1 chrisriccomini wheel 512M Nov 1 09:21 00000000000000000003.sst -rw-r--r-- 1 chrisriccomini wheel 1.2G Nov 1 09:21 00000000000000000004.sst
So the L0's are going to be that size
By the time we finish writing the 4th 1.2 gig L0 to disk, the latest WAL table has had so much adata put into it that it's into the 3-5 gig range.
The reason the 4th L0 is important is because that's when backpressure starts to be applied by default.
So I'm thinking we need to apply back pressure at the WAL level as well...
So that writers that aren't awaiting durable still receive back pressure if the unflushed WAL size reaches some amount..
The problem I'm running into is this Send/threading stuff.. I can't figure out a good way to have the put/delete's block
Fighting with Rust
What I'm thinking is to make the write_batch method "maybe_freeze_wal" the way it does with maybe_freeze_memtable.
Then in maybe_apply_backpressure, we can check the number of WALs in the imm_wal vecdeq much like we do with the immutable memtables
I think that'll work...
a
I haven't looked at the flush algorithm enough so this question might make no sense, but why do we wait on finishing a flush before we start writing the next WAL segment to disk? I guess my question is whether we're saturating disk, or if we can better utilize that.
c
Mmm not entirely sure what you mean by finishing a flush.. you mean finishing a flush to WAL or to L0 SST?
I think you might be asking why we don't allow parallel WAL SST writes?
a
yeah that ^
c
Ahh, yes we discussed this in some detail in RFC 1. The algorithm is designed to support it, but we do not allow it right now. It complicates the writer fencing protocol.
a
got it, that makes sense
c
since we use WAL SSTs to fence writers
(you might end up with intermingled SSTs from multiple writers)
This is fixable by defining a fence as N consecutive WAL SST writes from the current writer epoch. bUt it requires.. work
a
wait, doesn't that only matter when you flush the WALs to S3? do we not buffer them on disk first? I think I need to go back and read the algorithm
c
We do not buffer to disk first
a
💡 ah
c
Disk is only for reads
I opened (and the closed) a GH issue discussing writing to disk
a
will go read back up on that one
oh nope, that doesn't seem right
c
Yea looking for it. it's not 9
grr where is it
a
https://github.com/slatedb/slatedb/issues/162 ah this looks like it might be it?
c
Yes!
thats' it
a
I guess I was imagining the file would be written to disk, but not considered durable, until it's flushed to S3. It's just a mechanism to relieve memory pressure. Anyway I'm going to go read up on this so I can come back with a more educated opinion 🙂 this is a fun bug though
c
@almog I yield to you if you want to take a look at this
I did verify that I can make it work properly, but I don't like the way I did it
What I did was update maybe_apply_backpressure to check if there was a WAL in the
imm_wal
list. If there was, then I grabbed the tail of that list and `await_durable`'d on it.
Then, I added a
maybe_freeze_wal
in db_common and called that in
batch_write.write_batch
Essentially, I mirrored the memtable logic for the WAL
The code doesn't feel right, but it did keep the process at 1gig the entire time with reasonable throughput (12k-15k writes/sec @ 8192b per-key = ~125 MiB/s using local FS as object store)
I think the current back pressure strategy is insufficient if a client goes too fast. It can fill a single WAL kv table with gigs of data before 4 L0’s are flushed
a
I'll try to take a look this weekend! I've got a busy rest of my day today but will try my hand at it
i'll learn a lot either way