Skip to content

Commit 3e3e2be

Browse files
committed
fixup: shared fifo
1 parent 0861cd1 commit 3e3e2be

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/run/runner/shared/fifo.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use nix::{sys::time::TimeValLike, time::clock_gettime};
44
use runner_shared::benchmark_results::MarkerResult;
55
use runner_shared::fifo::{Command as FifoCommand, MarkerType};
66
use runner_shared::fifo::{RUNNER_ACK_FIFO, RUNNER_CTL_FIFO};
7+
use std::cmp::Ordering;
78
use std::path::{Path, PathBuf};
89
use std::{collections::HashSet, time::Duration};
910
use tokio::io::{AsyncReadExt, AsyncWriteExt};
@@ -62,8 +63,7 @@ impl GenericFifo {
6263
}
6364
}
6465

65-
// TODO: Find a better name for this (SharedBenchmarkData? BenchmarkData?)
66-
pub struct FifoData {
66+
pub struct FifoBenchmarkData {
6767
/// Name and version of the integration
6868
pub integration: Option<(String, String)>,
6969
pub bench_pids: HashSet<pid_t>,
@@ -127,7 +127,7 @@ impl RunnerFifo {
127127
&mut self,
128128
mut health_check: impl AsyncFnMut() -> anyhow::Result<bool>,
129129
mut handle_cmd: impl AsyncFnMut(&FifoCommand) -> anyhow::Result<FifoCommand>,
130-
) -> anyhow::Result<(MarkerResult, FifoData)> {
130+
) -> anyhow::Result<(MarkerResult, FifoBenchmarkData)> {
131131
let mut bench_order_by_timestamp = Vec::<(u64, String)>::new();
132132
let mut bench_pids = HashSet::<pid_t>::new();
133133
let mut markers = Vec::<MarkerType>::new();
@@ -181,6 +181,7 @@ impl RunnerFifo {
181181
benchmark_started = false;
182182
markers.push(MarkerType::SampleEnd(current_time()));
183183
}
184+
#[allow(deprecated)]
184185
FifoCommand::SetIntegration { name, version } => {
185186
integration = Some((name.into(), version.into()));
186187
self.send_cmd(FifoCommand::Ack).await?;
@@ -192,19 +193,20 @@ impl RunnerFifo {
192193
continue;
193194
}
194195
FifoCommand::SetVersion(protocol_version) => {
195-
if *protocol_version < runner_shared::fifo::CURRENT_PROTOCOL_VERSION {
196-
panic!(
196+
match protocol_version.cmp(&runner_shared::fifo::CURRENT_PROTOCOL_VERSION) {
197+
Ordering::Less => panic!(
197198
"Integration is using an incompatible protocol version ({protocol_version} < {}). Please update the integration to the latest version.",
198199
runner_shared::fifo::CURRENT_PROTOCOL_VERSION
199-
)
200-
} else if *protocol_version > runner_shared::fifo::CURRENT_PROTOCOL_VERSION {
201-
panic!(
200+
),
201+
Ordering::Greater => panic!(
202202
"Runner is using an incompatible protocol version ({} < {protocol_version}). Please update the runner to the latest version.",
203203
runner_shared::fifo::CURRENT_PROTOCOL_VERSION
204-
)
205-
};
206-
self.send_cmd(FifoCommand::Ack).await?;
207-
continue;
204+
),
205+
Ordering::Equal => {
206+
self.send_cmd(FifoCommand::Ack).await?;
207+
continue;
208+
}
209+
}
208210
}
209211
_ => {}
210212
}
@@ -213,7 +215,7 @@ impl RunnerFifo {
213215
}
214216

215217
let marker_result = MarkerResult::new(&bench_order_by_timestamp, &markers);
216-
let fifo_data = FifoData {
218+
let fifo_data = FifoBenchmarkData {
217219
integration,
218220
bench_pids,
219221
};

src/run/runner/wall_time/perf/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::run::runner::helpers::env::is_codspeed_debug_enabled;
88
use crate::run::runner::helpers::run_command_with_log_pipe::run_command_with_log_pipe_and_callback;
99
use crate::run::runner::helpers::run_with_sudo::run_with_sudo;
1010
use crate::run::runner::helpers::run_with_sudo::wrap_with_sudo;
11-
use crate::run::runner::shared::fifo::FifoData;
11+
use crate::run::runner::shared::fifo::FifoBenchmarkData;
1212
use crate::run::runner::shared::fifo::RunnerFifo;
1313
use crate::run::runner::valgrind::helpers::ignored_objects_path::get_objects_path_to_ignore;
1414
use crate::run::runner::valgrind::helpers::perf_maps::harvest_perf_maps_for_pids;
@@ -350,7 +350,7 @@ impl PerfRunner {
350350
}
351351

352352
pub struct BenchmarkData {
353-
fifo_data: FifoData,
353+
fifo_data: FifoBenchmarkData,
354354
marker_result: MarkerResult,
355355
pub symbols_by_pid: HashMap<pid_t, ProcessSymbols>,
356356
pub unwind_data_by_pid: HashMap<pid_t, Vec<UnwindData>>,
@@ -461,7 +461,7 @@ impl BenchmarkData {
461461
}
462462

463463
impl Deref for BenchmarkData {
464-
type Target = FifoData;
464+
type Target = FifoBenchmarkData;
465465

466466
fn deref(&self) -> &Self::Target {
467467
&self.fifo_data

0 commit comments

Comments
 (0)