From 595016f2b6b730120cac8dee3da7608d865dfe22 Mon Sep 17 00:00:00 2001 From: Alex Chi Date: Thu, 25 Jan 2024 23:45:00 +0800 Subject: [PATCH] ensure compaction can finish in mvcc Signed-off-by: Alex Chi --- README.md | 12 ++++++------ mini-lsm-mvcc/src/compact.rs | 2 +- mini-lsm/src/tests/harness.rs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 37d4d143..1813aa05 100644 --- a/README.md +++ b/README.md @@ -58,16 +58,16 @@ We are working on chapter 3 and more test cases for all existing contents. * Week 3: Multi-Version Concurrency Control * The Extra Week / Rest of Your Life: Optimizations (unlikely to be available in 2024...) -✅: finished \ +✅: Finished \ 🚧: WIP and will likely be available soon | Week + Chapter | Topic | Solution | Starter Code | Writeup | | -------------- | ----------------------------------------------- | -------- | ------------ | ------- | -| 2.7 | Batch Write + Checksum | 🚧 | 🚧 | | -| 3.1 | Timestamp Key Encoding | 🚧 | | | -| 3.2 | Snapshot Read - Blocks, Memtables, and SSTs | | | | -| 3.3 | Snapshot Read - Engine Read Path | | | | -| 3.4 | Watermark and Garbage Collection | | | | +| 2.7 | Batch Write + Checksum | ✅ | ✅ | | +| 3.1 | Timestamp Key Encoding | ✅ | 🚧 | | +| 3.2 | Snapshot Read - Blocks, Memtables, and SSTs | ✅ | 🚧 | | +| 3.3 | Snapshot Read - Engine Read Path | 🚧 | 🚧 | | +| 3.4 | Watermark and Garbage Collection | 🚧 | 🚧 | | | 3.5 | Transactions and Optimistic Concurrency Control | | | | | 3.6 | Serializable Snapshot Isolation | | | | | 3.7 | TTL (Time-to-Live) Entries | | | | diff --git a/mini-lsm-mvcc/src/compact.rs b/mini-lsm-mvcc/src/compact.rs index 9140f9e1..83ddeea1 100644 --- a/mini-lsm-mvcc/src/compact.rs +++ b/mini-lsm-mvcc/src/compact.rs @@ -307,7 +307,6 @@ impl LsmStorageInner { } fn trigger_compaction(&self) -> Result<()> { - self.dump_structure(); let snapshot = { let state = self.state.read(); state.clone() @@ -318,6 +317,7 @@ impl LsmStorageInner { let Some(task) = task else { return Ok(()); }; + self.dump_structure(); println!("running compaction task: {:?}", task); let sstables = self.compact(&task)?; let output = sstables.iter().map(|x| x.sst_id()).collect::>(); diff --git a/mini-lsm/src/tests/harness.rs b/mini-lsm/src/tests/harness.rs index 39866515..822f0756 100644 --- a/mini-lsm/src/tests/harness.rs +++ b/mini-lsm/src/tests/harness.rs @@ -173,7 +173,7 @@ pub fn compaction_bench(storage: Arc) { let mut max_key = 0; for iter in 0..10 { let range_begin = iter * 5000; - for i in range_begin..(range_begin + 40000) { + for i in range_begin..(range_begin + 10000) { // 120B per key, 4MB data populated let key = gen_key(i); let version = key_map.get(&i).copied().unwrap_or_default() + 1;