diff options
| author | diogo464 <[email protected]> | 2025-07-11 20:14:42 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-07-11 20:14:42 +0100 |
| commit | f0f57060a54b5c57608f945fd8f66b030779fd31 (patch) | |
| tree | ad9f341e8a91057f1df9d00027812fee53de117a /src | |
| parent | 9c57f905f93e381cbb27147f2effc76e127cc646 (diff) | |
feat: add benchmark startup analysis tools and improve demo.sh
- Add generate-schedule.sh script to create container schedules from addresses.txt
- Add benchmark-startup Python script for analyzing container startup times
- Update demo.sh to print timestamps and wait for start signal at /oar-p2p/start
- Add comprehensive statistics including startup, start signal, and waiting times
- Support for synchronized container coordination via start signal file
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 06cf322..e2d356e 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -4,6 +4,7 @@ use std::{ | |||
| 4 | net::Ipv4Addr, | 4 | net::Ipv4Addr, |
| 5 | path::{Path, PathBuf}, | 5 | path::{Path, PathBuf}, |
| 6 | process::Output, | 6 | process::Output, |
| 7 | time::Duration, | ||
| 7 | }; | 8 | }; |
| 8 | 9 | ||
| 9 | use clap::{Args, Parser, Subcommand}; | 10 | use clap::{Args, Parser, Subcommand}; |
| @@ -108,6 +109,9 @@ struct RunArgs { | |||
| 108 | #[clap(long)] | 109 | #[clap(long)] |
| 109 | output_dir: PathBuf, | 110 | output_dir: PathBuf, |
| 110 | 111 | ||
| 112 | #[clap(long, default_value = "10")] | ||
| 113 | signal_delay: u64, | ||
| 114 | |||
| 111 | schedule: Option<PathBuf>, | 115 | schedule: Option<PathBuf>, |
| 112 | } | 116 | } |
| 113 | 117 | ||
| @@ -307,6 +311,17 @@ async fn cmd_run(args: RunArgs) -> Result<()> { | |||
| 307 | ) | 311 | ) |
| 308 | .await?; | 312 | .await?; |
| 309 | 313 | ||
| 314 | tracing::info!("waiting {} seconds before signaling", args.signal_delay); | ||
| 315 | tokio::time::sleep(Duration::from_secs(args.signal_delay)).await; | ||
| 316 | |||
| 317 | machine::for_each( | ||
| 318 | machines | ||
| 319 | .iter() | ||
| 320 | .filter(|&machine| containers.iter().any(|c| c.machine == *machine)), | ||
| 321 | |machine| machine_signal_containers(&ctx, machine), | ||
| 322 | ) | ||
| 323 | .await?; | ||
| 324 | |||
| 310 | tracing::info!("waiting for all containers to exit"); | 325 | tracing::info!("waiting for all containers to exit"); |
| 311 | machine::for_each(&machines, |machine| { | 326 | machine::for_each(&machines, |machine| { |
| 312 | let ctx = ctx.clone(); | 327 | let ctx = ctx.clone(); |
| @@ -350,10 +365,15 @@ async fn cmd_run(args: RunArgs) -> Result<()> { | |||
| 350 | fn machine_containers_create_script(containers: &[ScheduledContainer]) -> String { | 365 | fn machine_containers_create_script(containers: &[ScheduledContainer]) -> String { |
| 351 | let mut script = String::default(); | 366 | let mut script = String::default(); |
| 352 | for (idx, container) in containers.iter().enumerate() { | 367 | for (idx, container) in containers.iter().enumerate() { |
| 368 | // remove the start signal file if it exists | ||
| 369 | script.push_str("mkdir -p /tmp/oar-p2p-signal\n"); | ||
| 370 | script.push_str("rm /tmp/oar-p2p-signal/start 2>/dev/null || true\n"); | ||
| 371 | |||
| 353 | script.push_str("docker create \\\n"); | 372 | script.push_str("docker create \\\n"); |
| 354 | script.push_str("\t--pull=always \\\n"); | 373 | script.push_str("\t--pull=always \\\n"); |
| 355 | script.push_str("\t--network=host \\\n"); | 374 | script.push_str("\t--network=host \\\n"); |
| 356 | script.push_str("\t--restart=no \\\n"); | 375 | script.push_str("\t--restart=no \\\n"); |
| 376 | script.push_str("\t--volume /tmp/oar-p2p-signal:/oar-p2p\\\n"); | ||
| 357 | script.push_str(&format!("\t--name {} \\\n", container.name)); | 377 | script.push_str(&format!("\t--name {} \\\n", container.name)); |
| 358 | for (key, val) in container.variables.iter() { | 378 | for (key, val) in container.variables.iter() { |
| 359 | script.push_str("\t-e "); | 379 | script.push_str("\t-e "); |
| @@ -406,6 +426,14 @@ async fn machine_start_containers(ctx: &Context, machine: Machine) -> Result<()> | |||
| 406 | Ok(()) | 426 | Ok(()) |
| 407 | } | 427 | } |
| 408 | 428 | ||
| 429 | #[tracing::instrument(ret, err, skip(ctx))] | ||
| 430 | async fn machine_signal_containers(ctx: &Context, machine: Machine) -> Result<()> { | ||
| 431 | tracing::info!("signaling containers"); | ||
| 432 | machine_run_script(ctx, machine, "touch /tmp/oar-p2p-signal/start").await?; | ||
| 433 | tracing::info!("containers signaled"); | ||
| 434 | Ok(()) | ||
| 435 | } | ||
| 436 | |||
| 409 | fn machine_containers_wait_script(containers: &[ScheduledContainer]) -> String { | 437 | fn machine_containers_wait_script(containers: &[ScheduledContainer]) -> String { |
| 410 | let mut script = String::default(); | 438 | let mut script = String::default(); |
| 411 | for container in containers { | 439 | for container in containers { |
