Skip to content

Commit b7fb0db

Browse files
committed
fix(perf): validate measurements and bound worker startup
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent c853db1 commit b7fb0db

4 files changed

Lines changed: 682 additions & 153 deletions

File tree

‎architecture/sandbox.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,20 @@ broker as its sender, not the original calling agent's `SI_USER` identity.
612612
Queued signals preserve permitted application siginfo payloads; they cannot
613613
forge kernel-generated or `SI_TKILL` codes. Programs requiring original sender
614614
identity must account for this mediation boundary.
615+
616+
## Performance Measurement
617+
618+
The optional `perf-harness` feature provides a local TCP microbenchmark, not a
619+
full sandbox benchmark. It separates connection establishment from established
620+
stream I/O. Connections and warmup complete before measurement starts;
621+
connection-only results have no payload-throughput value. Worker preparation
622+
fails with an error rather than leaving peers blocked at a barrier.
623+
624+
The opt-in E2E benchmarks exercise DNS and TCP through both sandbox and
625+
supervisor to Internet destinations. The live-traffic benchmark alternates a
626+
direct **host-process** baseline with sandbox traffic for ten rounds by default;
627+
this baseline is not raw Docker. Its typed reports distinguish successful,
628+
failed, and skipped samples. Only successful samples are performance results:
629+
every comparable scenario needs successful coverage, and every sandbox denial
630+
round must report an explicit permission error. HTTP error responses, truncated
631+
downloads, and failed DNS queries cannot count as fast successful requests.

‎crates/openshell-sandbox/src/bin/seccomp-perf.rs‎

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,21 @@
55
66
use std::net::SocketAddr;
77

8-
use clap::{Parser, Subcommand};
8+
use clap::{Parser, Subcommand, ValueEnum};
99
use openshell_sandbox::perf::{BenchmarkOptions, Layer, Protocol};
1010

1111
#[derive(Debug, Parser)]
1212
#[command(
1313
about = "Measure native and seccomp-filtered socket performance",
14-
long_about = "Measure native and seccomp-filtered socket performance. UDP unconnected means destination-bearing SOCK_DGRAM traffic, not SOCK_RAW. General external UDP and SOCK_RAW are currently denied by the sandbox."
14+
long_about = "Measure native and seccomp-filtered TCP connection establishment and established-stream performance. Full supervisor-mediated DNS and Internet traffic are measured by the separate E2E harness."
1515
)]
1616
struct Cli {
1717
/// Benchmark layer: native, filtered, or all.
18-
#[arg(long, default_value = "all", value_parser = ["native", "filtered", "all"])]
19-
layer: String,
20-
/// Protocol: tcp-connect, tcp-stream, udp-connected, udp-unconnected, or all.
21-
#[arg(
22-
long,
23-
default_value = "all",
24-
value_parser = ["tcp-connect", "tcp-stream", "udp-connected", "udp-unconnected", "all"]
25-
)]
26-
protocol: String,
18+
#[arg(long, default_value = "all", value_enum)]
19+
layer: LayerSelection,
20+
/// TCP scenario to measure.
21+
#[arg(long, default_value = "all", value_enum)]
22+
protocol: ProtocolSelection,
2723
#[arg(long, default_value_t = 10_000)]
2824
iterations: u64,
2925
#[arg(long, default_value_t = 1_000)]
@@ -79,8 +75,8 @@ fn main() -> anyhow::Result<()> {
7975
}
8076

8177
let options = BenchmarkOptions {
82-
layers: Layer::selection(&cli.layer)?,
83-
protocols: Protocol::selection(&cli.protocol)?,
78+
layers: cli.layer.values(),
79+
protocols: cli.protocol.values(),
8480
iterations: cli.iterations,
8581
warmup: cli.warmup,
8682
concurrency: cli.concurrency,
@@ -91,3 +87,48 @@ fn main() -> anyhow::Result<()> {
9187
}
9288
Ok(())
9389
}
90+
91+
#[derive(Clone, Copy, Debug, ValueEnum)]
92+
enum LayerSelection {
93+
Native,
94+
Filtered,
95+
All,
96+
}
97+
98+
impl LayerSelection {
99+
fn values(self) -> Vec<Layer> {
100+
match self {
101+
Self::Native => vec![Layer::Native],
102+
Self::Filtered => vec![Layer::Filtered],
103+
Self::All => vec![Layer::Native, Layer::Filtered],
104+
}
105+
}
106+
}
107+
108+
#[derive(Clone, Copy, Debug, ValueEnum)]
109+
enum ProtocolSelection {
110+
TcpConnect,
111+
TcpStream,
112+
All,
113+
}
114+
115+
impl ProtocolSelection {
116+
fn values(self) -> Vec<Protocol> {
117+
match self {
118+
Self::TcpConnect => vec![Protocol::TcpConnect],
119+
Self::TcpStream => vec![Protocol::TcpStream],
120+
Self::All => vec![Protocol::TcpConnect, Protocol::TcpStream],
121+
}
122+
}
123+
}
124+
125+
#[cfg(test)]
126+
mod tests {
127+
use super::*;
128+
#[test]
129+
fn unsupported_udp_is_rejected_by_cli() {
130+
for value in ["udp-connected", "udp-unconnected"] {
131+
assert!(Cli::try_parse_from(["seccomp-perf", "--protocol", value]).is_err());
132+
}
133+
}
134+
}

0 commit comments

Comments
 (0)