Skip to content

Commit

Permalink
explicitly set cache sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 authored Nov 20, 2024
1 parent b879f35 commit d547519
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions benches/lmdb_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const KEY_SIZE: usize = 24;
const VALUE_SIZE: usize = 150;
const RNG_SEED: u64 = 3;

const CACHE_SIZE: usize = 4 * 1_024 * 1_024 * 1_024;

fn fill_slice(slice: &mut [u8], rng: &mut fastrand::Rng) {
let mut i = 0;
while i + size_of::<u128>() < slice.len() {
Expand Down Expand Up @@ -331,7 +333,7 @@ fn main() {
let redb_latency_results = {
let tmpfile: NamedTempFile = NamedTempFile::new_in(&tmpdir).unwrap();
let mut db = redb::Database::builder()
.set_cache_size(4 * 1024 * 1024 * 1024)
.set_cache_size(CACHE_SIZE)
.create(tmpfile.path())
.unwrap();
let table = RedbBenchDatabase::new(&db);
Expand Down Expand Up @@ -375,7 +377,7 @@ fn main() {
let tmpfile: TempDir = tempfile::tempdir_in(&tmpdir).unwrap();

let mut bb = rocksdb::BlockBasedOptions::default();
bb.set_block_cache(&rocksdb::Cache::new_lru_cache(4 * 1_024 * 1_024 * 1_024));
bb.set_block_cache(&rocksdb::Cache::new_lru_cache(CACHE_SIZE as u64));

let mut opts = rocksdb::Options::default();
opts.set_block_based_table_factory(&bb);
Expand All @@ -395,7 +397,13 @@ fn main() {

let sled_results = {
let tmpfile: TempDir = tempfile::tempdir_in(&tmpdir).unwrap();
let db = sled::Config::new().path(tmpfile.path()).open().unwrap();

let db = sled::Config::new()
.path(tmpfile.path())
.cache_capacity(CACHE_SIZE as u64)
.open()
.unwrap();

let table = SledBenchDatabase::new(&db, tmpfile.path());
let mut results = benchmark(table);
results.push(("compaction".to_string(), ResultType::NA));
Expand Down

0 comments on commit d547519

Please sign in to comment.