https://slatedb.io logo
I have pretty bad news, I reverted back to commit:...
# general
p
I have pretty bad news, I reverted back to commit: 6febe556b918df584063ba9b7b16866cdbf6b9c8 Because, I was running in a weird behavior (looks like a deadlock to me), after around 30 mins-1hour, my app wouldn't be able to process more writes (reads fine though).
c
Hmmmm and still no backpressure logs?
p
No
I was reading through little bit I wonder if it's not a deadlock with stop
Maybe I am on a wrong path (again) though
It was probably not pressure related at all, I would not get any new files in compacted or wal when that would happen
Even if letting the app run for hours
c
Ew that's not good..
🤔
What makes you think it's a deadlock with stop() ?
Do you stop the DB sometimes?
p
Ah, that only happens when you stop the db? So no, that's not this... I didn't understand that codepath properly then
c
Yea, stop() shold only happen when DB is closed
hmm
Can you look share your logs in/around the time that the deadlock is triggered? Maybe on a gist or something
Also.. does it recover on its own?
p
No, it never recovers, even after stopping new stuff to go inside
No log at all @criccomini
And backpressure on my side is "no batches flushed in last 5 secs, queue full"
c
Oof that's not good
I assume all threads in tokio show blocked?
p
No, no cpu usage
😄
c
That's weird....
Everything works on 6febe556b918df584063ba9b7b16866cdbf6b9c8 ?
p
Yes
c
Hmmmmm
p
I am pretty confident that it's slatedb's fault this time
c
It'd be good to get a stack trace when it's in a deadlocked state...
p
I was not able to run more than 20-30 mins at a time
With HEAD
c
🤔 But it was running fine on head yesterday?
p
Yes, but after 30 mins-1hour I'd get this
I didn't share it because I assumed it was my fault
c
Ah
p
c
Let's see...
p
You can actually see when I am in front of my computer from this graph
😂
Everytime there's a "hole" it's that I had to restart my app
That really looks like a lock
c
Can you get it to deadlock again and share the logs at that point?
p
Which logs?
c
The process logs.. warn!'s and such
p
No logs at all from slatedb
c
From start to finish?
p
There's normal logs, until I reach the state where no new writes are going through
Then, it's just my app spamming "queue full, rejecting request"
And no progress from there
c
hmm
but reads still go through?
p
Yes
c
This is odd..
p
I thought I had a deadlock on my side, but I am pretty sure there's nothing like this
I went through 1-2 hours of review
And especially as changing commit just fixes it...
c
yea that's not a good sign for slatedb
can you trigger it again and take a stack trace?
I'd like to see what the threads are locked on
p
Using GDB?
c
ya
p
Fuck, here we go again
Yeah, let me do that
c
It never ends does it... 😛
The write path underwent a lot of changes recently..
p
What I am doing is pretty crazy in the end
So not too surprised
Some of it was slatedb, most of it was me
c
It's a fantastic stress test
p
@criccomini Google has a whole team of engineers on the same stuff, and my implementation performs way better, so I'm pretty satisfied
Btw, my stuff would probably be a good self contained stress test in a ci job
c
Yea I think that'd be really interesting to set up. Was just thinking about this today.
I want to set up something like that
I'm looking at the WAL buffer code
p
I am currently running latest through gdb
Let's see
What's also good is that using google's tools, we can upload a bunch of data, and verify through my api that the data is actually correct
Because the tool verifies the crypto stuff
c
Yea... correctness check 😄
p
I guess so
Or a very complicated integration test
Ahaha
c
lol
p
To be sure, I need to type "run" in gdb, then ctrl+c and "bt" when I reach that state?
c
This is what we do: dump_backtrace() { sudo gdb -p "$pid" -batch -ex "thread apply all bt" 2>/dev/null
p
Ah, so you first gdb ./target/debug/program then that from an other terminal?
c
Yea
(that script does it for tests that are running)
p
My program crashed with gdb...
Now, that's annoying
c
😭
p
Let me try to remove target-cpu=native
When there's more bugs in the debug tools than the thing you are trying to debug... ahaha
[New Thread 0x7ff68d07f6c0 (LWP 3122276)] [New Thread 0x7ff68c9ff6c0 (LWP 3122277)] [New Thread 0x7ff68c7fe6c0 (LWP 3122278)] [New Thread 0x7ff68c5fd6c0 (LWP 3122279)] [New Thread 0x7ff68c3fc6c0 (LWP 3122280)] [New Thread 0x7ff676fff6c0 (LWP 3122281)] 2025-06-28T23:17:41.281182Z INFO compactlog::storage: Batch stats: 9 batches flushed (avg size: 1460, avg time: 509ms), throughput: 2629 entries/sec, queue: 1463/4000, dedup: 66.7% (26324/39469 certs, 27521 KB saved, 213ms) 2025-06-28T23:17:42.384336Z INFO slatedb::compactor_state: finished compaction: Compaction { status: Submitted, sources: [Sst(Ulid(2117013664505156886788680421970131921)), Sst(Ulid(2117013657701417672751850714603883378)), Sst(Ulid(2117013651966362230914921823244120304)), Sst(Ulid(2117013454689065937489373250333396231))], destination: 57 } Thread 22 "tokio-runtime-w" received signal SIGPIPE, Broken pipe. [Switching to Thread 0x7fffee3f86c0 (LWP 3121440)] __GI___writev (iovcnt=25, iov=0x7fffee3f3f80, fd=115) at ../sysdeps/unix/sysv/linux/writev.c:26 26 ../sysdeps/unix/sysv/linux/writev.c: No such file or directory.
This is weird...
(few seconds after launching gdb)
c
hmm
p
Typed continue
Ah I think I need to do handle SIGPIPE nostop noprint pass
c
man.. so many changes between 6febe556b918df584063ba9b7b16866cdbf6b9c8 and now lol
If we can't get a useful stack trace.. might have to binary search our way to the commit that introduced the issue
I would start right before this one.. https://github.com/slatedb/slatedb/pull/519 .. we did a ton of changes to the WAL in 519
I read over the code again.. I don't see any o bvious deadlocks .. but...
p
Still running fine for now
I am kind of scared that running through gdb will somehow fix it
lol
c
Ya.. I guess it'll take a bit huh
lol
Please god no lol
p
😄
Doesn't look too useful
Cpu is 5000% right now
And not much progress
So perhaps, this degrades over time
c
Is it deadlocked?
p
Not yet
c
hrm
p
But the 5000% cpu definitely looks odd
c
Yea.. that could be a gdb side effect?
p
Ah here we go
2025-06-29T00:02:16.331706Z INFO compactlog::storage: Batch stats: 1 batches flushed (avg size: 1579, avg time: 4215ms), throughput: 315 entries/sec, queue: 1450/4000, dedup: 66.7% (3160/4739 certs, 3291 KB saved, 1723ms) 2025-06-29T00:02:21.281187Z INFO compactlog::storage: Batch stats: 2 batches flushed (avg size: 1343, avg time: 2518ms), throughput: 537 entries/sec, queue: 1162/4000, dedup: 66.8% (5386/8068 certs, 5598 KB saved, 2566ms) 2025-06-29T00:02:21.713810Z WARN slatedb::db: Unflushed memtable and WAL size 139623089 >= max_unflushed_bytes 134217728. Applying backpressure. 2025-06-29T00:02:26.633208Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 1267/4000 2025-06-29T00:02:31.281056Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 1373/4000 2025-06-29T00:02:36.282038Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 1473/4000
c
Also.. is GDB going to give us appropriate symbols so we can see the slatedb fn's?
p
2025-06-29T00:02:16.331706Z INFO compactlog::storage: Batch stats: 1 batches flushed (avg size: 1579, avg time: 4215ms), throughput: 315 entries/sec, queue: 1450/4000, dedup: 66.7% (3160/4739 certs, 3291 KB saved, 1723ms) 2025-06-29T00:02:21.281187Z INFO compactlog::storage: Batch stats: 2 batches flushed (avg size: 1343, avg time: 2518ms), throughput: 537 entries/sec, queue: 1162/4000, dedup: 66.8% (5386/8068 certs, 5598 KB saved, 2566ms) 2025-06-29T00:02:21.713810Z WARN slatedb::db: Unflushed memtable and WAL size 139623089 >= max_unflushed_bytes 134217728. Applying backpressure. 2025-06-29T00:02:26.633208Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 1267/4000 2025-06-29T00:02:31.281056Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 1373/4000 2025-06-29T00:02:36.282038Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 1473/4000 2025-06-29T00:02:41.436108Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 1592/4000 2025-06-29T00:02:46.286248Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 1715/4000 2025-06-29T00:02:51.289603Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 4000/4000 2025-06-29T00:02:51.289629Z WARN compactlog::storage: Queue utilization critical: 100% 2025-06-29T00:02:56.281266Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 4000/4000 2025-06-29T00:02:56.281375Z WARN compactlog::storage: Queue utilization critical: 100% 2025-06-29T00:03:01.517349Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 4000/4000 2025-06-29T00:03:01.517372Z WARN compactlog::storage: Queue utilization critical: 100% 2025-06-29T00:03:06.280911Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 4000/4000 2025-06-29T00:03:06.280940Z WARN compactlog::storage: Queue utilization critical: 100%
c
oo a backpressure message
p
So this do degrades
Copy code
-rw-r--r-- 1 root root 192M Jun 29 01:58 01JYWFNBXTY94Y3HD3QN0E4988.sst
-rw-r--r-- 1 root root  47M Jun 29 01:59 01JYWFP5FWH4JJHQ6J3C14DW0N.sst
-rw-r--r-- 1 root root  51M Jun 29 02:00 01JYWFQMNWD7B4XBM3F6XFVDZY.sst
-rw-r--r-- 1 root root  47M Jun 29 02:00 01JYWFRTQ8H48Q22PDP6XZCRPT.sst
-rw-r--r-- 1 root root  47M Jun 29 02:01 01JYWFSWD4X9TCRX06Y2SFPH9G.sst
-rw-r--r-- 1 root root 191M Jun 29 02:01 01JYWFTDBNDVN01C9FBDSHRYT7.sst
-rw-r--r-- 1 root root 787M Jun 29 02:01 01JYWFTFSR6DBKV0QR8MHWNBJB.sst
-rw-r--r-- 1 root root 2.4M Jun 29 02:01 01JYWFTRCFGZKEGSHV59KQ3GGE.sst
-rw-r--r-- 1 root root  47M Jun 29 02:01 01JYWFTTRFM9HGVMEHPN6RK67A.sst
-rw-r--r-- 1 root root  50M Jun 29 02:02 01JYWFW4R956PETT2PFPAY6FT8.sst
What's weird is that there's no progress, see
(Look the time)
c
seems to imply compaction is going on and backpressure is being applied?
p
Ah but this time it recovered
2025-06-29T00:03:41.281471Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 1213/4000 2025-06-29T00:03:46.386352Z INFO compactlog::storage: Batch stats: 1 batches flushed (avg size: 2000, avg time: 8325ms), throughput: 400 entries/sec, queue: 1592/4000, dedup: 67.5% (4035/5982 certs, 4078 KB saved, 627ms) 2025-06-29T00:03:51.281773Z INFO compactlog::storage: Batch stats: 3 batches flushed (avg size: 1305, avg time: 2153ms), throughput: 783 entries/sec, queue: 1433/4000, dedup: 67.1% (7875/11730 certs, 8129 KB saved, 2611ms)
Hmmm
c
> 2025-06-29T00:02:21.713810Z WARN slatedb::db: Unflushed memtable and WAL size 139623089 >= max_unflushed_bytes 134217728. Applying backpressure. Is very telling
p
Yes
So perhaps I was stupid, didn't see the backpressure message because I lost it in the "screen" output?
And my server is too loaded for slatedb to make progress?
c
haha could be.. it'd be nice if the logs were saved so we could see 😵‍💫
But so far it looks like legit backpressure from compactor
p
What I don't get in this situation is that why restarting the app fixes it?
And here
Until I restarted my app
Nothing happened
c
It clears the in-memory bufer
the unflushed bytes goes back to 0 each time
p
hmm
c
so there's no backpressure after a restart
until the put's fill up the L0 and WAL again
p
I really have a hard time to believe that no compaction could happen in 30+ mins
That seems unlikely?
c
Yea... that does
Maybe the compactor died or deadlocked... 🤔
I would at least expect to see DB Levels logs every 10s
p
Let me run again in release at tip
And see what actually happens
c
k
p
Thinking about it this doesn't change much
because after a restart I immediately get write pressure
So even if the unflushed stuff is gone
There's immediately new unflushed stuff
That doesn't explain why it works fine for 30 mins+
I am starting to see something
The cpu seem to get "hogged"
And compactions start to be slower and slower
Until there's no compactions that can advance anymore
That's odd
(More cpu, doesn't mean more activity in compacted)
c
Ya that tracks. So it just takes some time to overwhelm the compactor
p
Yes, I wonder if then the low cpu usage that I saw after hours and no compaction means something interesting
c
Want to try the commit before I did the async compactor refactoring? That’s a somewhat recent commit
p
Is it possible that multiple compactions block each other?
c
It shouldn’t be but I could have broken something lol
p
Also, I wonder if the high number of concurrent compactions I set couldn’t be the cause
IE. useless work being performed + some kind of blocking
c
Yea it’s possible. Either the compactor is slow or there’s a bug…
Might be interesting to try right before that commit. Just to make sure I didn’t break anything.
p
I will run that full night now at head with default compaction concurrency
If when I wake up it breaks, I will try before they
That*
c
Ya get some sleep!
p
🥲 🥲
So here it is
(With HEAD)
Cpu usage looks off
And here is the files in "compacted"
Copy code
-rw-r--r-- 1 root root  113M Jun 29 04:06 01JYWPZ4R70CMPV5930WB1C0NN.sst
-rw-r--r-- 1 root root   89M Jun 29 04:06 01JYWPZ73BTAGQG5K4SEBGTZ7R.sst
-rw-r--r-- 1 root root   89M Jun 29 04:06 01JYWPZ8BK05AJFJ4QG135CS0D.sst
-rw-r--r-- 1 root root   90M Jun 29 04:06 01JYWPZ976N5XRQ280A8EB5QQ5.sst
-rw-r--r-- 1 root root   89M Jun 29 04:06 01JYWPZ9X88M3T883H1WSWQ7GW.sst
-rw-r--r-- 1 root root   89M Jun 29 04:06 01JYWPZAV8E8ZDAJ8MV6FY4506.sst
-rw-r--r-- 1 root root   89M Jun 29 04:06 01JYWPZBRSRKY1TKMPSD7SCDK2.sst
-rw-r--r-- 1 root root   91M Jun 29 04:06 01JYWPZCQ2KRVZEEH02B7BHV2A.sst
-rw-r--r-- 1 root root   90M Jun 29 04:06 01JYWPZDEJD7HQ7FQGAQHB926W.sst
-rw-r--r-- 1 root root   49M Jun 29 04:06 01JYWPZE3G4Q3AJCS7B4JWSKDY.sst
-rw-r--r-- 1 root root   99M Jun 29 04:06 01JYWPZE9EBE85CS37S2GCVTZG.sst
-rw-r--r-- 1 root root   58M Jun 29 04:06 01JYWPZJ7GG2GQ5XH94C73SAV9.sst
-rw-r--r-- 1 root root   49M Jun 29 04:07 01JYWQ0HK0HTWJMHXHGR32S179.sst
-rw-r--r-- 1 root root   45M Jun 29 04:07 01JYWQ1H38FVES7EXN2RM22TB9.sst
-rw-r--r-- 1 root root   45M Jun 29 04:08 01JYWQ20WQDC5WNKCC4PCBZZ36.sst
-rw-r--r-- 1 root root   99M Jun 29 04:08 01JYWQ23GD11YV6KDXK4KJJ2F8.sst
-rw-r--r-- 1 root root   89M Jun 29 04:08 01JYWQ246VSK5KEYKF9CV81SG7.sst
-rw-r--r-- 1 root root   47M Jun 29 04:08 01JYWQ2PRQ02D8DNRJSWQSEMJ0.sst
-rw-r--r-- 1 root root   46M Jun 29 04:08 01JYWQ39CWQVGQ8EH1X3D94RVX.sst
-rw-r--r-- 1 root root   46M Jun 29 04:08 01JYWQ3SNJ9JRZ1B9GXDEFBVPK.sst
-rw-r--r-- 1 root root   47M Jun 29 04:09 01JYWQ4C6XJA4P1N0271F94GCT.sst
-rw-r--r-- 1 root root   99M Jun 29 04:09 01JYWQ4HP2T5GNKZNZD7K6P6W6.sst
-rw-r--r-- 1 root root   86M Jun 29 04:09 01JYWQ4JF3191W3SAXGFFWR6TA.sst
-rw-r--r-- 1 root root   51M Jun 29 04:09 01JYWQ58YW3EM5B9K6QXHTA8PV.sst
Now trying it b9f729ae974f999ecddcc761d743b30a070ff3bd
Hmm same at b9f729ae974f999ecddcc761d743b30a070ff3bd
It's definitely weird, for about 10-13 mins, the compactor makes progress
No further after that
Let me try something...
c
What about trying the commit before this?
I worry I introduced some compactor issue in that refactor maybe
p
I tried before this, it's same
See the spikes?
Every time I restart my app and fine again
2025-06-29T14:59:42.908012Z INFO compactlog::storage: Batch stats: 2 batches flushed (avg size: 3739, avg time: 2639ms), throughput: 1495 entries/sec, queue: 16/10000, dedup: 67.4% (15434/22907 certs, 16786 KB saved, 3910ms) 2025-06-29T14:59:47.103233Z INFO slatedb:🕰️ Clock tick 1751209187102 is lagging behind the last known tick 1751209187103. Sleeping 2ms to potentially resolve skew before returning InvalidClockTick. 2025-06-29T14:59:47.908469Z INFO compactlog::storage: Batch stats: 1 batches flushed (avg size: 3671, avg time: 2750ms), throughput: 734 entries/sec, queue: 57/10000, dedup: 67.3% (7551/11218 certs, 8215 KB saved, 1991ms) 2025-06-29T14:59:52.908058Z INFO compactlog::storage: Batch stats: 1 batches flushed (avg size: 3755, avg time: 4474ms), throughput: 751 entries/sec, queue: 47/10000, dedup: 67.4% (7762/11516 certs, 8491 KB saved, 2590ms) 2025-06-29T14:59:57.907986Z INFO compactlog::storage: Batch stats: 2 batches flushed (avg size: 3880, avg time: 3591ms), throughput: 1552 entries/sec, queue: 0/10000, dedup: 67.5% (16098/23857 certs, 17466 KB saved, 5602ms) 2025-06-29T15:00:02.908213Z INFO compactlog::storage: Batch stats: 1 batches flushed (avg size: 4073, avg time: 3948ms), throughput: 814 entries/sec, queue: 0/10000, dedup: 67.7% (8522/12589 certs, 9254 KB saved, 3263ms)
When I start the app each batch flushes in 700ms
AND I can see that the cpu is spinning when that happens
From 1400% cpu (serving reads, writes...)
It gets stuck at 3000%+
While making less progress
c
Hmmmm… but things work properly on the original commit you were using before all this?
p
Now I am not all sure
c
Yea.. I wonder…
p
Lol
c
If you go back to that commit so you see the same
You find all the oddest behavior 😂
p
What the cpu usage seems to indicate is that the compactor is "spinning" Or something else?
Wait, the 10-13 mins marker is very suspicious
c
Yea…
p
How often does the gc kick-in already?
c
Every 5 mins
I think by default
p
Hmmm
See, less and less throughput 2025-06-29T15:06:32.908130Z INFO compactlog::storage: Batch stats: 1 batches flushed (avg size: 3467, avg time: 6868ms), throughput: 693 entries/sec, queue: 79/10000, dedup: 66.9% (7012/10479 certs, 7526 KB saved, 5045ms) 2025-06-29T15:06:37.907982Z INFO compactlog::storage: Batch stats: 1 batches flushed (avg size: 3445, avg time: 6048ms), throughput: 689 entries/sec, queue: 50/10000, dedup: 67.0% (6975/10413 certs, 7525 KB saved, 4789ms) 2025-06-29T15:06:42.908880Z INFO compactlog::storage: Batch stats: 1 batches flushed (avg size: 3469, avg time: 5900ms), throughput: 693 entries/sec, queue: 15/10000, dedup: 67.1% (7053/10509 certs, 7599 KB saved, 4723ms) 2025-06-29T15:06:47.908709Z INFO compactlog::storage: Batch stats: No batches flushed in last 5s, queue: 119/10000 2025-06-29T15:06:52.909141Z INFO compactlog::storage: Batch stats: 1 batches flushed (avg size: 3639, avg time: 6500ms), throughput: 727 entries/sec, queue: 113/10000, dedup: 67.1% (7405/11040 certs, 7982 KB saved, 4455ms) 2025-06-29T15:06:57.908538Z INFO compactlog::storage: Batch stats: 1 batches flushed (avg size: 3449, avg time: 7668ms), throughput: 689 entries/sec, queue: 85/10000, dedup: 67.1% (6999/10436 certs, 7539 KB saved, 5723ms)
Ah wait I have an idea
Let me try something
I am using a mokache for my app
To try things out, I lowered the ttl to 5 mins
Now, it hangs at "5 mins"
Pretty suspicious
Wtf
Let me confirm that
I wonder if my access patterns couldn't have triggered a deadlock in moka now
c
Hmm.. try foyer instead? I think that’s what responsive uses
p
If it's this, it's so fucking stupid
lol
I'd love it to be this
Let me confirm
I think I may have found the problem
Lol
I really hope it's this this time
c
😮
Nice spike there…
p
I restarted my app without the block cache
And it just would not do anything, and barely any io
I restarted my app with minio
Now it's making progress
I enabled the cache again, with minio as a store
We'll see
Do the local cache uses the object_store crate too?
c
🤔 you mean the block cache or the disk cache?
The disk cache uses object store crate I think. It wraps an object store and caches reads
p
Ok
c
Searched deadlock on moka… https://github.com/moka-rs/moka/issues/240
No idea if it’s related
Hmm
c
hahaha
you and I foudn the same thing 😉
Ah nm I see you're linking toa c omment
lemme see..
I don't see us using
get_with
in our repo tho
How's your current test going?
Which cache? moka still?
If it tanks again, I suggest trying Foyer instead
We have @Croxx to answer questions here 🙂
p
I will try that
I am also investing an other theory
at this point I'll try on a new db
I think I accumulated so much work on the compaction side
That when I start my app I immediately reach 5k% cpu
So let's start with a clean state
Let me also stop whatever is also running on this server
To get proper latency readings
At this point I am pretty confident it's moka's fault
2025-06-29T16:38:21.787214Z INFO compactlog::storage: Batch stats: 24 batches flushed (avg size: 14, avg time: 99ms), throughput: 69 entries/sec, queue: 0/4000, dedup: 65.0% (642/987 certs, 551 KB saved, 0ms) 2025-06-29T16:38:26.787780Z INFO compactlog::storage: Batch stats: 25 batches flushed (avg size: 11, avg time: 101ms), throughput: 59 entries/sec, queue: 0/4000, dedup: 65.3% (558/855 certs, 469 KB saved, 0ms)
With moka = 1800ms
Yeah
Copy code
2025-06-29T16:39:11.788232Z  INFO compactlog::storage: Batch stats: 20 batches flushed (avg size: 1797, avg time: 188ms), throughput: 7191 entries/sec, queue: 239/4000, dedup: 66.7% (71884/107849 certs, 76042 KB saved, 969ms)
Never saw 7k with moka
Latency is half too
🤦
🤦‍♂️
@criccomini I think it was moka all along
And I was seeing that at the 10 mins mark because it's when my cache was full
I'll run this for few hours now
Don't know what you think but if this is confirmed, moka has no place in slatedb lol
c
Yea that's brutal...
I wonder what's causing the issue
On the moka side...
p
Now reads go though properly too
(Left with moka, right after)
Could be just be classic contention
TBH I don't even want to try to debug anything in that, I'm done if that's the issue
LOL
c
haha yea totally
p
When you think about it my pattern is basically, read a bunch, write a bunch, 20-30k keys a second
c
Are you trying Foyer now?
p
That's basically a stress test
No, moka for the block cache, I just disabled the cache in my app
I am caching key / values for the hot path
I'll ditch moka too in slatedb
But one thing at a time
Cpu usage is way lower too
That's very suprising...
That's very telling (left with moka, right without)
Btw the 10 seconds "max latency" is very suspicious too
It should have been unbounded if it was a true "too much work" issue
c
haha yea... that does suggest contention
p
Fuck that, I spent almost 20 hours debugging that I think
I'll try foyer now
c
Computers are hard...
p
The thing is that problems in isolation are easy to fix "Lol don't use a linked list, use a hashmap"
But when you have so many systems interacting with so many things
It's hard to reason about anything
And you are litteraly chasing ghosts sometimes...
Miss my youth writing hello.php
This was easy 😄
c
hahaha
Sometimes I think PHP was the epitome of web dev...
p
I was very critical of the execution model (Actually serverless, handle request, create env, destroy env)
But that eliminate a lot of complexity
I won't miss sql injections though
This is so stupid lol
Not really php's fault, but kind-of
c
Hi. Thank you for informing me. This seems a long thread and I'm not sure where to start. Would you like to summary your question. 🙌
p
No question, I'll just try your lib instead of moka
Moka seems to deadlock and behave very poorly under very concurrent access
Spent the last 2-3 days debugging "hanging"
Thinking it was slatedb's fault
c
Please let me know the result after switch to foyer. Btw, foyer can also serves as in-memory-only cache.
p
And as I was showing , on the left it's with moka, on the right, without
LOL...
And now, cpu usage is down 3-4x too
Ok the difference with foyer is massive
2025-06-29T17:52:26.519316Z INFO compactlog::storage: Batch stats: 7 batches flushed (avg size: 4019, avg time: 257ms), throughput: 5627 entries/sec, queue: 0/10000, dedup: 65.7% (55569/84583 certs, 78620 KB saved, 104ms)
I couldn't get under 1-2 seconds per batch using moka
Copy code
2025-06-29T17:55:28.616376Z  INFO compactlog::storage: Batch stats: 19 batches flushed (avg size: 1956, avg time: 206ms), throughput: 7436 entries/sec, queue: 19/10000, dedup: 66.7% (74404/111593 certs, 78722 KB saved, 862ms)
That's ... awesome
That litterally changed the scale ahaha, look on the right
Couldn't get past 2-3k
Now hitting 10k+
Cpu usage is down 2000% (20 cores), was using 2000-3000% cpu to ingest, now little under 1000
c
Glad to hear that! 🙌 (I hope I didn't misunderstand. I'm not very familiar with the workload and setup you used for testing. Are there more intuitive numerical comparisons of the differences? For example, improvements in average latency, IOPS, or throughput? The numbers above are a bit overwhelming, making it hard for me to understand what each item corresponds to. Thank you very much! It would be even better if you could share it.
p
Basically, each batch contains thousands of entries to insert, each entry makes multiple read/write calls to slatedb, I have a cache that are caching the reads
So in total, per second, there is 20-50k+ writes and similar reads
What's very telling @criccomini is that in the logs I never saw more than 4 l0s getting compacted
Now I am able to push so much that I often see 8 l0s
c
Catching back up
Wow.. this is great news.
I suppose we should change the default from moka to foyer in slate...
@Pierre so.. all good now? 😅
p
I don’t want to shout victory too early
Let it run for few hours
lol 🤮
c
Sounds good!
p
I’d go further and say that if it’s confirmed moka is garbage
And probably should be completely removed lol
c
Yea it's surprising.. I thought it was well adopted
p
Yeah, it’s fixed
🤦‍♂️
I would have never guessed that
Throughput and latency steady
If you want to remove Moka I deserve to make that PR lol
c
Let’s do a default to foyer for now. Want to submit that PR?
IIRC, moka has a few more features (TTL/TTI?)
You should hook DbStats up to this, too. Would be helpful
p
Yes
Possibly we should just warn in the doc that under high concurrency this has been known to cause problem
Just has a heads up
(In the moka example stuff)
Just as a follow up, still fine after one more hour
So I think it was really this 🙂
What a relief
And I am at HEAD, so everything is fine
c
🎉
That’s fantastic
p
Agreed
c
IMO we should still default to foyer
p
Yes of course
The default is broken to me
I’ll pr that
c
Yea
Thx
p
(As an aside between this and the gc deletes thing it shouldn't stuff, I really find the worst stuff ahaha)
c
Yea.. definitely stressing it, which is good
I want to fix the GC stuff in 0.8
p
Yeah this is ugly
The gc "bug" 😛
c
oh haha yea
I think the fix should be do-able, though. Then it'll be nice and safe
p
At least this got identified as what it is
It was very unclear initially, and pretty scary
c
yea I was pretty worried we broke something
p
And now that I am turning the other knobs, I really wonder if the default 1GB max sst size makes sense
It doesn't seem that it'd improve read latency or throughput, but it makes write amplification terrible
c
Yea it just keeps the manifest a bit smaller
p
And in cases where you have a lot of overlaping keys and you have to rewrite a large portion of l1, that's quickly insane
(My experiment of hashing keys was a... failure ahaha)
It basically rewrite full l1 at each l0 -> l1
Gotta love nvme drives ahaha
c
Jeez....
Insane...
p
Through zfs that to be
So not even as fast as it could
c
What kind of machine is this lol
p
AMD EPYC 9454P with 7 datacenter nvme
c
wild
p
... expensive ahaha
What's crazy is that it's handling the workload, the raid-5 like parity checks, the write and read amplification from zfs, my crypto stuff
At 10GB/s ... lol
Btw same machine earlier that day
I got surprised
c
Computers have gotten so insane now..
p
Yeah
Compare that to the spinning rust of not even 10 years back
c
hahaha
yea.. it's wild.. I still remember installing a "math co-processor" so my 386 could do floating point ops in hardware 🤣
p
Copy code
2025-06-29T23:34:49.280081Z  INFO slatedb::compactor: in-flight compaction: ["12", "8", "4", "0"] -> 0: Submitted
2025-06-29T23:34:49.280085Z  INFO slatedb::compactor: in-flight compaction: ["l0", "l0", "l0", "l0"] -> 15: Submitted
2025-06-29T23:34:50.350142Z  INFO slatedb::compactor: in-flight compaction: ["12", "8", "4", "0"] -> 0: Submitted
2025-06-29T23:34:54.279892Z  INFO compactlog::storage: Batch stats: 21 batches flushed (avg size: 2000, avg time: 229ms), throughput: 8400 entries/sec, queue: 1877/4000, dedup: 66.7% (84019/126019 certs, 87825 KB saved, 440ms)
2025-06-29T23:34:54.279907Z  INFO compactlog::storage: Read stats: 45528 ops/s, 4 MB/s, avg size: 0 KB
2025-06-29T23:34:59.144914Z  INFO slatedb::compactor_state: finished compaction: Compaction { status: Submitted, sources: [SortedRun(12), SortedRun(8), SortedRun(4), SortedRun(0)], destination: 0 }
2025-06-29T23:34:59.147316Z  INFO slatedb::compactor_state: accepted submitted compaction: Compaction { status: Submitted, sources: [Sst(Ulid(2117119370266351275398611635218206264)), Sst(Ulid(2117119367860426848223623671739418206)), Sst(Ulid(2117119365557922885233301527440085843)), Sst(Ulid(2117119363240841639704275013484185038)), Sst(Ulid(2117119360939925997309254212488508294))], destination: 16 }
2025-06-29T23:34:59.147335Z  INFO slatedb::compactor: in-flight compaction: ["l0", "l0", "l0", "l0", "l0"] -> 16: Submitted
2025-06-29T23:34:59.276861Z  INFO slatedb::compactor: in-flight compaction: ["l0", "l0", "l0", "l0", "l0"] -> 16: Submitted
2025-06-29T23:34:59.279949Z  INFO compactlog::storage: Batch stats: 20 batches flushed (avg size: 2000, avg time: 232ms), throughput: 8000 entries/sec, queue: 2119/4000, dedup: 66.7% (79970/119971 certs, 83325 KB saved, 507ms)
2025-06-29T23:34:59.279974Z  INFO compactlog::storage: Read stats: 45365 ops/s, 5 MB/s, avg size: 0 KB
I've added some logs
45k get per second + around 20k writes per second
That looks really good
(This: 2025-06-29T23:34:59.279974Z INFO compactlog::storage: Read stats: 45365 ops/s, 5 MB/s, avg size: 0 KB )
c
Amazing
That’s such good news haha
p
Yeah, I am surprised , great work guys
The 1GB sst default is definitly shit though, it killed performance
So much work compacting
That just does not happen with 128MB-256MB
c
Hmm… yea. Let’s drop it to 256
So swap moka and drop sst to 256mb
p
You want me to pr that in one go?
Btw such a throughput would definitly make postgres on top of slatedb fly
c
Ya please
p
There's no reason why it couldn't work as-good or even faster than postgres' storage engine
c
Ya I want to create a projects page and pg_slatedb is top of mind
Hoping someone will do it
p
I can have a shot at this, but snapshots are basically required
Otherwise it would be a massive mess
c
Ya. Snapshots are around the corner. @flaneur233 is doing them now.
If you want to take a crack, that’s be amazing.
p
I myself have a 25TB postgres database, great benchmark again 😂
c
Is it crypto verified like the current workload?
p
No @criccomini
This is more traditional, heavily transactional
But I insert 40k rows a second
(yeah...)
c
Ahh oh well
Hahah damn dude
p
I cannot help myself, it seems
c
😂
p
What's funny is everytime, I take the simpler approach, while everyone else go the cassndra/coakroach/weird db path
And they have a shit system
c
They can’t resist
Gotta join the boring technology club
p
I think the s3 as a storage but proper stateful database + cache is a better design
Full distributed just doesn't really work except for data warehouses
Even with dual 40gbps port network cards
You don't reach what you can achieve on a single system with nvme...
s3 basically forces good design when you want something fast
Because it's slow in itself, high latency
slatedb is really sound IHMO
Now that I got things under control, it looks beautiful
Latencies basically flat
c
Yea man I’m kinda blown away myself lol
Rust is so fast and, though really annoying, seems to produce apps that just work…
Some folks ran it through antithesis and it.. worked lol
p
Now, what I wonder about Foyer, is that, with the hybrid cache, is it faster to just use foyer for everything, or is the cache handled by slatedb for the "disk cache" is faster
c
Looking forward to a benchmark!
Btw, to fully leverage the power of foyer, I recommend to use
fetch()
API for getting object. I provide the following functionalities: 1. Request I/O duplication for the same key for both disk cache and remote storage. 2. Automatic cache refill after fetching from the disk cache and the remote storage. 3. If cache miss is caused by disk cache throttle (if configured), the API only fetch from remote storage, without unnecessary disk cache refilling. 4. Mark the source of the cached entry from disk cache / remote storage. If it comes from the disk cache, an
age
will be granted to the cached entry to decide wether to fill it back to disk cache or skip this write without double checking the disk cache indexer to reduce concurrent access overhead.
c
Would you mind opening a GH issue to this effect?
p
What I noticed where Foyer will probably work better is that slatedb's own disk cache seems to always need to download, even things we already uploaded just now
c
Yea this is an optimization we need to do. IIRC, Rohan added l0 writes going to cache now…
p
Just noticed that from GitHub phone app
They really made this pretty
🥲
@Croxx I've implemented Foyer in my new project (A s3fs, but that aims to be actually good), that works super nicely there too 🙂
Compiling my fs on top of my fs https://github.com/Barre/ZeroFS
I'm pretty surprised at how well everything performs
c
Cool! I just saw ZeroFS from multiple sources! 🙌 Thank you for your trust. There will be significant changes in the foyer soon, please stay tuned!
p
> Cool! I just saw ZeroFS from multiple sources Ahaha, that's my inner salesman 🙂
c
I think it is good news now. 😃
p
ahaha yes
I cannot see a way to access Store from an HybridCache 🤔
c
This API is for internal usage and testing. The close API will call it internally. Do you have requirement to manually wait for flushing and reclaiming?
p
It’s basically to enforce consistency
Insert and delete is not await
So for now I cannot use the hybrid cache because I cannot handle proper invalidation cycles
@Croxx if you are open to it, I’d love to submit a PR for that
c
Sure. Sorry for the late response. I'm on a trip this week.
p
Enjoy
c
Thank you. 🥰
p
message has been deleted
Btw, cache hit rates from foyer with ZeroFS!
c
If you're not sure about the details you need. Please submit a RFC first and let us discuss together.
Nice TUI, BTW
There is still space to inprove hit ratio.
Let's investigate it later.
c
what tui is that?
p
It’s not a tui, it’s comfy_table flushed every 5s to stdout!
Check the code in stats.rs
In zerofs
c
nice!
p
Yeah that’s cool, that’s why I love rust
People do this kind of nice ui stuff
In C you just don’t have such a ecosystem for “UX”
c
Yea Rust community is this weird mashup between javascript and c/c++
p
Python too I’d say
Or ruby
I was very heavy into python before getting into rust
And then I thought “is python performance trade off actually worth it?”
Because most of my time is thinking about design, not syntax
c
Yea..