perf: Fixes (#38935)

Release Notes:

- N/A
This commit is contained in:
Nia 2025-09-26 07:41:06 +02:00 committed by GitHub
parent b1528601cc
commit bcc8149263
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 8 deletions

View file

@ -5,7 +5,8 @@ rustflags = ["-C", "symbol-mangling-version=v0", "--cfg", "tokio_unstable"]
[alias]
xtask = "run --package xtask --"
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\"]"]
perf-compare = ["run", "--release", "-p", "perf", "--", "compare"]
# Keep similar flags here to share some ccache
perf-compare = ["run", "--profile", "release-fast", "-p", "perf", "--config", "target.'cfg(true)'.rustflags=[\"--cfg\", \"perf_enabled\"]", "--", "compare"]
[target.'cfg(target_os = "windows")']
rustflags = [

View file

@ -261,8 +261,8 @@ impl Output {
// Only compare categories where both meow
// runs have data. /
let mut other_data = other_categories.remove(&cat)?;
let mut max = 0.;
let mut min = 0.;
let mut max = f64::MIN;
let mut min = f64::MAX;
// Running totals for averaging out tests.
let mut r_total_numerator = 0.;
@ -284,10 +284,15 @@ impl Output {
r_total_numerator += shift * f64::from(weight);
r_total_denominator += u32::from(weight);
}
let mean = r_total_numerator / f64::from(r_total_denominator);
// TODO: also aggregate standard deviation? That's harder to keep
// meaningful, though, since we dk which tests are correlated.
Some((cat, PerfDelta { max, mean, min }))
// There were no runs here!
if r_total_denominator == 0 {
None
} else {
let mean = r_total_numerator / f64::from(r_total_denominator);
// TODO: also aggregate standard deviation? That's harder to keep
// meaningful, though, since we dk which tests are correlated.
Some((cat, PerfDelta { max, mean, min }))
}
})
.collect();

View file

@ -93,7 +93,10 @@ impl OutputKind<'_> {
match self {
OutputKind::Markdown => print!("{output}"),
OutputKind::Json(ident) => {
let wspace_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
// We're going to be in tooling/perf/$whatever.
let wspace_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap())
.join("..")
.join("..");
let runs_dir = PathBuf::from(&wspace_dir).join(consts::RUNS_DIR);
std::fs::create_dir_all(&runs_dir).unwrap();
assert!(