Skip to content

Commit

Permalink
chore: fix benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Oct 31, 2024
1 parent 7f73d70 commit 054296b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions benches/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use tokio::fs::create_dir_all;
use tonbo::{
executor::tokio::TokioExecutor, stream, transaction::TransactionEntry, DbOption, Projection,
};
use tonbo_ext_reader::foyer_reader::FoyerReader;
use tonbo_macros::Record;

const RNG_SEED: u64 = 3;
Expand Down Expand Up @@ -185,12 +186,12 @@ pub trait BenchReader {
}

pub struct TonboBenchDataBase {
db: tonbo::DB<Customer, TokioExecutor>,
db: tonbo::DB<Customer, TokioExecutor, FoyerReader>,
}

impl TonboBenchDataBase {
#[allow(dead_code)]
pub fn new(db: tonbo::DB<Customer, TokioExecutor>) -> Self {
pub fn new(db: tonbo::DB<Customer, TokioExecutor, FoyerReader>) -> Self {
TonboBenchDataBase { db }
}
}
Expand Down Expand Up @@ -234,7 +235,7 @@ impl BenchDatabase for TonboBenchDataBase {
}

pub struct TonboBenchReadTransaction<'a> {
txn: tonbo::transaction::Transaction<'a, Customer>,
txn: tonbo::transaction::Transaction<'a, Customer, FoyerReader>,
}

impl<'db> BenchReadTransaction for TonboBenchReadTransaction<'db> {
Expand All @@ -249,7 +250,7 @@ impl<'db> BenchReadTransaction for TonboBenchReadTransaction<'db> {
}

pub struct TonboBenchReader<'db, 'txn> {
txn: &'txn tonbo::transaction::Transaction<'db, Customer>,
txn: &'txn tonbo::transaction::Transaction<'db, Customer, FoyerReader>,
}

impl BenchReader for TonboBenchReader<'_, '_> {
Expand Down Expand Up @@ -289,7 +290,7 @@ impl BenchReader for TonboBenchReader<'_, '_> {
}

pub struct TonboBenchWriteTransaction<'a> {
txn: tonbo::transaction::Transaction<'a, Customer>,
txn: tonbo::transaction::Transaction<'a, Customer, FoyerReader>,
}

impl<'db> BenchWriteTransaction for TonboBenchWriteTransaction<'db> {
Expand All @@ -309,7 +310,7 @@ impl<'db> BenchWriteTransaction for TonboBenchWriteTransaction<'db> {
}

pub struct TonboBenchInserter<'db, 'txn> {
txn: &'txn mut tonbo::transaction::Transaction<'db, Customer>,
txn: &'txn mut tonbo::transaction::Transaction<'db, Customer, FoyerReader>,
}

impl BenchInserter for TonboBenchInserter<'_, '_> {
Expand Down
3 changes: 2 additions & 1 deletion benches/criterion/writes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{iter::repeat_with, sync::Arc};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use mimalloc::MiMalloc;
use tonbo::{executor::tokio::TokioExecutor, DbOption, Record, DB};
use tonbo_ext_reader::foyer_reader::FoyerReader;

#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
Expand All @@ -15,7 +16,7 @@ pub struct KV {
}

#[inline(never)]
async fn tonbo_write(db: &DB<KV, TokioExecutor>, batch_size: usize) {
async fn tonbo_write(db: &DB<KV, TokioExecutor, FoyerReader>, batch_size: usize) {
let mut kvs = Vec::with_capacity(128);
for _ in 0..batch_size {
let key = repeat_with(fastrand::alphanumeric).take(256).collect();
Expand Down

0 comments on commit 054296b

Please sign in to comment.