From 3afa1d0dbb9b0ea492cf68973697f79ef1b74d2e Mon Sep 17 00:00:00 2001 From: Carlos Date: Fri, 20 Dec 2024 13:53:13 +0000 Subject: [PATCH] start-up: add runc baseline (#15) * start-up: add runc baseline * nit * gha: add libfontconfig * fix clippy warning * gha: more fixes * run new cargo fmt * add clippy --- .github/workflows/checks.yaml | 9 +- results/start-up/README.md | 2 +- results/start-up/data/runc.csv | 19 +++ results/start-up/plots/start_up.svg | 189 ++++++++++++++-------------- src/containerd.rs | 8 +- src/experiment.rs | 8 +- src/kubernetes.rs | 16 ++- src/plot.rs | 24 ++-- 8 files changed, 166 insertions(+), 109 deletions(-) create mode 100644 results/start-up/data/runc.csv diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index c7b8083..c7077bd 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -18,11 +18,18 @@ concurrency: jobs: lint_and_format: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: "Checkout code" uses: actions/checkout@v4 + - name: "Install apt deps" + run: sudo apt install -y libfontconfig1-dev + - name: "Fix rust version" + run: | + rustup default 1.83.0 + rustup component add clippy + rustup component add rustfmt - name: "Run cargo fmt check" run: cargo fmt --all -- --check - name: "Run cargo clippy" diff --git a/results/start-up/README.md b/results/start-up/README.md index d30c93d..b4e8ace 100644 --- a/results/start-up/README.md +++ b/results/start-up/README.md @@ -1,7 +1,7 @@ ## Start-Up Experimnet This experiment measures the start-up latency of a simple Knative service. It -compares SC2 with Kata and SEV-SNP. +compares SC2 with runc, and Kata-Qemu plain and with SEV-SNP and TDX. Once you have a working SC2 cluster, you may run the experiment using: diff --git a/results/start-up/data/runc.csv b/results/start-up/data/runc.csv new file mode 100644 index 0000000..b7c3b17 --- /dev/null +++ b/results/start-up/data/runc.csv @@ -0,0 +1,19 @@ +Run,Event,TimeMs +0,StartUp,941 +0,CreateContainerQueueProxy,6 +0,CreateContainerUserContainer,5 +0,RunPodSandbox,221 +0,StartContainerQueueProxy,74 +0,StartContainerUserContainer,66 +1,StartUp,928 +1,CreateContainerQueueProxy,5 +1,CreateContainerUserContainer,6 +1,RunPodSandbox,198 +1,StartContainerQueueProxy,75 +1,StartContainerUserContainer,82 +2,StartUp,936 +2,CreateContainerQueueProxy,7 +2,CreateContainerUserContainer,5 +2,RunPodSandbox,195 +2,StartContainerQueueProxy,97 +2,StartContainerUserContainer,94 diff --git a/results/start-up/plots/start_up.svg b/results/start-up/plots/start_up.svg index b44a39f..50da18e 100644 --- a/results/start-up/plots/start_up.svg +++ b/results/start-up/plots/start_up.svg @@ -1,135 +1,138 @@ - - - - + + - - - - - - - - - - - - + + + + + + + - - - - - - - - - + + + + + - - - - + + - - - - - - - - + + + + + - - - - + + + + + 0 - + 5 - - + + 10 - - + + 15 - - + + 20 - + + +25 + + Cold Start Latency [s] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + +runc + + kata - + snp - + snp-sc2 - + tdx - + tdx-sc2 - - + + +control-plane + + + create-vm - - + + pull-image diff --git a/src/containerd.rs b/src/containerd.rs index 658359e..0bd2937 100644 --- a/src/containerd.rs +++ b/src/containerd.rs @@ -67,13 +67,14 @@ impl Containerd { ); // Load the journalctl output into a buffer reader - let journalctl = Command::new("sudo") + let mut journalctl = Command::new("sudo") .args(["journalctl", "-xeu", "containerd", "-o", "json"]) .stdout(Stdio::piped()) .spawn() .unwrap(); let stdout = journalctl .stdout + .take() .ok_or("sc2-exp: failed to open journalctl stdout") .unwrap(); let reader = BufReader::new(stdout); @@ -235,6 +236,11 @@ impl Containerd { } } + // Wait on the process to silent clippy warning + journalctl + .wait() + .expect("Failed to wait on journalctl process"); + debug!( "{}(containerd): got a total of {} events", Env::SYS_NAME, diff --git a/src/experiment.rs b/src/experiment.rs index 9edbb0c..9ff8e9c 100644 --- a/src/experiment.rs +++ b/src/experiment.rs @@ -11,6 +11,7 @@ use std::{ #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] pub enum AvailableBaselines { + Runc, Kata, Snp, SnpSc2, @@ -21,6 +22,7 @@ pub enum AvailableBaselines { impl fmt::Display for AvailableBaselines { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { + AvailableBaselines::Runc => write!(f, "runc"), AvailableBaselines::Kata => write!(f, "kata"), AvailableBaselines::Snp => write!(f, "snp"), AvailableBaselines::SnpSc2 => write!(f, "snp-sc2"), @@ -35,6 +37,7 @@ impl FromStr for AvailableBaselines { fn from_str(input: &str) -> Result { match input { + "runc" => Ok(AvailableBaselines::Runc), "kata" => Ok(AvailableBaselines::Kata), "snp" => Ok(AvailableBaselines::Snp), "snp-sc2" => Ok(AvailableBaselines::SnpSc2), @@ -47,7 +50,8 @@ impl FromStr for AvailableBaselines { impl AvailableBaselines { pub fn iter_variants() -> std::slice::Iter<'static, AvailableBaselines> { - static VARIANTS: [AvailableBaselines; 5] = [ + static VARIANTS: [AvailableBaselines; 6] = [ + AvailableBaselines::Runc, AvailableBaselines::Kata, AvailableBaselines::Snp, AvailableBaselines::SnpSc2, @@ -59,6 +63,7 @@ impl AvailableBaselines { pub fn get_color(&self) -> RGBColor { match self { + AvailableBaselines::Runc => RGBColor(122, 92, 117), AvailableBaselines::Kata => RGBColor(171, 222, 230), AvailableBaselines::Snp => RGBColor(203, 170, 203), AvailableBaselines::SnpSc2 => RGBColor(213, 160, 163), @@ -375,6 +380,7 @@ impl Exp { ( "RUNTIME_CLASS_NAME", match baseline { + AvailableBaselines::Runc => "runc".to_string(), AvailableBaselines::Kata => "kata-qemu".to_string(), AvailableBaselines::Snp => "kata-qemu-snp".to_string(), AvailableBaselines::SnpSc2 => "kata-qemu-snp-sc2".to_string(), diff --git a/src/kubernetes.rs b/src/kubernetes.rs index f66b6c4..6ea8542 100644 --- a/src/kubernetes.rs +++ b/src/kubernetes.rs @@ -115,8 +115,20 @@ impl K8s { .wait_with_output() .expect("sc2-exp(k8s): failed to read envsubst result"); - String::from_utf8(result.stdout) - .expect("sc2-exp(k8s): failed to convert envsubst output to string") + let result_str = String::from_utf8(result.stdout) + .expect("sc2-exp(k8s): failed to convert envsubst output to string"); + + // If running the `runc` baseline, we must drop the runtime class line + // altogether + if env_vars.get("RUNTIME_CLASS_NAME").unwrap() == "runc" { + return result_str + .lines() + .filter(|line| !line.trim_start().starts_with("runtimeClassName")) + .collect::>() + .join("\n"); + } + + result_str } fn get_knative_service_ip(service_name: &str) -> String { diff --git a/src/plot.rs b/src/plot.rs index 0ca37c5..411fcba 100644 --- a/src/plot.rs +++ b/src/plot.rs @@ -55,7 +55,7 @@ impl Plot { data.insert(workflow.clone(), inner_map); } - let mut y_max: f64 = 0.0; + let mut y_max: f64 = 25.0e3; for csv_file in data_files { let file_name = csv_file .file_name() @@ -142,6 +142,7 @@ impl Plot { .configure_mesh() .y_label_style(("sans-serif", 20).into_font()) .y_labels(10) + .y_max_light_lines(5) .disable_x_mesh() .disable_x_axis() .y_label_formatter(&|y| format!("{:.0}", y)) @@ -242,11 +243,12 @@ impl Plot { // Manually draw the x-axis labels with a custom font and size 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, + AvailableBaselines::Runc => 80, + AvailableBaselines::Kata => 180, + AvailableBaselines::Snp => 260, + AvailableBaselines::SnpSc2 => 340, + AvailableBaselines::Tdx => 445, + AvailableBaselines::TdxSc2 => 520, } } @@ -260,21 +262,23 @@ impl Plot { } // Manually draw the legend outside the grid, above the chart - let legend_labels = vec!["create-vm", "pull-image"]; + let legend_labels = vec!["control-plane", "create-vm", "pull-image"]; fn legend_pos_for_label(label: &str) -> (i32, i32) { - let legend_x_start = 170; + let legend_x_start = 110; let legend_y_pos = 6; match label { - "create-vm" => (legend_x_start, legend_y_pos), - "pull-image" => (legend_x_start + 150, legend_y_pos), + "control-plane" => (legend_x_start, legend_y_pos), + "create-vm" => (legend_x_start + 150, legend_y_pos), + "pull-image" => (legend_x_start + 280, legend_y_pos), _ => panic!("{}(plot): unrecognised label: {label}", Env::SYS_NAME), } } fn legend_color_for_label(label: &str) -> RGBColor { match label { + "control-plane" => Containerd::get_color_for_event("StartUp"), "create-vm" => Containerd::get_color_for_event("RunPodSandbox"), "pull-image" => Containerd::get_color_for_event("StartContainerUserContainer"), _ => panic!("{}(plot): unrecognised label: {label}", Env::SYS_NAME),