From a7eee590173f3f369af8db5293c7924f79ac9a96 Mon Sep 17 00:00:00 2001 From: Carlos Segarra Date: Wed, 4 Dec 2024 12:29:14 +0000 Subject: [PATCH] start-up: add tdx results --- results/start-up/README.md | 2 +- results/start-up/data/tdx-sc2.csv | 19 ++ results/start-up/data/tdx.csv | 19 ++ results/start-up/plots/start_up.svg | 260 ++++++++++++---------------- src/experiment.rs | 8 +- src/plot.rs | 67 +++++-- 6 files changed, 207 insertions(+), 168 deletions(-) create mode 100644 results/start-up/data/tdx-sc2.csv create mode 100644 results/start-up/data/tdx.csv diff --git a/results/start-up/README.md b/results/start-up/README.md index 09ce41b..d30c93d 100644 --- a/results/start-up/README.md +++ b/results/start-up/README.md @@ -6,7 +6,7 @@ compares SC2 with Kata and SEV-SNP. Once you have a working SC2 cluster, you may run the experiment using: ```bash -sc2-exp start-up run --baseline [kata,snp,snp-sc2] +sc2-exp start-up run --baseline [kata,snp,snp-sc2,tdx,tdx-sc2] ``` after running all baselines, you may plot the results using: diff --git a/results/start-up/data/tdx-sc2.csv b/results/start-up/data/tdx-sc2.csv new file mode 100644 index 0000000..ddc3d12 --- /dev/null +++ b/results/start-up/data/tdx-sc2.csv @@ -0,0 +1,19 @@ +Run,Event,TimeMs +0,StartUp,15217 +0,CreateContainerQueueProxy,43 +0,CreateContainerUserContainer,47 +0,RunPodSandbox,4076 +0,StartContainerQueueProxy,1441 +0,StartContainerUserContainer,8152 +1,StartUp,13260 +1,CreateContainerQueueProxy,51 +1,CreateContainerUserContainer,47 +1,RunPodSandbox,875 +1,StartContainerQueueProxy,2752 +1,StartContainerUserContainer,8904 +2,StartUp,13148 +2,CreateContainerQueueProxy,51 +2,CreateContainerUserContainer,74 +2,RunPodSandbox,859 +2,StartContainerQueueProxy,2745 +2,StartContainerUserContainer,8890 diff --git a/results/start-up/data/tdx.csv b/results/start-up/data/tdx.csv new file mode 100644 index 0000000..997c9db --- /dev/null +++ b/results/start-up/data/tdx.csv @@ -0,0 +1,19 @@ +Run,Event,TimeMs +0,StartUp,20861 +0,CreateContainerQueueProxy,46 +0,CreateContainerUserContainer,51 +0,RunPodSandbox,8336 +0,StartContainerQueueProxy,2702 +0,StartContainerUserContainer,8715 +1,StartUp,19689 +1,CreateContainerQueueProxy,43 +1,CreateContainerUserContainer,61 +1,RunPodSandbox,8381 +1,StartContainerQueueProxy,1364 +1,StartContainerUserContainer,8378 +2,StartUp,21193 +2,CreateContainerQueueProxy,51 +2,CreateContainerUserContainer,56 +2,RunPodSandbox,8296 +2,StartContainerQueueProxy,2693 +2,StartContainerUserContainer,8720 diff --git a/results/start-up/plots/start_up.svg b/results/start-up/plots/start_up.svg index 96c0809..b44a39f 100644 --- a/results/start-up/plots/start_up.svg +++ b/results/start-up/plots/start_up.svg @@ -1,169 +1,135 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - - -2 + + +5 - - -4 - - - -6 - - - -8 - - - + + 10 - - -12 + + +15 - - -14 + + +20 - - + + Cold Start Latency [s] - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + kata - + snp - + snp-sc2 - + tdx - - + +tdx-sc2 + + + create-vm - - + + pull-image diff --git a/src/experiment.rs b/src/experiment.rs index 879f3c6..9edbb0c 100644 --- a/src/experiment.rs +++ b/src/experiment.rs @@ -15,6 +15,7 @@ pub enum AvailableBaselines { Snp, SnpSc2, Tdx, + TdxSc2, } impl fmt::Display for AvailableBaselines { @@ -24,6 +25,7 @@ impl fmt::Display for AvailableBaselines { AvailableBaselines::Snp => write!(f, "snp"), AvailableBaselines::SnpSc2 => write!(f, "snp-sc2"), AvailableBaselines::Tdx => write!(f, "tdx"), + AvailableBaselines::TdxSc2 => write!(f, "tdx-sc2"), } } } @@ -37,6 +39,7 @@ impl FromStr for AvailableBaselines { "snp" => Ok(AvailableBaselines::Snp), "snp-sc2" => Ok(AvailableBaselines::SnpSc2), "tdx" => Ok(AvailableBaselines::Tdx), + "tdx-sc2" => Ok(AvailableBaselines::TdxSc2), _ => Err(()), } } @@ -44,11 +47,12 @@ impl FromStr for AvailableBaselines { impl AvailableBaselines { pub fn iter_variants() -> std::slice::Iter<'static, AvailableBaselines> { - static VARIANTS: [AvailableBaselines; 4] = [ + static VARIANTS: [AvailableBaselines; 5] = [ AvailableBaselines::Kata, AvailableBaselines::Snp, AvailableBaselines::SnpSc2, AvailableBaselines::Tdx, + AvailableBaselines::TdxSc2, ]; VARIANTS.iter() } @@ -59,6 +63,7 @@ impl AvailableBaselines { AvailableBaselines::Snp => RGBColor(203, 170, 203), AvailableBaselines::SnpSc2 => RGBColor(213, 160, 163), AvailableBaselines::Tdx => RGBColor(255, 255, 181), + AvailableBaselines::TdxSc2 => RGBColor(205, 255, 101), } } } @@ -374,6 +379,7 @@ impl Exp { AvailableBaselines::Snp => "kata-qemu-snp".to_string(), AvailableBaselines::SnpSc2 => "kata-qemu-snp-sc2".to_string(), AvailableBaselines::Tdx => "kata-qemu-tdx".to_string(), + AvailableBaselines::TdxSc2 => "kata-qemu-tdx-sc2".to_string(), }, ), ]); diff --git a/src/plot.rs b/src/plot.rs index 731a321..0ca37c5 100644 --- a/src/plot.rs +++ b/src/plot.rs @@ -109,12 +109,6 @@ impl Plot { .insert("Orchestration", orchestration_time); } - // FIXME(tdx): must manually add Orchestration for TDX as we cannot - // run the experiments yet - data.get_mut(&AvailableBaselines::Tdx) - .unwrap() - .insert("Orchestration", 0.0); - // ---------- Plot Data ---------- // for (baseline, times) in data.iter() { @@ -129,16 +123,19 @@ impl Plot { fs::create_dir_all(plot_path.clone()).unwrap(); plot_path.push(format!("{}.svg", exp.to_string().replace("-", "_"))); - let root = SVGBackend::new(&plot_path, (400, 600)).into_drawing_area(); + let chart_height_px = 600; + let chart_width_px = 400; + let root = + SVGBackend::new(&plot_path, (chart_height_px, chart_width_px)).into_drawing_area(); root.fill(&WHITE).unwrap(); - let x_max = AvailableBaselines::iter_variants().len(); + let x_max = AvailableBaselines::iter_variants().len() as f64; let mut chart = ChartBuilder::on(&root) .x_label_area_size(40) .y_label_area_size(40) .margin(10) .margin_top(40) - .build_cartesian_2d(0..x_max, 0f64..(y_max / 1000.0)) + .build_cartesian_2d(0.0..x_max, 0f64..(y_max / 1000.0)) .unwrap(); chart @@ -154,7 +151,7 @@ impl Plot { // Manually draw the y-axis label with a custom font and size root.draw(&Text::new( "Cold Start Latency [s]", - (3, 360), + (3, 280), ("sans-serif", 20) .into_font() .transform(FontTransform::Rotate270) @@ -185,8 +182,10 @@ impl Plot { let prev_y = prev_y_map.get_mut(baseline).unwrap(); this_y /= 1000.0; - let mut bar = - Rectangle::new([(x, *prev_y), (x + 1, *prev_y + this_y)], bar_style); + let mut bar = Rectangle::new( + [(x as f64, *prev_y), (x as f64 + 1.0, *prev_y + this_y)], + bar_style, + ); *prev_y += this_y; bar.set_margin(0, 0, 2, 2); @@ -196,11 +195,34 @@ impl Plot { } // Consider adding another series in black without fill (for the frame) + chart + .draw_series((0..).zip(data.iter()).map(|(x, (baseline, _))| { + // Benefit from the fact that prev_y stores the maximum y + // value after we plot the stacked bar chart + let this_y = *prev_y_map.get_mut(baseline).unwrap(); + + let margin_px = 2; + let x_axis_range = 0.0..x_max; + let margin_units = margin_px as f64 * (x_axis_range.end - x_axis_range.start) + / chart_width_px as f64; + + PathElement::new( + vec![ + (x as f64 + margin_units, this_y), + (x as f64 - margin_units + 1.0, this_y), + (x as f64 - margin_units + 1.0, 0.0), + (x as f64 + margin_units, 0.0), + (x as f64 + margin_units, this_y), + ], + BLACK, + ) + })) + .unwrap(); // Add solid frames chart .plotting_area() - .draw(&PathElement::new(vec![(0, y_max), (x_max, y_max)], BLACK)) + .draw(&PathElement::new(vec![(0.0, y_max), (x_max, y_max)], BLACK)) .unwrap(); chart .plotting_area() @@ -212,29 +234,36 @@ impl Plot { chart .plotting_area() .draw(&PathElement::new( - vec![(0, 0 as f64), (x_max, 0 as f64)], + vec![(0.0, 0 as f64), (x_max, 0 as f64)], BLACK, )) .unwrap(); // Manually draw the x-axis labels with a custom font and size - let mut x = 85; + fn xaxis_pos_for_baseline(baseline: &AvailableBaselines) -> i32 { + match baseline { + AvailableBaselines::Kata => 100, + AvailableBaselines::Snp => 200, + AvailableBaselines::SnpSc2 => 300, + AvailableBaselines::Tdx => 400, + AvailableBaselines::TdxSc2 => 500, + } + } + for (_, baseline) in (0..).zip(AvailableBaselines::iter_variants()) { root.draw(&Text::new( format!("{baseline}"), - (x, 560), + (xaxis_pos_for_baseline(baseline), 360), ("sans-serif", 20).into_font().color(&BLACK), )) .unwrap(); - - x += 80; } // Manually draw the legend outside the grid, above the chart let legend_labels = vec!["create-vm", "pull-image"]; fn legend_pos_for_label(label: &str) -> (i32, i32) { - let legend_x_start = 70; + let legend_x_start = 170; let legend_y_pos = 6; match label {