Skip to content

Commit

Permalink
Update stresstest example to help with debugging large DB size
Browse files Browse the repository at this point in the history
  • Loading branch information
dermesser committed Jul 15, 2023
1 parent e87f0c0 commit 913b60f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions examples/stresstest/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rand::distributions::{Alphanumeric, DistString};
use rusty_leveldb::{compressor, CompressorId, Options, DB};
use rusty_leveldb::{Options, DB};

const KEY_LEN: usize = 4;
const KEY_LEN: usize = 5;
const VAL_LEN: usize = 8;

fn gen_string(n: usize) -> String {
Expand All @@ -16,6 +16,10 @@ fn write(db: &mut DB, n: usize) {
let (k, v) = (gen_string(KEY_LEN), gen_string(VAL_LEN));

db.put(k.as_bytes(), v.as_bytes()).unwrap();
if i % (n/100) == 0 {
println!("{}/100 ...", i * 100 / n);
db.flush().unwrap();
}
}

{
Expand Down
2 changes: 2 additions & 0 deletions src/db_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ impl DB {
if self.imm.is_some() {
self.compact_memtable()?;
}
// Issue #34 PR #36: after compacting a memtable into an L0 file, it is possible that the
// L0 files need to be merged and promoted.
if self.vset.borrow().needs_compaction() {
let c = self.vset.borrow_mut().pick_compaction();
if let Some(c) = c {
Expand Down

0 comments on commit 913b60f

Please sign in to comment.