|
2 | 2 |
|
3 | 3 | use anyhow::{bail, Context};
|
4 | 4 | use clap::Parser;
|
| 5 | +use collector::api::next_artifact::NextArtifact; |
5 | 6 | use collector::category::Category;
|
6 |
| -use database::{ArtifactId, Commit, CommitType}; |
| 7 | +use database::{ArtifactId, Commit, CommitType, Pool}; |
7 | 8 | use log::debug;
|
8 | 9 | use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
|
9 | 10 | use std::collections::HashMap;
|
@@ -834,7 +835,7 @@ enum Commands {
|
834 | 835 | self_profile: SelfProfileOption,
|
835 | 836 | },
|
836 | 837 |
|
837 |
| - /// Benchmarks the next commit for perf.rust-lang.org |
| 838 | + /// Benchmarks the next commit or release for perf.rust-lang.org |
838 | 839 | BenchNext {
|
839 | 840 | /// Site URL
|
840 | 841 | site_url: String,
|
@@ -995,113 +996,64 @@ fn main_result() -> anyhow::Result<i32> {
|
995 | 996 | bench_rustc,
|
996 | 997 | self_profile,
|
997 | 998 | } => {
|
998 |
| - println!("processing commits"); |
| 999 | + println!("processing artifacts"); |
999 | 1000 | let client = reqwest::blocking::Client::new();
|
1000 |
| - let response: collector::api::next_commit::Response = client |
1001 |
| - .get(&format!("{}/perf/next_commit", site_url)) |
| 1001 | + let response: collector::api::next_artifact::Response = client |
| 1002 | + .get(&format!("{}/perf/next_artifact", site_url)) |
1002 | 1003 | .send()?
|
1003 | 1004 | .json()?;
|
1004 |
| - let next = if let Some(c) = response.commit { |
| 1005 | + let next = if let Some(c) = response.artifact { |
1005 | 1006 | c
|
1006 | 1007 | } else {
|
1007 |
| - println!("no commit to benchmark"); |
1008 |
| - // no missing commits |
| 1008 | + println!("no artifact to benchmark"); |
| 1009 | + // no missing artifacts |
1009 | 1010 | return Ok(0);
|
1010 | 1011 | };
|
1011 | 1012 |
|
1012 | 1013 | let pool = database::Pool::open(&db.db);
|
1013 | 1014 |
|
1014 |
| - let sysroot = Sysroot::install(next.commit.sha.to_string(), &target_triple) |
1015 |
| - .with_context(|| format!("failed to install sysroot for {:?}", next.commit))?; |
1016 |
| - |
1017 |
| - let mut benchmarks = get_benchmarks( |
1018 |
| - &benchmark_dir, |
1019 |
| - next.include.as_deref(), |
1020 |
| - next.exclude.as_deref(), |
1021 |
| - )?; |
1022 |
| - benchmarks.retain(|b| b.category().is_primary_or_secondary()); |
| 1015 | + match next { |
| 1016 | + NextArtifact::Release(tag) => { |
| 1017 | + bench_published_artifact(tag, pool, &mut rt, &target_triple, &benchmark_dir)?; |
| 1018 | + } |
| 1019 | + NextArtifact::Commit { |
| 1020 | + commit, |
| 1021 | + include, |
| 1022 | + exclude, |
| 1023 | + runs, |
| 1024 | + } => { |
| 1025 | + let sysroot = Sysroot::install(commit.sha.to_string(), &target_triple) |
| 1026 | + .with_context(|| format!("failed to install sysroot for {:?}", commit))?; |
| 1027 | + |
| 1028 | + let mut benchmarks = |
| 1029 | + get_benchmarks(&benchmark_dir, include.as_deref(), exclude.as_deref())?; |
| 1030 | + benchmarks.retain(|b| b.category().is_primary_or_secondary()); |
| 1031 | + |
| 1032 | + let res = bench( |
| 1033 | + &mut rt, |
| 1034 | + pool, |
| 1035 | + &ArtifactId::Commit(commit), |
| 1036 | + &Profile::all(), |
| 1037 | + &Scenario::all(), |
| 1038 | + bench_rustc.bench_rustc, |
| 1039 | + Compiler::from_sysroot(&sysroot), |
| 1040 | + &benchmarks, |
| 1041 | + runs.map(|v| v as usize), |
| 1042 | + self_profile.self_profile, |
| 1043 | + ); |
1023 | 1044 |
|
1024 |
| - let res = bench( |
1025 |
| - &mut rt, |
1026 |
| - pool, |
1027 |
| - &ArtifactId::Commit(next.commit), |
1028 |
| - &Profile::all(), |
1029 |
| - &Scenario::all(), |
1030 |
| - bench_rustc.bench_rustc, |
1031 |
| - Compiler::from_sysroot(&sysroot), |
1032 |
| - &benchmarks, |
1033 |
| - next.runs.map(|v| v as usize), |
1034 |
| - self_profile.self_profile, |
1035 |
| - ); |
| 1045 | + client.post(&format!("{}/perf/onpush", site_url)).send()?; |
1036 | 1046 |
|
1037 |
| - client.post(&format!("{}/perf/onpush", site_url)).send()?; |
| 1047 | + res.fail_if_nonzero()?; |
| 1048 | + } |
| 1049 | + } |
1038 | 1050 |
|
1039 |
| - res.fail_if_nonzero()?; |
1040 | 1051 | Ok(0)
|
1041 | 1052 | }
|
1042 | 1053 |
|
1043 | 1054 | Commands::BenchPublished { toolchain, db } => {
|
1044 |
| - let status = Command::new("rustup") |
1045 |
| - .args(&["install", "--profile=minimal", &toolchain]) |
1046 |
| - .status() |
1047 |
| - .context("rustup install")?; |
1048 |
| - if !status.success() { |
1049 |
| - anyhow::bail!("failed to install toolchain for {}", toolchain); |
1050 |
| - } |
1051 |
| - |
1052 | 1055 | let pool = database::Pool::open(&db.db);
|
1053 |
| - |
1054 |
| - let profiles = if collector::version_supports_doc(&toolchain) { |
1055 |
| - Profile::all() |
1056 |
| - } else { |
1057 |
| - Profile::all_non_doc() |
1058 |
| - }; |
1059 |
| - let scenarios = if collector::version_supports_incremental(&toolchain) { |
1060 |
| - Scenario::all() |
1061 |
| - } else { |
1062 |
| - Scenario::all_non_incr() |
1063 |
| - }; |
1064 |
| - |
1065 |
| - let which = |tool| { |
1066 |
| - String::from_utf8( |
1067 |
| - Command::new("rustup") |
1068 |
| - .arg("which") |
1069 |
| - .arg("--toolchain") |
1070 |
| - .arg(&toolchain) |
1071 |
| - .arg(tool) |
1072 |
| - .output() |
1073 |
| - .context(format!("rustup which {}", tool))? |
1074 |
| - .stdout, |
1075 |
| - ) |
1076 |
| - .context("utf8") |
1077 |
| - }; |
1078 |
| - let rustc = which("rustc")?; |
1079 |
| - let rustdoc = which("rustdoc")?; |
1080 |
| - let cargo = which("cargo")?; |
1081 |
| - |
1082 |
| - // Exclude benchmarks that don't work with a stable compiler. |
1083 |
| - let mut benchmarks = get_benchmarks(&benchmark_dir, None, None)?; |
1084 |
| - benchmarks.retain(|b| b.category().is_stable()); |
1085 |
| - |
1086 |
| - let res = bench( |
1087 |
| - &mut rt, |
1088 |
| - pool, |
1089 |
| - &ArtifactId::Tag(toolchain), |
1090 |
| - &profiles, |
1091 |
| - &scenarios, |
1092 |
| - /* bench_rustc */ false, |
1093 |
| - Compiler { |
1094 |
| - rustc: Path::new(rustc.trim()), |
1095 |
| - rustdoc: Some(Path::new(rustdoc.trim())), |
1096 |
| - cargo: Path::new(cargo.trim()), |
1097 |
| - is_nightly: false, |
1098 |
| - triple: &target_triple, |
1099 |
| - }, |
1100 |
| - &benchmarks, |
1101 |
| - Some(3), |
1102 |
| - /* is_self_profile */ false, |
1103 |
| - ); |
1104 |
| - res.fail_if_nonzero()?; |
| 1056 | + bench_published_artifact(toolchain, pool, &mut rt, &target_triple, &benchmark_dir)?; |
1105 | 1057 | Ok(0)
|
1106 | 1058 | }
|
1107 | 1059 |
|
@@ -1248,6 +1200,75 @@ fn main_result() -> anyhow::Result<i32> {
|
1248 | 1200 | }
|
1249 | 1201 | }
|
1250 | 1202 |
|
| 1203 | +fn bench_published_artifact( |
| 1204 | + toolchain: String, |
| 1205 | + pool: Pool, |
| 1206 | + rt: &mut Runtime, |
| 1207 | + target_triple: &str, |
| 1208 | + benchmark_dir: &Path, |
| 1209 | +) -> anyhow::Result<()> { |
| 1210 | + let status = Command::new("rustup") |
| 1211 | + .args(&["install", "--profile=minimal", &toolchain]) |
| 1212 | + .status() |
| 1213 | + .context("rustup install")?; |
| 1214 | + if !status.success() { |
| 1215 | + anyhow::bail!("failed to install toolchain for {}", toolchain); |
| 1216 | + } |
| 1217 | + |
| 1218 | + let profiles = if collector::version_supports_doc(&toolchain) { |
| 1219 | + Profile::all() |
| 1220 | + } else { |
| 1221 | + Profile::all_non_doc() |
| 1222 | + }; |
| 1223 | + let scenarios = if collector::version_supports_incremental(&toolchain) { |
| 1224 | + Scenario::all() |
| 1225 | + } else { |
| 1226 | + Scenario::all_non_incr() |
| 1227 | + }; |
| 1228 | + |
| 1229 | + let which = |tool| { |
| 1230 | + String::from_utf8( |
| 1231 | + Command::new("rustup") |
| 1232 | + .arg("which") |
| 1233 | + .arg("--toolchain") |
| 1234 | + .arg(&toolchain) |
| 1235 | + .arg(tool) |
| 1236 | + .output() |
| 1237 | + .context(format!("rustup which {}", tool))? |
| 1238 | + .stdout, |
| 1239 | + ) |
| 1240 | + .context("utf8") |
| 1241 | + }; |
| 1242 | + let rustc = which("rustc")?; |
| 1243 | + let rustdoc = which("rustdoc")?; |
| 1244 | + let cargo = which("cargo")?; |
| 1245 | + |
| 1246 | + // Exclude benchmarks that don't work with a stable compiler. |
| 1247 | + let mut benchmarks = get_benchmarks(&benchmark_dir, None, None)?; |
| 1248 | + benchmarks.retain(|b| b.category().is_stable()); |
| 1249 | + |
| 1250 | + let res = bench( |
| 1251 | + rt, |
| 1252 | + pool, |
| 1253 | + &ArtifactId::Tag(toolchain), |
| 1254 | + &profiles, |
| 1255 | + &scenarios, |
| 1256 | + /* bench_rustc */ false, |
| 1257 | + Compiler { |
| 1258 | + rustc: Path::new(rustc.trim()), |
| 1259 | + rustdoc: Some(Path::new(rustdoc.trim())), |
| 1260 | + cargo: Path::new(cargo.trim()), |
| 1261 | + is_nightly: false, |
| 1262 | + triple: &target_triple, |
| 1263 | + }, |
| 1264 | + &benchmarks, |
| 1265 | + Some(3), |
| 1266 | + /* is_self_profile */ false, |
| 1267 | + ); |
| 1268 | + res.fail_if_nonzero()?; |
| 1269 | + Ok(()) |
| 1270 | +} |
| 1271 | + |
1251 | 1272 | fn add_perf_config(directory: &PathBuf, category: Category) {
|
1252 | 1273 | let data = serde_json::json!({
|
1253 | 1274 | "category": category.to_string()
|
|
0 commit comments