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
1 change: 1 addition & 0 deletions .github/buildomat/jobs/bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ pfexec cp /input/xde/work/release/xde /kernel/drv/amd64
pfexec add_drv xde

banner "bench"
CI=1
cargo kbench local
cargo ubench

Expand Down
76 changes: 65 additions & 11 deletions bench/benches/userland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

// Copyright 2024 Oxide Computer Company
// Copyright 2026 Oxide Computer Company

//! Userland packet parsing and processing microbenchmarks.

Expand All @@ -21,6 +21,7 @@ use opte_bench::packet::Dhcp6;
use opte_bench::packet::Icmp4;
use opte_bench::packet::Icmp6;
use opte_bench::packet::ParserKind;
use opte_bench::packet::SlowpathEvict;
use opte_bench::packet::TestCase;
use opte_bench::packet::ULP_FAST_PATH;
use opte_bench::packet::ULP_SLOW_PATH;
Expand All @@ -44,11 +45,18 @@ pub fn block<M: MeasurementInfo>(c: &mut Criterion<M>, do_parse: bool) {
Box::new(Icmp6),
Box::new(ULP_FAST_PATH),
Box::new(ULP_SLOW_PATH),
Box::new(SlowpathEvict {
capacities: [1 << 10, 1 << 15, 1 << 19, 1 << 20]
.into_iter()
.filter_map(NonZeroU32::new)
.collect(),
p_expires: vec![0.0],
}),
];

for experiment in all_tests {
for case in experiment.test_cases() {
if do_parse {
if experiment.do_parse_benchmark() && do_parse {
test_parse(c, &**experiment, &*case);
}
test_handle(c, &**experiment, &*case);
Expand Down Expand Up @@ -151,6 +159,7 @@ pub fn test_handle<M: MeasurementInfo>(
));

let parser = case.parse_with();
let can_fail = experiment.allow_failure();
c.bench_with_input(
BenchmarkId::from_parameter(case.instance_name()),
&case,
Expand All @@ -174,19 +183,23 @@ pub fn test_handle<M: MeasurementInfo>(
GenericUlp {},
)
.unwrap();
port.port.process(dir, black_box(pkt)).unwrap()
port.port.process(dir, black_box(pkt))
}
Out => {
let pkt = Packet::parse_outbound(
pkt_m.iter_mut(),
GenericUlp {},
)
.unwrap();
port.port.process(dir, black_box(pkt)).unwrap()
port.port.process(dir, black_box(pkt))
}
};
assert!(!matches!(res, ProcessResult::Drop { .. }));
if let Modified(spec) = res {

if !can_fail {
assert!(res.is_ok());
}

if let Ok(Modified(spec)) = res {
black_box(spec.apply(pkt_m));
}
}
Expand All @@ -198,19 +211,23 @@ pub fn test_handle<M: MeasurementInfo>(
VpcParser {},
)
.unwrap();
port.port.process(dir, black_box(pkt)).unwrap()
port.port.process(dir, black_box(pkt))
}
Out => {
let pkt = Packet::parse_outbound(
pkt_m.iter_mut(),
VpcParser {},
)
.unwrap();
port.port.process(dir, black_box(pkt)).unwrap()
port.port.process(dir, black_box(pkt))
}
};
assert!(!matches!(res, ProcessResult::Drop { .. }));
if let Modified(spec) = res {

if !can_fail {
assert!(res.is_ok());
}

if let Ok(Modified(spec)) = res {
black_box(spec.apply(pkt_m));
}
}
Expand Down Expand Up @@ -325,7 +342,44 @@ fn source_filter_allows(c: &mut Criterion) {
group.finish();
}

criterion_group!(wall, parse_and_process, source_filter_allows);
fn periodic_cleanup<M: MeasurementInfo>(c: &mut Criterion<M>) {
let (capacities, p_expires) = if std::env::var("CI").is_ok() {
(&[1 << 10, 1 << 15][..], vec![0.0, 0.25])
} else {
(&[1 << 10, 1 << 15, 1 << 19, 1 << 20][..], vec![0.0, 0.1, 0.25, 0.5])
};
let expt = SlowpathEvict {
capacities: capacities
.iter()
.copied()
.filter_map(NonZeroU32::new)
.collect(),
p_expires,
};
for case in expt.test_cases() {
let port = case.create_port().unwrap();
let mut c = c.benchmark_group(format!("cleanup/{}", M::label()));

c.bench_with_input(
BenchmarkId::from_parameter(case.instance_name()),
&case,
|b, _i| {
b.iter_batched(
|| case.pre_handle(&port),
|_| black_box(port.port.expire_flows()),
criterion::BatchSize::LargeInput,
)
},
);
}
}

criterion_group!(
wall,
parse_and_process,
source_filter_allows,
periodic_cleanup
);
criterion_group!(
name = alloc;
config = new_crit(Allocs);
Expand Down
20 changes: 5 additions & 15 deletions bench/src/kbench/workload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

// Copyright 2024 Oxide Computer Company
// Copyright 2026 Oxide Computer Company

use super::*;
use measurement::Instrumentation;

#[allow(dead_code)]
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub enum IperfMode {
#[default]
ClientSend,
ServerSend,
// TODO: need an updated illumos package.
Expand All @@ -28,15 +29,10 @@ impl std::fmt::Display for IperfMode {
}
}

impl Default for IperfMode {
fn default() -> Self {
Self::ClientSend
}
}

#[allow(dead_code)]
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub enum IperfProto {
#[default]
Tcp,
Udp {
/// Target bandwidth in MiB/s.
Expand All @@ -59,12 +55,6 @@ impl std::fmt::Display for IperfProto {
}
}

impl Default for IperfProto {
fn default() -> Self {
Self::Tcp
}
}

#[derive(Debug, Clone)]
pub struct IperfConfig {
pub instrumentation: Instrumentation,
Expand Down
Loading