6 ms·
My LSM tree was slower than a B-tree. Then I profiled it
- AtlasBarfed 5mo agoYour right should go into a queue and get compacted later on? That's what Cassandra does iirc
- jmalicki 5mo agoWriting to disk for every write is required, otherwise you're not durable. Sure it's faster to never write to disk, then you reboot and you've lost data. /dev/null is a webscale database that is even faster!
- FarmerPotato 5mo agoread the whole article. WAL is the transaction log and the author tested correctness after a crash.
- jmalicki 5mo ago"Every batch of writes called file.Write on the write-ahead log" You don't write to the WAL on a batch. > the author tested correctness after a crash. You mean the LLM?
- bawolff 5mo agoThey tested SIGKILLing the process, they didn't test a power loss situation.
- teraflop 5mo agoWell, the thing about reliability is that you can't really guarantee it by testing one particular scenario. It seems to me that neither the old nor the new version of the code is really "durable" as I would understand the word. The old version made a write syscall per batch, but doesn't say it also did an fsync per batch. The new version writes data to an mmap'ed file, and calls fsync in the background. So both versions are "durable" in the sense that written data is preserved even if the process gets killed, because it's in the OS page cache. But in both versions, a write can be completed before the data actually makes it to disk, so a power failure will lose acknowledged writes.
- Retr0id 5mo agoThere are a lot of use cases where you only truly need consistency, and durability can take a back seat. RocksDB for example does not fsync its WAL writes in the default configuration. https://github.com/facebook/rocksdb/wiki/WAL-Performance#non-sync-mode https://github.com/facebook/rocksdb/wiki/WAL-Performance#non...
- jmalicki 5mo agoIf you can't at least guarantee write ordering you don't even have consistency. Fsync is often used when the data doesn't truly need to be on disk, because there aren't very good write ordering APIs exposed, even if that's all you truly need.
- dj_axl 5mo ago> A 100-bit bloom filter holding 100,000 keys is saturated instantly. Every bit is set. It returns “maybe present” for every key you ask about — which means it filters nothing, and every read falls through to a full file scan. Hahaha. (Seems like the bloom filter library isn't set for maximum false positive rate and/or to autoexpand.) Edit: Actually there's a BloomFalsePositive setting, maybe it never gets used? Also maybe it's not a library and it's a custom implementation.
- FarmerPotato 5mo agoI guess you've never made a silly mistake, found it, and admitted it. The author wrote this as a learning exercise. And is sharing the process.
- Retr0id 5mo ago> A 100-bit bloom filter holding 100,000 keys is saturated instantly > This is the kind of bug you only find by building the thing and measuring it. No? I mean, maybe if you're vibecoding it's the only way, but in the prehistoric days you could reason about what code would do before you ran it.
- bawolff 5mo agoMistakes are always easy to recognize in retrospect, so hopefully this comment isnt too unfair, but one thing that caught me about this, is that logically it makes no sense. You would never use a bloom filter for just 10 entries. If you have only 10 entries it is almost certainly faster to skip the bloom filter. So i feel like that is the part that should have instantly stood out. [Obviously, i've made my own silly mistakes over the years, many much sillier than this, its just weird to describe this one as only detectable by profiling]
- FarmerPotato 5mo agoSure, it logically makes no sense. But while learning a new subject, have you never made a silly mistake like: bool getSchemaSizes(size_t * expectedBatchSize, size_t * expectedEntriesPerBlock) { ... } size_t expectedEntriesPerBlock, expectedBatchSize; getSchemaSizes(&expectedEntriesPerBlock, &expectedBatchSize) initBloomFilter(expectedEntriesPerBlock)
- bawolff 5mo agoI said as much in my comment.
- HelloNurse 5mo agoThe quoted code suggests that the wrong sizes aren't evident constants in code (there is a function to compute/retrieve them) and extra inspection during debugging is the most plausible way to detect them. Hopefully this kind of bug is enough to teach the important of measuring, logging and testing to a naive optimist.
- teraflop 5mo agoThe article doesn't link to it but this appears to be the repo in question: https://github.com/AasheeshLikePanner/lsm-tree-go https://github.com/AasheeshLikePanner/lsm-tree-go I'm very amused by this obviously AI-generated "benchmark program": https://github.com/AasheeshLikePanner/lsm-tree-go/blob/main/bench/fulltable.go https://github.com/AasheeshLikePanner/lsm-tree-go/blob/main/...
- sheepcow 5mo ago> A few weeks ago I wanted to understand how the storage engine inside RocksDB actually works. Not read about it. Build it. Immediate tell that this was written by AI. Another thing I've noticed lately - AI's overuse of "every": > Every batch of writes called `file.Write` on the write-ahead log. > Every read was scanning entire SSTable files. > Every bit is set. > Every value matches.
- FarmerPotato 5mo agoWell, this is sad.
- kristianp 5mo agoAlso the header "The honest benchmarks" is an irritating LLM style. And all the commas! So many commas and short sentences! E.g: "Same database, same machine. The only difference is the write pattern.". It's so bad I thought someone might be copying LLM style, because the writing seems so stilted.