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

Add windows support for microbenchmark #2

Open
wants to merge 1 commit into
base: kv_dev
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions evaluation/benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ vstd = { git = "https://github.com/verus-lang/verus.git", rev="a53f39271666ac7dc
toml = { version = "0.8.19", features = ["parse"] }
serde = { version = "1.0.215", features = ["derive"] }
chrono = "0.4.38"
redis = "0.27.5"
rand = "0.8.5"
rocksdb = { path = "../rust-rocksdb/" }
num_cpus = "1.16.0"
num_cpus = "1.16.0"

[target.'cfg(target_os = "linux")'.dependencies]
redis = "0.27.5"
rocksdb = { path = "../rust-rocksdb/" }
15 changes: 7 additions & 8 deletions evaluation/benchmark/src/capybarakv_client.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
use storage_node::kv::kvimpl_t::*;
#[cfg(target_os = "linux")]
use storage_node::pmem::linux_pmemfile_t::*;
#[cfg(target_os = "windows")]
use storage_node::pmem::windows_pmemfile_t::*;
use crate::{Key, Value, KvInterface, init_and_mount_pm_fs, remount_pm_fs, unmount_pm_fs};
use storage_node::pmem::pmcopy_t::*;
use storage_node::pmem::traits_t::{ConstPmSized, PmSized, UnsafeSpecPmSized, PmSafe};
use pmsafe::PmCopy;
use crate::config::*;

use std::fmt::Debug;
use std::hash::Hash;
use std::thread::sleep;
use std::time::{Duration, Instant};

// TODO: read these from config file
const KVSTORE_ID: u128 = 1234;
const KVSTORE_FILE: &str = "/mnt/pmem/capybarakv";
const REGION_SIZE: u64 = 1024*1024*1024*115;

// TODO: should make a capybarakv util crate so that you
// can share some of these functions with ycsb_ffi?

Expand Down Expand Up @@ -109,7 +108,7 @@ fn open_pm_region(file_name: &str, region_size: u64) -> FileBackedPersistentMemo
#[cfg(target_os = "windows")]
let pm_region = FileBackedPersistentMemoryRegion::restore(
&file_name,
MemoryMappedFileMediaType::SSD,
MemoryMappedFileMediaType::BatteryBackedDRAM,
region_size,
).unwrap();
#[cfg(target_os = "linux")]
Expand All @@ -126,9 +125,9 @@ fn create_pm_region(file_name: &str, region_size: u64) -> FileBackedPersistentMe
{
#[cfg(target_os = "windows")]
let pm_region = FileBackedPersistentMemoryRegion::new(
&file_name, MemoryMappedFileMediaType::SSD,
&file_name, MemoryMappedFileMediaType::BatteryBackedDRAM,
region_size,
FileCloseBehavior::TestingSoDeleteOnClose
FileCloseBehavior::Persistent
).unwrap();
#[cfg(target_os = "linux")]
let pm_region = FileBackedPersistentMemoryRegion::new(
Expand Down
26 changes: 26 additions & 0 deletions evaluation/benchmark/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#[cfg(target_os = "linux")]
pub const PM_DEV: &str = "/dev/pmem0";
#[cfg(target_os = "linux")]
pub const MOUNT_POINT: &str = "/mnt/pmem";
#[cfg(target_os = "linux")]
pub const KVSTORE_FILE: &str = "/mnt/pmem/capybarakv";

#[cfg(target_os = "windows")]
pub const PM_DEV: &str = "C:\\pmem";
#[cfg(target_os = "windows")]
pub const MOUNT_POINT: &str = PM_DEV;
#[cfg(target_os = "windows")]
pub const KVSTORE_FILE: &str = "C:\\pmem\\capybarakv";

// TODO: read these from config file
pub const KVSTORE_ID: u128 = 1234;
pub const REGION_SIZE: u64 = 1024*1024*1024*15;

// TODO: read these from a config file?
pub const NUM_KEYS: u64 = 3125000;

// for use in the full startup experiment
// 1024*1024*1024*115 / (1024 + 1024*512 + 128) (approximately)
// 115GB CapybaraKV instances uses 100% of PM device
// the extra 128 bytes accounts for metadata and CRCs
pub const CAPYBARAKV_MAX_KEYS: u64 = 30000;
59 changes: 47 additions & 12 deletions evaluation/benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use builtin::*;
#[allow(unused_imports)]
use builtin_macros::*;

#[cfg(target_os = "linux")]
use redis::{FromRedisValue, RedisResult};

use std::fs;
Expand All @@ -22,15 +23,22 @@ use rand::thread_rng;
use rand::seq::SliceRandom;

use crate::kv_interface::*;
#[cfg(target_os = "linux")]
use crate::redis_client::*;
#[cfg(target_os = "linux")]
use crate::rocksdb_client::*;
use crate::capybarakv_client::*;

pub mod kv_interface;
#[cfg(target_os = "linux")]
pub mod redis_client;
#[cfg(target_os = "linux")]
pub mod rocksdb_client;
pub mod capybarakv_client;

use crate::config::*;
pub mod config;

// length of key and value in byte for most tests
const KEY_LEN: usize = 64;
const VALUE_LEN: usize = 1024;
Expand All @@ -40,18 +48,7 @@ const VALUE_LEN: usize = 1024;
const BIG_KEY_LEN: usize = 1024;
const BIG_VALUE_LEN: usize = 1024 * 512;

const PM_DEV: &str = "/dev/pmem0";
const MOUNT_POINT: &str = "/mnt/pmem";

// TODO: read these from a config file?
const NUM_KEYS: u64 = 25000000;
const ITERATIONS: u64 = 1;
// for use in the full startup experiment
// 1024*1024*1024*115 / (1024 + 1024*512 + 128) (approximately)
// 115GB CapybaraKV instances uses 100% of PM device
// the extra 128 bytes accounts for metadata and CRCs
const CAPYBARAKV_MAX_KEYS: u64 = 235000;


#[repr(C)]
#[derive(PmCopy, Copy, Hash, Debug)]
Expand Down Expand Up @@ -161,6 +158,7 @@ pub struct PlaceholderListElem {
_val: u64,
}

#[cfg(target_os = "linux")]
impl FromRedisValue for TestValue {
fn from_redis_value(v: &redis::Value) -> RedisResult<Self> {
use redis::Value::*;
Expand All @@ -187,6 +185,7 @@ impl FromRedisValue for TestValue {
}
}

#[cfg(target_os = "linux")]
impl FromRedisValue for BigTestValue {
fn from_redis_value(v: &redis::Value) -> RedisResult<Self> {
use redis::Value::*;
Expand Down Expand Up @@ -223,24 +222,36 @@ fn main() {
};

// create per-KV output directories
#[cfg(target_os = "linux")]
let redis_output_dir = output_dir.clone() + "/" + &RedisClient::<TestKey,TestValue>::db_name();
#[cfg(target_os = "linux")]
let rocksdb_output_dir = output_dir.clone() + "/" + &RocksDbClient::<TestKey,TestValue>::db_name();

let capybara_output_dir = output_dir.clone() + "/" + &CapybaraKvClient::<TestKey, TestValue, PlaceholderListElem>::db_name();

#[cfg(target_os = "linux")]
fs::create_dir_all(&redis_output_dir).unwrap();
#[cfg(target_os = "linux")]
fs::create_dir_all(&rocksdb_output_dir).unwrap();

fs::create_dir_all(&capybara_output_dir).unwrap();


for i in 1..ITERATIONS+1 {
#[cfg(target_os = "linux")]
run_experiments::<RedisClient<TestKey, TestValue>>(&redis_output_dir, i).unwrap();
#[cfg(target_os = "linux")]
run_experiments::<RocksDbClient<TestKey, TestValue>>(&rocksdb_output_dir, i).unwrap();

run_experiments::<CapybaraKvClient<TestKey, TestValue, PlaceholderListElem>>(&capybara_output_dir, i).unwrap();
}

// full setup works differently so that we don't have to rebuild the full KV every iteration
#[cfg(target_os = "linux")]
run_full_setup::<RedisClient<BigTestKey, BigTestValue>>(&redis_output_dir, NUM_KEYS).unwrap();
#[cfg(target_os = "linux")]
run_full_setup::<RocksDbClient<BigTestKey, BigTestValue>>(&rocksdb_output_dir, NUM_KEYS).unwrap();

run_full_setup::<CapybaraKvClient<BigTestKey, BigTestValue, PlaceholderListElem>>(&capybara_output_dir, CAPYBARAKV_MAX_KEYS).unwrap();
}

Expand Down Expand Up @@ -657,6 +668,7 @@ fn run_full_setup<KV>(output_dir: &str, num_keys: u64) -> Result<(), KV::E>
Ok(())
}

#[cfg(target_os = "linux")]
pub fn init_and_mount_pm_fs() {
println!("Mounting PM FS...");

Expand All @@ -682,6 +694,19 @@ pub fn init_and_mount_pm_fs() {
println!("Mounted");
}

#[cfg(target_os = "windows")]
pub fn init_and_mount_pm_fs() {

let output = Command::new("cmd")
.args(["/C", "del", "/Q", format!("{}\\capybarakv*", MOUNT_POINT).as_str()])
.status()
.expect("Failed to delete files under the mount point");
println!("[Windows] Deleted files under the mount point");

println!("[Windows] Mounting PM FS...");
}

#[cfg(target_os = "linux")]
pub fn remount_pm_fs() {
println!("Remounting existing FS...");

Expand All @@ -697,6 +722,17 @@ pub fn remount_pm_fs() {
println!("Mounted");
}

#[cfg(target_os = "windows")]
pub fn remount_pm_fs() {
println!("[Windows] Remounting existing FS...");
}

#[cfg(target_os = "windows")]
pub fn unmount_pm_fs() {
println!("[Windows] Unmounting PM FS...");
}

#[cfg(target_os = "linux")]
pub fn unmount_pm_fs() {
let status = Command::new("sudo")
.args(["umount", PM_DEV])
Expand All @@ -706,7 +742,6 @@ pub fn unmount_pm_fs() {
}
}


fn remove_file(name: &str) {
let _ = std::fs::remove_file(name);
}