Skip to content

Commit 978969b

Browse files
authored
Merge pull request #280 from lqd/perf-builds
Fix bisecting into rollups via unrolled perf builds
2 parents 79db57e + f869578 commit 978969b

File tree

3 files changed

+105
-18
lines changed

3 files changed

+105
-18
lines changed

Cargo.lock

+9-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ tempfile = "3"
3636
xz2 = "0.1.7"
3737
chrono = "0.4.22"
3838
colored = "2"
39+
regex = "1.8.4"
3940

4041
[dev-dependencies]
4142
quickcheck = "1"

src/main.rs

+95-10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use clap::{ArgAction, Parser, ValueEnum};
1919
use colored::Colorize;
2020
use github::get_pr_comments;
2121
use log::debug;
22+
use regex::RegexBuilder;
2223
use reqwest::blocking::Client;
2324

2425
mod git;
@@ -1200,16 +1201,7 @@ impl Config {
12001201
.filter(|c| c.user.login == "rust-timer")
12011202
.find(|c| c.body.contains("Perf builds for each rolled up PR"))
12021203
.context("couldn't find perf build comment")?;
1203-
let builds = perf_comment
1204-
.body
1205-
.lines()
1206-
// lines of table with PR builds
1207-
.filter(|l| l.starts_with("|#"))
1208-
// get the commit link
1209-
.filter_map(|l| l.split('|').nth(2))
1210-
// get the commit sha
1211-
.map(|l| l.split_once('[').unwrap().1.rsplit_once(']').unwrap().0)
1212-
.collect::<Vec<_>>();
1204+
let builds = extract_perf_shas(&perf_comment.body)?;
12131205
let short_sha = builds
12141206
.iter()
12151207
.map(|sha| sha.chars().take(8).collect())
@@ -1272,6 +1264,29 @@ fn main() {
12721264
}
12731265
}
12741266

1267+
/// Extracts the commits posted by the rust-timer bot on rollups, for unrolled perf builds.
1268+
///
1269+
/// We're looking for a commit sha, in a comment whose format has changed (and could change in the
1270+
/// future), for example:
1271+
/// - v1: https://github.com/rust-lang/rust/pull/113014#issuecomment-1605868471
1272+
/// - v2, the current: https://github.com/rust-lang/rust/pull/113105#issuecomment-1610393473
1273+
///
1274+
/// The sha comes in later columns, so we'll look for a 40-char hex string and give priority to the
1275+
/// last we find (to avoid possible conflicts with commits in the PR title column).
1276+
fn extract_perf_shas(body: &str) -> anyhow::Result<Vec<&str>> {
1277+
let sha_regex = RegexBuilder::new(r"([0-9a-f]{40})")
1278+
.case_insensitive(true)
1279+
.build()?;
1280+
let builds = body
1281+
.lines()
1282+
// lines of table with PR builds
1283+
.filter(|l| l.starts_with("|#"))
1284+
// get the last sha we find, to prioritize the 3rd or 2nd columns.
1285+
.filter_map(|l| sha_regex.find_iter(l).last().and_then(|m| Some(m.as_str())))
1286+
.collect();
1287+
Ok(builds)
1288+
}
1289+
12751290
#[cfg(test)]
12761291
mod tests {
12771292
use super::*;
@@ -1339,4 +1354,74 @@ mod tests {
13391354
validate_dir(main).unwrap_err()
13401355
)
13411356
}
1357+
1358+
// Ensure the first version of the comment posted by the perf-bot works
1359+
#[test]
1360+
fn test_perf_builds_v1_format() {
1361+
// Body extracted from this v1 comment
1362+
// https://github.com/rust-lang/rust/pull/113014#issuecomment-1605868471
1363+
let body = "📌 Perf builds for each rolled up PR:
1364+
1365+
|PR# | Perf Build Sha|
1366+
|----|:-----:|
1367+
|#113009|[05b07dad146a6d43ead9bcd1e8bc10cbd017a5f5](https://github.com/rust-lang-ci/rust/commit/05b07dad146a6d43ead9bcd1e8bc10cbd017a5f5)|
1368+
|#113008|[581913b6789370def5158093b799baa6d4d875eb](https://github.com/rust-lang-ci/rust/commit/581913b6789370def5158093b799baa6d4d875eb)|
1369+
|#112956|[e294bd3827eb2e878167329648f3c8178ef344e7](https://github.com/rust-lang-ci/rust/commit/e294bd3827eb2e878167329648f3c8178ef344e7)|
1370+
|#112950|[0ed6ba504649ca1cb2672572b4ab41acfb06c86c](https://github.com/rust-lang-ci/rust/commit/0ed6ba504649ca1cb2672572b4ab41acfb06c86c)|
1371+
|#112937|[18e108ab85b78e6966c5b5bdadfd5b8efeadf080](https://github.com/rust-lang-ci/rust/commit/18e108ab85b78e6966c5b5bdadfd5b8efeadf080)|
1372+
1373+
1374+
*previous master*: [f7ca9df695](https://github.com/rust-lang-ci/rust/commit/f7ca9df69549470541fbf542f87a03eb9ed024b6)
1375+
1376+
In the case of a perf regression, run the following command for each PR you suspect might be the cause: `@rust-timer build $SHA`
1377+
<!-- rust-timer: rollup -->";
1378+
assert_eq!(
1379+
vec![
1380+
"05b07dad146a6d43ead9bcd1e8bc10cbd017a5f5",
1381+
"581913b6789370def5158093b799baa6d4d875eb",
1382+
"e294bd3827eb2e878167329648f3c8178ef344e7",
1383+
"0ed6ba504649ca1cb2672572b4ab41acfb06c86c",
1384+
"18e108ab85b78e6966c5b5bdadfd5b8efeadf080",
1385+
],
1386+
extract_perf_shas(body).expect("extracting perf builds on v1 format failed"),
1387+
);
1388+
}
1389+
1390+
// Ensure the second version of the comment posted by the perf-bot works
1391+
#[test]
1392+
fn test_perf_builds_v2_format() {
1393+
// Body extracted from this v2 comment
1394+
// https://github.com/rust-lang/rust/pull/113105#issuecomment-1610393473
1395+
let body = "📌 Perf builds for each rolled up PR:
1396+
1397+
| PR# | Message | Perf Build Sha |
1398+
|----|----|:-----:|
1399+
|#112207|Add trustzone and virtualization target features for aarch3…|`bbec6d6e413aa144c8b9346da27a0f2af299cbeb` ([link](https://github.com/rust-lang-ci/rust/commit/bbec6d6e413aa144c8b9346da27a0f2af299cbeb))|
1400+
|#112454|Make compiletest aware of targets without dynamic linking|`70b67c09ead52f4582471650202b1a189821ed5f` ([link](https://github.com/rust-lang-ci/rust/commit/70b67c09ead52f4582471650202b1a189821ed5f))|
1401+
|#112628|Allow comparing `Box`es with different allocators|`3043f4e577f41565443f38a6a16b7a1a08b063ad` ([link](https://github.com/rust-lang-ci/rust/commit/3043f4e577f41565443f38a6a16b7a1a08b063ad))|
1402+
|#112692|Provide more context for `rustc +nightly -Zunstable-options…|`4ab6f33fd50237b105999cc6d32d85cce5dad61a` ([link](https://github.com/rust-lang-ci/rust/commit/4ab6f33fd50237b105999cc6d32d85cce5dad61a))|
1403+
|#112972|Make `UnwindAction::Continue` explicit in MIR dump|`e1df9e306054655d7d41ec1ad75ade5d76a6888d` ([link](https://github.com/rust-lang-ci/rust/commit/e1df9e306054655d7d41ec1ad75ade5d76a6888d))|
1404+
|#113020|Add tests impl via obj unless denied|`affe009b94eba41777cf02997b1780e50445d6af` ([link](https://github.com/rust-lang-ci/rust/commit/affe009b94eba41777cf02997b1780e50445d6af))|
1405+
|#113084|Simplify some conditions|`0ce4618dbf5810aabb389edd4950c060b6b4d049` ([link](https://github.com/rust-lang-ci/rust/commit/0ce4618dbf5810aabb389edd4950c060b6b4d049))|
1406+
|#113103|Normalize types when applying uninhabited predicate.|`241cd8cd818cdc865cdf02f0c32a40081420b772` ([link](https://github.com/rust-lang-ci/rust/commit/241cd8cd818cdc865cdf02f0c32a40081420b772))|
1407+
1408+
1409+
*previous master*: [5ea6668646](https://github.com/rust-lang-ci/rust/commit/5ea66686467d3ec5f8c81570e7f0f16ad8dd8cc3)
1410+
1411+
In the case of a perf regression, run the following command for each PR you suspect might be the cause: `@rust-timer build $SHA`
1412+
<!-- rust-timer: rollup -->";
1413+
assert_eq!(
1414+
vec![
1415+
"bbec6d6e413aa144c8b9346da27a0f2af299cbeb",
1416+
"70b67c09ead52f4582471650202b1a189821ed5f",
1417+
"3043f4e577f41565443f38a6a16b7a1a08b063ad",
1418+
"4ab6f33fd50237b105999cc6d32d85cce5dad61a",
1419+
"e1df9e306054655d7d41ec1ad75ade5d76a6888d",
1420+
"affe009b94eba41777cf02997b1780e50445d6af",
1421+
"0ce4618dbf5810aabb389edd4950c060b6b4d049",
1422+
"241cd8cd818cdc865cdf02f0c32a40081420b772",
1423+
],
1424+
extract_perf_shas(body).expect("extracting perf builds on v2 format failed"),
1425+
);
1426+
}
13421427
}

0 commit comments

Comments
 (0)