Skip to content

Commit bcc8149

Browse files
authored
perf: Fixes (#38935)
Release Notes: - N/A
1 parent b152860 commit bcc8149

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

.cargo/config.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ rustflags = ["-C", "symbol-mangling-version=v0", "--cfg", "tokio_unstable"]
55
[alias]
66
xtask = "run --package xtask --"
77
perf-test = ["test", "--profile", "release-fast", "--lib", "--bins", "--tests", "--all-features", "--config", "target.'cfg(true)'.runner='cargo run -p perf --release'", "--config", "target.'cfg(true)'.rustflags=[\"--cfg\", \"perf_enabled\"]"]
8-
perf-compare = ["run", "--release", "-p", "perf", "--", "compare"]
8+
# Keep similar flags here to share some ccache
9+
perf-compare = ["run", "--profile", "release-fast", "-p", "perf", "--config", "target.'cfg(true)'.rustflags=[\"--cfg\", \"perf_enabled\"]", "--", "compare"]
910

1011
[target.'cfg(target_os = "windows")']
1112
rustflags = [

tooling/perf/src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ impl Output {
261261
// Only compare categories where both meow
262262
// runs have data. /
263263
let mut other_data = other_categories.remove(&cat)?;
264-
let mut max = 0.;
265-
let mut min = 0.;
264+
let mut max = f64::MIN;
265+
let mut min = f64::MAX;
266266

267267
// Running totals for averaging out tests.
268268
let mut r_total_numerator = 0.;
@@ -284,10 +284,15 @@ impl Output {
284284
r_total_numerator += shift * f64::from(weight);
285285
r_total_denominator += u32::from(weight);
286286
}
287-
let mean = r_total_numerator / f64::from(r_total_denominator);
288-
// TODO: also aggregate standard deviation? That's harder to keep
289-
// meaningful, though, since we dk which tests are correlated.
290-
Some((cat, PerfDelta { max, mean, min }))
287+
// There were no runs here!
288+
if r_total_denominator == 0 {
289+
None
290+
} else {
291+
let mean = r_total_numerator / f64::from(r_total_denominator);
292+
// TODO: also aggregate standard deviation? That's harder to keep
293+
// meaningful, though, since we dk which tests are correlated.
294+
Some((cat, PerfDelta { max, mean, min }))
295+
}
291296
})
292297
.collect();
293298

tooling/perf/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ impl OutputKind<'_> {
9393
match self {
9494
OutputKind::Markdown => print!("{output}"),
9595
OutputKind::Json(ident) => {
96-
let wspace_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
96+
// We're going to be in tooling/perf/$whatever.
97+
let wspace_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap())
98+
.join("..")
99+
.join("..");
97100
let runs_dir = PathBuf::from(&wspace_dir).join(consts::RUNS_DIR);
98101
std::fs::create_dir_all(&runs_dir).unwrap();
99102
assert!(

0 commit comments

Comments
 (0)