Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

explicitly set cache sizes #901

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));

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