penberg / ycsb-rs

A Rust port of Yahoo! Cloud Serving Benchmark (YCSB)
Apache License 2.0
27 stars 13 forks source link

RFC: async interface for DB trait #3

Open skyzh opened 2 years ago

skyzh commented 2 years ago

Currently, the DB trait is defined as follows:

pub trait DB {
    fn init(&mut self) -> Result<()>;
    fn insert(&self, table: &str, key: &str, values: &HashMap<&str, String>) -> Result<()>;
    fn read(&self, table: &str, key: &str) -> Result<()>;
}

However, for those storage engines in the Rust world, most of them support async I/O, which might boost performance. Therefore, I propose adding a new async DB trait:

#[async_trait]
pub trait AsyncDB {
    fn init(&mut self) -> Result<()>;
    async fn insert(&self, table: &str, key: &str, values: &HashMap<&str, String>) -> Result<()>;
    async fn read(&self, table: &str, key: &str) -> Result<()>;
}

And add new workloads to bench these DBs.

It seems that our DB interface only have very few trait methods, therefore I think we can have a lot of time to discuss the async interface before actually working on that.

penberg commented 2 years ago

Yeah, makes perfect sense!

penberg commented 2 years ago

@skyzh I started a draft pull request to do this: https://github.com/penberg/ycsb-rs/pull/5