Skip to content

Commit

Permalink
Latency benchmark first draft (MystenLabs#1141)
Browse files Browse the repository at this point in the history
* Latency benchmark first draft
  • Loading branch information
oxade authored Mar 30, 2022
1 parent 6a5dc05 commit 3c7ef0f
Show file tree
Hide file tree
Showing 4 changed files with 606 additions and 3 deletions.
4 changes: 2 additions & 2 deletions network_utils/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ impl NetworkClient {
let client = self.clone();
handles.push(
tokio::spawn(async move {
info!(
debug!(
"Sending TCP requests to {}:{}",
client.base_address, client.base_port,
);
let responses = client.batch_send_one_chunk(requests, max_in_flight).await;
// .unwrap_or_else(|_| Vec::new());
info!(
debug!(
"Done sending TCP requests to {}:{}",
client.base_address, client.base_port,
);
Expand Down
41 changes: 41 additions & 0 deletions scripts/bench_sweep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from time import sleep
import matplotlib.pyplot as plt
import subprocess
import ast
from string import Template

cmd_template = Template(
"../target/release/microbench_latency --period-us $period_us --chunk-size $chunk_size --num-chunks $num_chunks")

def get_avg_latency(period_us, chunk_size, num_chunks):
cmd = cmd_template.substitute(
period_us=period_us, chunk_size=chunk_size, num_chunks=num_chunks)
print(cmd)
process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
output, error = process.communicate()

resp = output.decode("utf-8")
res = ast.literal_eval(resp)
print(res)
# Pick upper half at steady state
res = res[len(res)//2:]
return sum(res)/len(res)


def plot(vals):
plt.title("Latency vs Throughput")
plt.scatter(*zip(*vals))
plt.ylabel("Latency (ms)")
plt.xlabel("Throughput")
plt.show()

lats = []
for i in range(10):
chunk_size = 200 * (i+1)
period_us = 10000
num_chunks = 10
thr = chunk_size*1000*1000/period_us
avg_lat_ms = get_avg_latency(period_us, chunk_size, num_chunks)/1000
lats.append((thr, avg_lat_ms))
sleep(1)
plot(lats)
6 changes: 5 additions & 1 deletion sui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ serde = { version = "1.0.136", features = ["derive"] }
serde_json = "1.0.79"
structopt = "0.3.26"
tempfile = "3.3.0"
tokio = { version = "1.17.0", features = ["full", "tracing"] }
tokio = { version = "1.17.0", features = ["full"] }
rand = "0.8.4"
toml = "0.5.8"
strum = "0.24.0"
Expand Down Expand Up @@ -68,6 +68,10 @@ tracing-test = "0.2.1"
name = "microbench"
path = "src/microbench.rs"

[[bin]]
name = "microbench_latency"
path = "src/microbench_latency.rs"

[[bin]]
name = "wallet"
path = "src/wallet.rs"
Expand Down
Loading

0 comments on commit 3c7ef0f

Please sign in to comment.