Skip to content

Commit

Permalink
benchmarks: apply formatter
Browse files Browse the repository at this point in the history
Signed-off-by: Reto Achermann <[email protected]>
  • Loading branch information
achreto committed Aug 19, 2024
1 parent 9edf2d1 commit f8487d5
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 325 deletions.
50 changes: 31 additions & 19 deletions benchmarks/ironsync/benches/ironsync_counter/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

//! Defines a hash-map that can be replicated.

use env_logger::Logger;
use std::env;
use std::fs::{remove_file, OpenOptions};
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::process::Command;
use std::io::{self, Write};
use env_logger::Logger;

fn obtain_dotnet(ironsync_dir: &Path) -> PathBuf {

// TODO: add an exist check!

let dotnet_dir = ironsync_dir.join(".dotnet");
Expand All @@ -26,7 +25,11 @@ fn obtain_dotnet(ironsync_dir: &Path) -> PathBuf {

let output = Command::new("wget")
.current_dir(ironsync_dir)
.args(&["https://dot.net/v1/dotnet-install.sh", "-O", "dotnet-install.sh"])
.args(&[
"https://dot.net/v1/dotnet-install.sh",
"-O",
"dotnet-install.sh",
])
.output()
.expect("failed to downlaod the dotnet install script");

Expand All @@ -39,7 +42,13 @@ fn obtain_dotnet(ironsync_dir: &Path) -> PathBuf {

let output = Command::new("bash")
.current_dir(ironsync_dir)
.args(&["dotnet-install.sh", "--channel", "5.0" , "--install-dir", ".dotnet"])
.args(&[
"dotnet-install.sh",
"--channel",
"5.0",
"--install-dir",
".dotnet",
])
.output()
.expect("failed to downlaod the dotnet install script");

Expand All @@ -56,11 +65,16 @@ fn obtain_dotnet(ironsync_dir: &Path) -> PathBuf {
}

fn run_linear_dafny() -> PathBuf {

let this_file = file!();
let this_file_path = Path::new(this_file).canonicalize().unwrap();

let benchmarks_dir = this_file_path.parent().unwrap().parent().unwrap().parent().unwrap();
let benchmarks_dir = this_file_path
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap();

// let cwd = std::env::current_dir().unwrap();
// let benchmarks_dir = cwd.parent().unwrap();
Expand All @@ -72,7 +86,7 @@ fn run_linear_dafny() -> PathBuf {

let build_script = ironsync_dir.join("run-dafny-in-docker.sh");
if !build_script.is_file() {
let output = Command::new("git")
let output = Command::new("git")
.args(&["submodule", "update", "--init"])
.output()
.expect("failed to execute process");
Expand Down Expand Up @@ -118,8 +132,7 @@ fn run_linear_dafny() -> PathBuf {

if !output.status.success() {
if dafny_path.exists() {
std::fs::remove_dir_all(dafny_path)
.expect("[dafny] failed to remove .dafny directory");
std::fs::remove_dir_all(dafny_path).expect("[dafny] failed to remove .dafny directory");
}

println!("[dafny] Building LinearDafny...");
Expand All @@ -129,10 +142,10 @@ fn run_linear_dafny() -> PathBuf {
.output()
.expect("[dafny] failed to run `artifact-setup-dafny.sh` command");
if !output.status.success() {
println!("status: {}", output.status);
io::stdout().write_all(&output.stdout).unwrap();
io::stderr().write_all(&output.stderr).unwrap();
panic!("[dafny] Dafny Build has failed");
println!("status: {}", output.status);
io::stdout().write_all(&output.stdout).unwrap();
io::stderr().write_all(&output.stderr).unwrap();
panic!("[dafny] Dafny Build has failed");
}

println!("[dafny] Dafny version ok.");
Expand All @@ -158,10 +171,11 @@ fn run_linear_dafny() -> PathBuf {
println!("[dafny] building nr binaries");
let nr_dir = ironsync_dir.join("concurrency/node-replication");

let filtered_env : std::collections::HashMap<String, String> =
env::vars().filter(|&(ref k, _)|
let filtered_env: std::collections::HashMap<String, String> = env::vars()
.filter(|&(ref k, _)| {
!k.starts_with("CARGO") && k != "RUSTUP_TOOLCHAIN" && k != "RUST_RECURSION_COUNT"
).collect();
})
.collect();

let output = Command::new("./compile-bench.sh")
.env_clear()
Expand All @@ -181,7 +195,6 @@ fn run_linear_dafny() -> PathBuf {
nr_dir
}


fn run_bench(nr_dir: PathBuf) {
println!("[run] running benchmark");
let output = Command::new("./bench.py")
Expand Down Expand Up @@ -212,7 +225,6 @@ pub fn disable_dvfs() {
assert!(o.status.success());
}


fn main() {
let _r = env_logger::try_init();

Expand Down
18 changes: 6 additions & 12 deletions benchmarks/upstream/benches/nr_counter/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ use std::marker::Sync;
use std::time::Duration;

use logging::warn;
use rand::seq::SliceRandom;
use rand::prelude::*;
use rand::seq::SliceRandom;
use rand_chacha::ChaCha8Rng;

use bench_utils::benchmark::*;
use bench_utils::mkbench::{self, DsInterface, NodeReplicated};
use bench_utils::topology::ThreadMapping;
use bench_utils::Operation;
use node_replication::{Dispatch};

use node_replication::Dispatch;

/// The initial amount of entries all Hashmaps are initialized with
#[cfg(feature = "smokebench")]
Expand All @@ -45,7 +44,7 @@ pub const NOP: usize = 25_000_000;
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
pub enum OpWr {
/// Increment the Counter
Inc
Inc,
}

#[derive(Debug, Eq, PartialEq, Clone, Copy)]
Expand Down Expand Up @@ -93,9 +92,7 @@ impl Dispatch for NrCounter {
/// Implements how we execute operation from the log against our local stack
fn dispatch_mut(&mut self, op: Self::WriteOperation) -> Self::Response {
match op {
OpWr::Inc => {
Ok(self.inc())
}
OpWr::Inc => Ok(self.inc()),
}
}
}
Expand All @@ -107,10 +104,7 @@ impl Dispatch for NrCounter {
/// - `write`: true will Put, false will generate Get sequences
/// - `span`: Maximum key
/// - `distribution`: Supported distribution 'uniform' or 'skewed'
pub fn generate_operations(
nop: usize,
write_ratio: usize,
) -> Vec<Operation<OpRd, OpWr>> {
pub fn generate_operations(nop: usize, write_ratio: usize) -> Vec<Operation<OpRd, OpWr>> {
let mut ops = Vec::with_capacity(nop);

let mut rng = ChaCha8Rng::seed_from_u64(42);
Expand Down Expand Up @@ -192,4 +186,4 @@ fn main() {
for write_ratio in write_ratios.into_iter() {
counter_scale_out::<NodeReplicated<NrCounter>>(&mut harness, " nr-counter", write_ratio);
}
}
}
6 changes: 2 additions & 4 deletions benchmarks/upstream/benches/nr_hashmap/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ use bench_utils::benchmark::*;
use bench_utils::mkbench::{self, DsInterface, NodeReplicated};
use bench_utils::topology::ThreadMapping;
use bench_utils::Operation;
use node_replication::{Dispatch};

use node_replication::Dispatch;

/// The initial amount of entries all Hashmaps are initialized with
#[cfg(feature = "smokebench")]
Expand Down Expand Up @@ -57,7 +56,6 @@ pub enum OpRd {
Get(u64),
}


/// Single-threaded implementation of the stack
///
/// We just use a vector.
Expand Down Expand Up @@ -213,4 +211,4 @@ fn main() {
for write_ratio in write_ratios.into_iter() {
hashmap_scale_out::<NodeReplicated<NrHashMap>>(&mut harness, "hashmap", write_ratio);
}
}
}
Loading

0 comments on commit f8487d5

Please sign in to comment.