Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/openshell-sandbox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ repository.workspace = true
name = "openshell-sandbox"
path = "src/main.rs"

[[bin]]
name = "openshell-seccomp-perf"
path = "src/bin/seccomp-perf.rs"
required-features = ["perf-harness"]

[features]
perf-harness = []

Expand Down
100 changes: 100 additions & 0 deletions crates/openshell-sandbox/src/bin/seccomp-perf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

//! Microbenchmark entry point for the production seccomp network broker.

use std::net::SocketAddr;

use clap::builder::{PossibleValue, PossibleValuesParser};
use clap::{Parser, Subcommand, ValueEnum as _};
use openshell_sandbox::perf::{BenchmarkOptions, Layer, Protocol};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

Warning — GATOR-6ea5a915-01 · Linux-only harness breaks macOS checks

Summary: A contributor running the required Rust check, lint, pre-commit, or CI task on macOS now compiles this binary with perf-harness. This import is unconditional, while openshell_sandbox::perf exists only on Linux, so supported macOS workflows fail before completing their checks.

Fix: Gate the binary implementation for Linux and provide a small non-Linux main that reports the platform requirement, or restrict all perf-specific task invocations to Linux while preserving cross-platform feature checks.

Verify: On aarch64 macOS, run mise run rust:check; both Cargo invocations must complete without an unresolved openshell_sandbox::perf import.

Agent context
  • Ownership: This PR adds the Linux-gated module and the generic tasks that compile its binary.
  • Location: crates/openshell-sandbox/src/bin/seccomp-perf.rs:10


#[derive(Debug, Parser)]
#[command(
about = "Measure native and seccomp-filtered socket performance",
long_about = "Measure native and seccomp-filtered TCP socket performance."
)]
struct Cli {
/// Benchmark layer: native, filtered, or all.
#[arg(long, default_value = "all", value_parser = ["native", "filtered", "all"])]
layer: String,
/// Implemented protocol to benchmark, or all.
#[arg(long, default_value = "all", value_parser = protocol_value_parser())]
protocol: String,
#[arg(long, default_value_t = 10_000)]
iterations: u64,
#[arg(long, default_value_t = 1_000)]
warmup: u64,
#[arg(long, default_value_t = 1)]
concurrency: usize,
#[arg(long, default_value_t = 64)]
payload_bytes: usize,
#[command(subcommand)]
command: Option<Command>,
}

fn protocol_value_parser() -> PossibleValuesParser {
let mut values = vec![PossibleValue::new("all")];
values.extend(
Protocol::value_variants()
.iter()
.filter_map(clap::ValueEnum::to_possible_value),
);
PossibleValuesParser::new(values)
}

#[derive(Debug, Subcommand)]
enum Command {
#[command(hide = true)]
Worker {
#[arg(long)]
protocol: Protocol,
#[arg(long)]
target: SocketAddr,
#[arg(long)]
iterations: u64,
#[arg(long)]
warmup: u64,
#[arg(long)]
concurrency: usize,
#[arg(long)]
payload_bytes: usize,
},
}

fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
if let Some(Command::Worker {
protocol,
target,
iterations,
warmup,
concurrency,
payload_bytes,
}) = cli.command
{
let report = openshell_sandbox::perf::run_worker(
protocol,
target,
iterations,
warmup,
concurrency,
payload_bytes,
)?;
println!("{}", serde_json::to_string(&report)?);
return Ok(());
}

let options = BenchmarkOptions {
layers: Layer::selection(&cli.layer)?,
protocols: Protocol::selection(&cli.protocol)?,
iterations: cli.iterations,
warmup: cli.warmup,
concurrency: cli.concurrency,
payload_bytes: cli.payload_bytes,
};
for report in openshell_sandbox::perf::run(options)? {
println!("{}", serde_json::to_string(&report)?);
}
Ok(())
}
2 changes: 2 additions & 0 deletions crates/openshell-sandbox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub mod main_session;
pub mod managed_children;
#[cfg(target_os = "linux")]
mod network_broker;
#[cfg(all(target_os = "linux", feature = "perf-harness"))]
pub mod perf;
#[cfg(unix)]
pub mod process;
mod pty;
Expand Down
Loading
Loading