mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-03 01:25:37 +00:00
bench: add configurable pipeline depth via HOTPATH_PIPELINE env
FuturesUnordered-based pipeline to overlap encrypt with mpsc_send. Tested depths 1/4/8/16: max +1.6% at depth=4, within noise. Pipeline has limited value because try_send fast path eliminates await gaps that would allow overlap. Default remains depth=1 (serial).
This commit is contained in:
@@ -85,12 +85,29 @@ async fn main() {
|
|||||||
let pm = inst_a.get_peer_manager();
|
let pm = inst_a.get_peer_manager();
|
||||||
let send_pkt = make_data_packet(src, "10.144.144.2", pkt_size);
|
let send_pkt = make_data_packet(src, "10.144.144.2", pkt_size);
|
||||||
|
|
||||||
|
let pipeline_depth: usize = std::env::var("HOTPATH_PIPELINE")
|
||||||
|
.ok()
|
||||||
|
.and_then(|s| s.parse().ok())
|
||||||
|
.unwrap_or(1);
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"cpu_hotspot_ring: pipeline_depth={}",
|
||||||
|
pipeline_depth
|
||||||
|
);
|
||||||
|
|
||||||
let sender_task = tokio::spawn(async move {
|
let sender_task = tokio::spawn(async move {
|
||||||
|
use futures::stream::{FuturesUnordered, StreamExt};
|
||||||
|
|
||||||
let mut sent: u64 = 0;
|
let mut sent: u64 = 0;
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
let mut in_flight = FuturesUnordered::new();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let pkt = send_pkt.clone();
|
while in_flight.len() < pipeline_depth {
|
||||||
let _ = pm.send_msg_by_ip(pkt, dst, false).await;
|
let pkt = send_pkt.clone();
|
||||||
|
in_flight.push(pm.send_msg_by_ip(pkt, dst, false));
|
||||||
|
}
|
||||||
|
in_flight.next().await;
|
||||||
sent += 1;
|
sent += 1;
|
||||||
if sent % 10000 == 0 {
|
if sent % 10000 == 0 {
|
||||||
let elapsed = start.elapsed().as_secs_f64();
|
let elapsed = start.elapsed().as_secs_f64();
|
||||||
|
|||||||
Reference in New Issue
Block a user