From db4cc92eb3bf820586b3ab7e55780b74f8e5ceb4 Mon Sep 17 00:00:00 2001 From: George Hahn Date: Wed, 11 Sep 2024 00:45:55 -0500 Subject: [PATCH] Don't start warmup period until target is running --- CHANGELOG.md | 6 ++++-- lading/src/bin/lading.rs | 30 ++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2809b1082..8a28010a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased - -### +### Changed - Now built using rust 1.81.0. +### Fixed +- Warmup period is now respected when container targeting is in use. + ## [0.23.1] ### Fixed - Fixes a panic in the signal mechanism that appeared when using the file diff --git a/lading/src/bin/lading.rs b/lading/src/bin/lading.rs index b936f6ffb..af4169258 100644 --- a/lading/src/bin/lading.rs +++ b/lading/src/bin/lading.rs @@ -29,7 +29,7 @@ use tokio::{ sync::broadcast, time::{self, sleep, Duration}, }; -use tracing::{debug, error, info, warn}; +use tracing::{debug, error, info, info_span, warn, Instrument}; use tracing_subscriber::{fmt::format::FmtSpan, util::SubscriberInitExt, EnvFilter}; #[derive(thiserror::Error, Debug)] @@ -474,6 +474,8 @@ async fn inner_main( } } + let mut sequence_tgt_recv = tgt_snd.subscribe(); + let mut tsrv_joinset = tokio::task::JoinSet::new(); let mut osrv_joinset = tokio::task::JoinSet::new(); // @@ -496,15 +498,23 @@ async fn inner_main( }; let (timer_watcher, timer_broadcast) = lading_signal::signal(); - tokio::spawn(async move { - info!("target is running, now sleeping for warmup"); - sleep(warmup_duration).await; - experiment_started_broadcast.signal(); - info!("warmup completed, collecting samples"); - sleep(experiment_duration).await; - info!("experiment duration exceeded, signaling for shutdown"); - timer_broadcast.signal(); - }); + + tokio::spawn( + async move { + info!("waiting for target startup"); + if let Err(e) = sequence_tgt_recv.recv().await { + warn!("failed to wait: {:?}", e); + } + info!("target is running, now sleeping for warmup"); + sleep(warmup_duration).await; + experiment_started_broadcast.signal(); + info!("warmup completed, collecting samples"); + sleep(experiment_duration).await; + info!("experiment duration exceeded, signaling for shutdown"); + timer_broadcast.signal(); + } + .instrument(info_span!("experiment_sequence")), + ); // We must be sure to drop any unused watcher at this point. Below in // `signal_and_wait` if a watcher remains derived from `shutdown_watcher` the run will not shut down.