brainhart.dev
07/16/2025, 5:25 AMcriccomini
07/16/2025, 6:15 PMbrainhart.dev
07/16/2025, 6:22 PMl0_sst_size_bytes = 1048576. Here's the resolved set afaict:
Writer:
Settings {
flush_interval: Some(Duration::from_millis(100)),
wal_enabled: true,
manifest_poll_interval: Duration::from_secs(1),
manifest_update_timeout: Duration::from_secs(300),
min_filter_keys: 1000,
max_unflushed_bytes: 1_073_741_824,
l0_sst_size_bytes: 1024 * 1024,
l0_max_ssts: 8,
compactor_options: Some(CompactorOptions::default()),
compression_codec: None,
object_store_cache_options: ObjectStoreCacheOptions::default(),
garbage_collector_options: None,
filter_bits_per_key: 10,
default_ttl: None,
}
Reader is just the default, which resolves to:
DbReader {
manifest_poll_interval: Duration::from_secs(10),
checkpoint_lifetime: Duration::from_secs(10 * 60),
max_memtable_bytes: 64 * 1024 * 1024,
block_cache: default_block_cache(),
}criccomini
07/16/2025, 6:23 PMbrainhart.dev
07/16/2025, 6:24 PMdiff --git a/slatedb/src/db_reader.rs b/slatedb/src/db_reader.rs
index 420c483..d004714 100644
--- a/slatedb/src/db_reader.rs
+++ b/slatedb/src/db_reader.rs
@@ -440,14 +440,14 @@ impl DbReaderInner {
replay_new_wals: bool,
) -> Result<(u64, u64), SlateDBError> {
let sst_iter_options = SstIteratorOptions {
- max_fetch_tasks: 1,
- blocks_to_fetch: 256,
+ max_fetch_tasks: 1000,
+ blocks_to_fetch: 25600,
cache_blocks: true,
eager_spawn: true,
};
let replay_options = WalReplayOptions {
- sst_batch_size: 4,
+ sst_batch_size: 640,
max_memtable_bytes: reader_options.max_memtable_bytes as usize,
min_memtable_bytes: usize::MAX,
sst_iter_options,brainhart.dev
07/16/2025, 6:24 PMcriccomini
07/16/2025, 6:25 PMbrainhart.dev
07/16/2025, 6:25 PMcriccomini
07/16/2025, 6:25 PMcriccomini
07/16/2025, 6:26 PMbrainhart.dev
07/16/2025, 6:26 PMbrainhart.dev
07/16/2025, 6:27 PMcriccomini
07/16/2025, 6:28 PMcriccomini
07/16/2025, 6:28 PMbrainhart.dev
07/16/2025, 6:29 PMbrainhart.dev
07/16/2025, 6:29 PMcriccomini
07/16/2025, 6:29 PMcriccomini
07/16/2025, 6:29 PMcriccomini
07/16/2025, 6:29 PMbrainhart.dev
07/16/2025, 6:29 PMcriccomini
07/16/2025, 6:30 PMcriccomini
07/16/2025, 6:30 PMcriccomini
07/16/2025, 6:30 PMbrainhart.dev
07/16/2025, 6:31 PMcriccomini
07/16/2025, 6:31 PMcriccomini
07/16/2025, 6:32 PMcriccomini
07/16/2025, 6:32 PMcriccomini
07/16/2025, 6:32 PMcriccomini
07/16/2025, 6:33 PMcriccomini
07/16/2025, 6:33 PMcriccomini
07/16/2025, 6:33 PMbrainhart.dev
07/16/2025, 6:34 PMbrainhart.dev
07/16/2025, 6:35 PMcriccomini
07/16/2025, 6:36 PMcriccomini
07/16/2025, 6:36 PMcriccomini
07/16/2025, 6:36 PMbrainhart.dev
07/16/2025, 6:37 PMcriccomini
07/16/2025, 6:37 PMcriccomini
07/16/2025, 6:37 PMcriccomini
07/16/2025, 6:37 PMbrainhart.dev
07/16/2025, 6:38 PMcriccomini
07/16/2025, 6:38 PMcriccomini
07/16/2025, 6:38 PMcriccomini
07/16/2025, 6:38 PMbrainhart.dev
07/16/2025, 6:39 PMbrainhart.dev
07/16/2025, 6:39 PMcriccomini
07/16/2025, 6:41 PMcriccomini
07/16/2025, 6:41 PMbrainhart.dev
07/17/2025, 6:10 PMbrainhart.dev
07/17/2025, 6:13 PMcriccomini
07/17/2025, 6:21 PMrust
/// represent the in-memory state of the manifest
#[derive(Clone, PartialEq, Serialize, Debug)]
pub(crate) struct CoreDbState {
// ...
pub(crate) l0: VecDeque<SsTableHandle>, // <-- here
pub(crate) compacted: Vec<SortedRun>, // <-- and here
// ...
}
This in-memory lookup determins which SSTs to scan for they key's value baserd on the SST's first/last key. Then it instantiates a bunch of merge iterators for all SSTs in the search set and begins scanning them for the key's value. The merge iterators eventually boil down to SstIterators, which fetch 4kib blocks from 1) it's in-memory cache, 2) the table store. The table store, will in turn attempt to read from the 2.1) object storee cache (4mib object store blocks), then 2.2) s3 itself.criccomini
07/17/2025, 6:22 PMbrainhart.dev
07/17/2025, 10:57 PMblocks_to_fetch of blocks for the range (i.e. the 256 default), which means it'll scan 256 * 4KiB from s3 at a time).brainhart.dev
07/17/2025, 11:03 PMbrainhart.dev
07/17/2025, 11:18 PM[5555*, 8888), is there anything that will optimally scan the key range and reduce s3 calls?
(EDIT: I think I see this SsTableIndex and BlockMeta !)criccomini
07/17/2025, 11:19 PMcriccomini
07/17/2025, 11:25 PMSsTableIndex is tha ctual index. But there's other metadata available as well.brainhart.dev
07/17/2025, 11:30 PMcriccomini
07/17/2025, 11:33 PMcriccomini
07/17/2025, 11:37 PMSizeTieredCompactorScheduler probably won't come up with a schedule that completely compacts things down to one level, but it should improve reads. If you wanted a single fully sorted level, you'd need to probably plug your own compactor scheduler in, which can be done.)brainhart.dev
07/18/2025, 1:13 AMdb.compact(), is there anything we can do to trigger the wal->l0 compaction? Or is the only option right now to disable wal, and handle flush ourselves?brainhart.dev
07/18/2025, 1:14 AMcriccomini
07/18/2025, 1:14 AMcriccomini
07/18/2025, 1:15 AMcriccomini
07/18/2025, 1:18 AMrust
// Flush WAL
db.flush_with_options(FlushOptions::Wal)
// Flush all in-memory memtables up to the max param
db.flush_with_options(FlushOptions::Memtables(1))
// Flush WAL and in-memory memtables (example shows a max of oldest 5 memtables getting flushed)
db.flush_with_options(FlushOptions::WalAndMemtables(5))brainhart.dev
07/18/2025, 1:18 AMbrainhart.dev
07/18/2025, 1:21 AMcriccomini
07/18/2025, 1:22 AMcriccomini
07/18/2025, 1:22 AMcriccomini
07/18/2025, 1:23 AMbrainhart.dev
07/18/2025, 1:30 AM[
7337,
{
"external_dbs": [],
"core": {
"initialized": true,
"l0_last_compacted": null,
"l0": [
{
"id": {
"Compacted": "01K08XR9A3QX8VMARTEW7PR26C"
},
"info": {
"first_key": [
99,
....
,
"end": "Unbounded"
}
}
],
"compacted": [],
"next_wal_sst_id": 361,
"replay_after_wal_id": 359,
"last_l0_clock_tick": 1752646296899,
"last_l0_seq": 358,
"checkpoints": [
{
"id": "ceb86001-cb0a-4251-83be-1c756033b73d",
"manifest_id": 9,
"expire_time": {
"secs_since_epoch": 1752720350,
"nanos_since_epoch": 0
},
"create_time": {
"secs_since_epoch": 1752646447,
"nanos_since_epoch": 0
}
},
...
{
"id": "9b1fe4eb-18c5-437c-addd-685a02d50e38",
"manifest_id": 175,
"expire_time": {
"secs_since_epoch": 1752648737,
"nanos_since_epoch": 0
},
"create_time": {
"secs_since_epoch": 1752648137,
"nanos_since_epoch": 0
}
}
],
"wal_object_store_uri": null
},
"writer_epoch": 5,
"compactor_epoch": 5
}
]brainhart.dev
07/18/2025, 1:30 AMcriccomini
07/18/2025, 1:30 AMbrainhart.dev
07/18/2025, 1:30 AMcriccomini
07/18/2025, 1:30 AMcriccomini
07/18/2025, 1:31 AMcriccomini
07/18/2025, 1:31 AMbrainhart.dev
07/18/2025, 1:31 AMcriccomini
07/18/2025, 1:31 AMcriccomini
07/18/2025, 1:31 AMcriccomini
07/18/2025, 1:34 AMlet sst_iter_options = SstIteratorOptions {
max_fetch_tasks: 1,
blocks_to_fetch: 256,
cache_blocks: false,
eager_spawn: true,
};
let replay_options = WalReplayOptions {
sst_batch_size: 4,
min_memtable_bytes: self.settings.l0_sst_size_bytes,
max_memtable_bytes: usize::MAX,
sst_iter_options,
};criccomini
07/18/2025, 1:34 AMbrainhart.dev
07/18/2025, 1:36 AMflush_with_options to be able to manually trigger the flush on job completion, that probably is killercriccomini
07/18/2025, 1:36 AMbrainhart.dev
07/18/2025, 1:37 AMcriccomini
07/18/2025, 1:37 AMbrainhart.dev
07/18/2025, 1:37 AMcriccomini
07/18/2025, 1:37 AMcriccomini
07/18/2025, 1:38 AMbrainhart.dev
07/18/2025, 1:39 AMbrainhart.dev
07/18/2025, 1:41 AMscanbrainhart.dev
07/18/2025, 1:45 AMcriccomini
07/18/2025, 2:45 AMbrainhart.dev
07/18/2025, 2:46 AMcriccomini
07/18/2025, 3:01 AMbrainhart.dev
07/18/2025, 3:05 AMbrainhart.dev
07/18/2025, 3:07 AMbrainhart.dev
07/18/2025, 3:10 AMcriccomini
07/18/2025, 3:13 AMbrainhart.dev
07/18/2025, 3:13 AMcriccomini
07/18/2025, 3:13 AMbrainhart.dev
07/18/2025, 3:14 AMcriccomini
07/18/2025, 3:14 AMbrainhart.dev
07/18/2025, 3:15 AMcriccomini
07/18/2025, 3:15 AMbrainhart.dev
07/18/2025, 3:15 AMcriccomini
07/18/2025, 3:16 AMcriccomini
07/18/2025, 3:16 AMbrainhart.dev
07/18/2025, 3:18 AMcriccomini
07/18/2025, 3:19 AMbrainhart.dev
07/18/2025, 3:25 AMcriccomini
07/18/2025, 3:28 AMcriccomini
07/18/2025, 3:30 AMcriccomini
07/18/2025, 3:49 AMcriccomini
07/18/2025, 3:50 AMcriccomini
07/18/2025, 3:52 AMflush_with_opts so you can flush the memtables every so often.
I'm going to open a GH issue for this. It should be a pretty straightforward fixcriccomini
07/18/2025, 3:54 AMcriccomini
07/18/2025, 3:55 AMbrainhart.dev
07/18/2025, 4:21 AMbrainhart.dev
07/18/2025, 4:26 AMflaneur233
07/18/2025, 5:03 AMcriccomini
07/18/2025, 4:34 PMcriccomini
07/18/2025, 4:39 PMsst_batch_size in db::replay_wal` way up (like.. 1024), what does startup time look like?criccomini
07/18/2025, 4:42 PMcriccomini
07/18/2025, 4:48 PMbrainhart.dev
07/18/2025, 7:49 PMbrainhart.dev
07/18/2025, 7:56 PMbrainhart.dev
07/18/2025, 8:00 PMflush_with_opts approach would be if we can basically maintain the WAL, but then trigger a memtable flush on job completion. But being able to db.compact() would be preferred ofc, just that flush_with_opts might be 'close enough' for uscriccomini
07/27/2025, 5:02 PMbrainhart.dev
07/28/2025, 6:04 AMcriccomini
07/28/2025, 2:20 PM