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
12 changes: 11 additions & 1 deletion server_manager/benches/service_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,21 @@ fn benchmark_port_matrix_generation(c: &mut Criterion) {
});
}

fn benchmark_doctor_check_port_conflicts(c: &mut Criterion) {
c.bench_function("doctor_check_port_conflicts", |b| {
b.iter(|| {
let result = server_manager::core::doctor::check_port_conflicts();
criterion::black_box(result);
})
});
}

criterion_group!(
benches,
benchmark_catalog_retrieval,
benchmark_compose_generation,
benchmark_validation_throughput,
benchmark_port_matrix_generation
benchmark_port_matrix_generation,
benchmark_doctor_check_port_conflicts
);
criterion_main!(benches);
9 changes: 3 additions & 6 deletions server_manager/src/core/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,13 @@ pub fn check_firewall() -> DoctorCheckResult {

pub fn check_port_conflicts() -> DoctorCheckResult {
let catalog = crate::services::get_service_catalog();
let mut total_ports = 0;
for entry in &catalog {
total_ports += entry.ports.len();
}
let total_ports: usize = catalog.iter().map(|entry| entry.ports.len()).sum();

// In a diagnostic check, we verify that the port matrix has zero internal collisions
let mut seen = std::collections::HashSet::new();
let mut seen = std::collections::HashSet::with_capacity(total_ports);
for entry in &catalog {
for port in &entry.ports {
let key = (port.host_ip.clone(), port.host_port, port.protocol);
let key = (port.host_ip.as_deref(), port.host_port, port.protocol);
if !seen.insert(key) {
return DoctorCheckResult {
name: "Port Matrix".to_string(),
Expand Down
Loading