summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Birr-Pixton <jpixton@gmail.com>2024-09-13 15:16:33 +0100
committerJoe Birr-Pixton <jpixton@gmail.com>2024-09-20 12:27:49 +0000
commit5c17f43e0fc9a6e083ae584efcb137aaf7846f31 (patch)
tree46f1cafca64d2c0e5d8ac4051e68112d01ab84d5
parentd85b165ee2b0576fb9fa7ef7f9309668546728d4 (diff)
Remove code for subtracting benchmark case costs
Previously, this would subtract a base case benchmark (the cost of the full handshake) but that adds the noise of that benchmark. It is no longer necessary now we are more precise about the instructions that are counted.
-rw-r--r--ci-bench/src/benchmark.rs66
-rw-r--r--ci-bench/src/main.rs22
2 files changed, 8 insertions, 80 deletions
diff --git a/ci-bench/src/benchmark.rs b/ci-bench/src/benchmark.rs
index 982e009e..6434df68 100644
--- a/ci-bench/src/benchmark.rs
+++ b/ci-bench/src/benchmark.rs
@@ -1,6 +1,6 @@
use std::sync::Arc;
-use fxhash::{FxHashMap, FxHashSet};
+use fxhash::FxHashMap;
use itertools::Itertools;
use crate::callgrind::InstructionCounts;
@@ -12,7 +12,6 @@ use crate::Side;
/// Benchmarks can be invalid because of the following reasons:
///
/// - Re-using an already defined benchmark name.
-/// - Referencing a non-existing benchmark in [`ReportingMode::AllInstructionsExceptSetup`].
pub fn validate_benchmarks(benchmarks: &[Benchmark]) -> anyhow::Result<()> {
// Detect duplicate definitions
let duplicate_names: Vec<_> = benchmarks
@@ -27,55 +26,15 @@ pub fn validate_benchmarks(benchmarks: &[Benchmark]) -> anyhow::Result<()> {
);
}
- // Detect dangling benchmark references
- let all_names: FxHashSet<_> = benchmarks
- .iter()
- .map(|b| b.name.as_str())
- .collect();
- let referenced_names: FxHashSet<_> = benchmarks
- .iter()
- .flat_map(|b| match &b.reporting_mode {
- ReportingMode::AllInstructions => None,
- ReportingMode::AllInstructionsExceptSetup(name) => Some(name.as_str()),
- })
- .collect();
-
- let undefined_names: Vec<_> = referenced_names
- .difference(&all_names)
- .cloned()
- .collect();
- if !undefined_names.is_empty() {
- anyhow::bail!("The following benchmark names are referenced, but have no corresponding benchmarks: {}",
- undefined_names.join(", "));
- }
-
Ok(())
}
-/// Specifies how the results of a particular benchmark should be reported
-pub enum ReportingMode {
- /// All instructions are reported
- AllInstructions,
- /// All instructions are reported, after subtracting the instructions of the setup code
- ///
- /// The instruction count of the setup code is obtained by running a benchmark containing only
- /// that code. The string parameter corresponds to the name of that benchmark.
- AllInstructionsExceptSetup(String),
-}
-
/// Get the reported instruction counts for the provided benchmark
pub fn get_reported_instr_count(
bench: &Benchmark,
results: &FxHashMap<&str, InstructionCounts>,
) -> InstructionCounts {
- match bench.reporting_mode() {
- ReportingMode::AllInstructions => results[&bench.name()],
- ReportingMode::AllInstructionsExceptSetup(setup_name) => {
- let bench_results = results[&bench.name()];
- let setup_results = results[setup_name.as_str()];
- bench_results - setup_results
- }
- }
+ results[&bench.name()]
}
/// Specifies which functionality is being benchmarked
@@ -167,26 +126,12 @@ pub struct Benchmark {
pub kind: BenchmarkKind,
/// The benchmark's parameters
pub params: BenchmarkParams,
- /// The way instruction counts should be reported for this benchmark
- pub reporting_mode: ReportingMode,
}
impl Benchmark {
/// Create a new benchmark
pub fn new(name: String, kind: BenchmarkKind, params: BenchmarkParams) -> Self {
- Self {
- name,
- kind,
- params,
- reporting_mode: ReportingMode::AllInstructions,
- }
- }
-
- /// Configure this benchmark to subtract the instruction count of the referenced benchmark when
- /// reporting results
- pub fn exclude_setup_instructions(mut self, name: String) -> Self {
- self.reporting_mode = ReportingMode::AllInstructionsExceptSetup(name);
- self
+ Self { name, kind, params }
}
/// Returns the benchmark's unique name
@@ -198,9 +143,4 @@ impl Benchmark {
pub fn name_with_side(&self, side: Side) -> String {
format!("{}_{}", self.name, side.as_str())
}
-
- /// Returns the benchmark's reporting mode
- pub fn reporting_mode(&self) -> &ReportingMode {
- &self.reporting_mode
- }
}
diff --git a/ci-bench/src/main.rs b/ci-bench/src/main.rs
index 88a979ff..fd73d78f 100644
--- a/ci-bench/src/main.rs
+++ b/ci-bench/src/main.rs
@@ -420,27 +420,15 @@ fn add_benchmark_group(benchmarks: &mut Vec<Benchmark>, params: BenchmarkParams)
params.clone(),
);
- let handshake_bench = if resumption_param != ResumptionKind::No {
- // Since resumed handshakes include a first non-resumed handshake, we need to subtract
- // the non-resumed handshake's instructions
- handshake_bench
- .exclude_setup_instructions(format!("handshake_no_resume_{params_label}"))
- } else {
- handshake_bench
- };
-
benchmarks.push(handshake_bench);
}
// Benchmark data transfer
- benchmarks.push(
- Benchmark::new(
- format!("transfer_no_resume_{params_label}"),
- BenchmarkKind::Transfer,
- params.clone(),
- )
- .exclude_setup_instructions(format!("handshake_no_resume_{params_label}")),
- );
+ benchmarks.push(Benchmark::new(
+ format!("transfer_no_resume_{params_label}"),
+ BenchmarkKind::Transfer,
+ params.clone(),
+ ));
}
/// Run all the provided benches under callgrind to retrieve their instruction count