Skip to content

Commit

Permalink
start-up: add runc baseline (#15)
Browse files Browse the repository at this point in the history
* start-up: add runc baseline

* nit

* gha: add libfontconfig

* fix clippy warning

* gha: more fixes

* run new cargo fmt

* add clippy
  • Loading branch information
csegarragonz authored Dec 20, 2024
1 parent afb5802 commit 3afa1d0
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 109 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion results/start-up/README.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
19 changes: 19 additions & 0 deletions results/start-up/data/runc.csv
Original file line number Diff line number Diff line change
@@ -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
189 changes: 96 additions & 93 deletions results/start-up/plots/start_up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion src/containerd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion src/experiment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::{

#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, ValueEnum)]
pub enum AvailableBaselines {
Runc,
Kata,
Snp,
SnpSc2,
Expand All @@ -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"),
Expand All @@ -35,6 +37,7 @@ impl FromStr for AvailableBaselines {

fn from_str(input: &str) -> Result<AvailableBaselines, Self::Err> {
match input {
"runc" => Ok(AvailableBaselines::Runc),
"kata" => Ok(AvailableBaselines::Kata),
"snp" => Ok(AvailableBaselines::Snp),
"snp-sc2" => Ok(AvailableBaselines::SnpSc2),
Expand All @@ -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,
Expand All @@ -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),
Expand Down Expand Up @@ -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(),
Expand Down
16 changes: 14 additions & 2 deletions src/kubernetes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>()
.join("\n");
}

result_str
}

fn get_knative_service_ip(service_name: &str) -> String {
Expand Down
24 changes: 14 additions & 10 deletions src/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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,
}
}

Expand All @@ -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),
Expand Down

0 comments on commit 3afa1d0

Please sign in to comment.