almog
10/13/2025, 3:49 PMLevelGet) work with iterators instead of just returning the first value it finds. I have a working patch for it but then I thought about leveraging the work done to make range scans (DbIterator) and wanted your takes on whether you thought it makes sense to keep them separate or merge (no pun intended) the two code paths.
The downside of merging them is that we're going to need a lot of special casing for the case where the Range covers only a single key (that way we can, for example, leverage bloom filters to skip SSTs/SRs).
cc @criccomini @Rohanalmog
10/13/2025, 3:50 PMalmog
10/13/2025, 3:51 PMRohan
10/13/2025, 7:26 PMalmog
10/13/2025, 7:44 PMDbIterator already has an option for how much you want to prefetch and it defaults to 1 (no prefetching). I'm already going down the path of prototyping the shared approach so I'll see how it plays out and how much "special casing" we need to do for the get to behave basically the same way it does todayalmog
10/13/2025, 7:45 PMRohan
10/13/2025, 7:47 PMalmog
10/13/2025, 7:57 PMalmog
10/13/2025, 8:57 PMalmog
10/13/2025, 9:38 PMalmog
10/13/2025, 9:38 PMalmog
10/13/2025, 9:39 PMcriccomini
10/14/2025, 4:28 PMcriccomini
10/14/2025, 4:30 PMcriccomini
10/14/2025, 4:32 PMcriccomini
10/14/2025, 4:32 PMcriccomini
10/14/2025, 4:33 PMalmog
10/14/2025, 5:44 PMnew meaning there's no way to avoid doing things like fetching blocks from S3 until the first next_entry which is a no-go for a basic get since you probably won't need most SSTs. I'm planning on splitting out an init method into the iterators so that we can defer the initialization of iterators OR call it eagerly when we want to prefetch/initialize iterators for range scans.
2. the bloom filter stuff is a little tricky because we need to record false positive rate so I'm thinking of having a special SingleKeySstIter that wraps the SstIterator and handles the bloom filter checking and stat recording. The get code would instantiate that iterator (which would also work for cases where you have merge operands for the same key).
3. I need to either change the MergeIterator to have a concept of "priority" based on the iterator level (WB/MEM/L0/SR) that allows it to work well with lazy init or create a new iterator that behaves the same way LevelGet does today. I'm leaning toward the latter but that'll cause another point of diversion between the two paths though only at the top level.criccomini
10/14/2025, 6:24 PMcriccomini
10/14/2025, 6:26 PMcriccomini
10/14/2025, 6:26 PMcriccomini
10/14/2025, 6:26 PMalmog
10/14/2025, 6:27 PMcriccomini
10/14/2025, 6:27 PMalmog
10/14/2025, 6:27 PMcriccomini
10/14/2025, 6:28 PMalmog
10/14/2025, 6:29 PMalmog
10/14/2025, 6:32 PMdb_state.core().l0 is always safe to return the first value found if you discount merges.Rohan
10/14/2025, 7:41 PMcriccomini
10/14/2025, 8:03 PMcriccomini
10/14/2025, 8:04 PMRohan
10/14/2025, 8:23 PMalmog
10/15/2025, 6:14 PMcriccomini
10/15/2025, 6:58 PMcriccomini
10/15/2025, 6:58 PMcriccomini
10/15/2025, 6:58 PMcriccomini
10/16/2025, 8:27 PMalmog
10/16/2025, 8:34 PMcriccomini
10/17/2025, 5:05 PMalmog
10/17/2025, 6:52 PM