Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
feat: add table result
Browse files Browse the repository at this point in the history
  • Loading branch information
unw9527 committed Apr 30, 2024
1 parent 089d3f4 commit 1f5602c
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark_group_1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: cmu-db/15721-s24-cache1
ref: yx/enable-sqlite
ref: lkl/benchmark
- name: Build Server
run: cargo build --package storage-node --bin storage_node
- name: Run Server
Expand Down
80 changes: 80 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ reqwest = { version = "0.11", features = ["stream", "json"] }
csv = "1.3.0"
istziio-client = "0.1.6"
parpulse-client = "0.1"
prettytable-rs = "0.10.0"
35 changes: 27 additions & 8 deletions src/benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use istziio_client::client_api::{StorageClient, StorageRequest};
use prettytable::{Cell, Row, Table};
use std::error::Error;
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use std::thread::sleep;
use std::time::Instant;
use std::time::{Duration, SystemTime};
Expand Down Expand Up @@ -40,7 +42,16 @@ pub async fn run_trace(
let start_time = SystemTime::now();
let request_num = traces.len();
let (tx, mut rx) = mpsc::channel(32);
let table = Arc::new(Mutex::new(Table::new()));
table.lock().unwrap().add_row(Row::new(vec![
Cell::new("Trace ID"),
Cell::new("File ID"),
Cell::new("Num Rows"),
Cell::new("Arrival Time"),
Cell::new("Wait Time"),
]));
for (i, trace) in traces.into_iter().enumerate() {
let table = Arc::clone(&table);
if let Some(diff) =
Duration::from_millis(trace.timestamp).checked_sub(start_time.elapsed().unwrap())
{
Expand All @@ -53,10 +64,10 @@ pub async fn run_trace(
StorageRequest::Table(id) => id,
_ => panic!("Invalid request type"),
};
println!(
"Trace {} sends request for table {} at timestamp {}",
i, table_id, trace.timestamp
);
// println!(
// "Trace {} sends request for table {} at timestamp {}",
// i, table_id, trace.timestamp
// );
let client_start = Instant::now();

let res = client.request_data(trace.request).await;
Expand All @@ -69,10 +80,17 @@ pub async fn run_trace(
total_num_rows += rb.num_rows();
}
let client_duration = client_start.elapsed();
println!(
"Trace {} gets {} rows from the client, latency is {:?}",
i, total_num_rows, client_duration
);
// println!(
// "Trace {} gets {} rows from the client, latency is {:?}",
// i, total_num_rows, client_duration
// );
table.lock().unwrap().add_row(Row::new(vec![
Cell::new(&i.to_string()),
Cell::new(&table_id.to_string()),
Cell::new(&total_num_rows.to_string()),
Cell::new(&trace.timestamp.to_string()),
Cell::new(&client_duration.as_millis().to_string()),
]));
tx.send(client_duration).await.unwrap();
});
}
Expand All @@ -85,5 +103,6 @@ pub async fn run_trace(
}

let avg_duration = duration_sum.div_f32(request_num as f32);
table.lock().unwrap().printstd();
println!("Average duration: {:?}", avg_duration);
}

0 comments on commit 1f5602c

Please sign in to comment.