Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

perf: Fixes (#38935)

Niabcc814926361
diff --git a/.cargo/config.toml b/.cargo/config.toml
index 7073c6db55e..9b2e6f51c96 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -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 = [
diff --git a/tooling/perf/src/lib.rs b/tooling/perf/src/lib.rs
index 18fc2984a69..c6d620aaeb4 100644
--- a/tooling/perf/src/lib.rs
+++ b/tooling/perf/src/lib.rs
@@ -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();
diff --git a/tooling/perf/src/main.rs b/tooling/perf/src/main.rs
index cbf14a48d83..d5be1a9d8a3 100644
--- a/tooling/perf/src/main.rs
+++ b/tooling/perf/src/main.rs
@@ -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!(