Skip to content

Commit 35a5e64

Browse files
committed
Remove bench_test, add install_next.
`install_next` + `bench_local` can now be used to do what `bench_test` previously did. This combination is better because it gives `bench_local` test coverage. This required adding a `preserve()` method to `Sysroot`, so that an installed toolchain could be preserved between `install_next` and `bench_local`.
1 parent cd37051 commit 35a5e64

File tree

4 files changed

+53
-54
lines changed

4 files changed

+53
-54
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- name: Check benchmarks
6060
run: sh -x -c "ci/check-benchmarks.sh"
6161
env:
62-
BENCH_TEST_OPTS: "--exclude script-servo"
62+
BENCH_INCLUDE_EXCLUDE_OPTS: "--exclude script-servo"
6363
test_script_servo:
6464
name: Test benchmark script-servo
6565
runs-on: ubuntu-latest
@@ -90,5 +90,5 @@ jobs:
9090
- name: Check benchmarks
9191
run: sh -x -c "ci/check-benchmarks.sh"
9292
env:
93-
BENCH_TEST_OPTS: "--include script-servo"
93+
BENCH_INCLUDE_EXCLUDE_OPTS: "--include script-servo"
9494
SHELL: "/bin/bash"

ci/check-benchmarks.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ set -x;
55
bash -c "while true; do sleep 30; echo \$(date) - running ...; done" &
66
PING_LOOP_PID=$!
77
trap - ERR
8+
RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot=debug \
9+
bindir=`cargo run -p collector --bin collector install_next` \
10+
&& \
811
RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot=debug \
912
cargo run -p collector --bin collector -- \
10-
bench_test $BENCH_TEST_OPTS
13+
bench_local $bindir/rustc Test \
14+
--builds Check,Doc \
15+
--cargo $bindir/cargo \
16+
--runs All \
17+
--rustdoc $bindir/rustdoc \
18+
$BENCH_INCLUDE_EXCLUDE_OPTS
1119
code=$?
1220
kill $PING_LOOP_PID
1321
exit $code

collector/src/main.rs

Lines changed: 33 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -473,17 +473,6 @@ fn main_result() -> anyhow::Result<i32> {
473473
(@arg DB: --db +takes_value "Database output file")
474474
)
475475

476-
(@subcommand bench_test =>
477-
(about: "Benchmarks the most recent commit for testing purposes")
478-
479-
// Mandatory arguments: (none)
480-
481-
// Options
482-
(@arg DB: --db +takes_value "Database output file")
483-
(@arg EXCLUDE: --exclude +takes_value "Exclude benchmarks matching these")
484-
(@arg INCLUDE: --include +takes_value "Include benchmarks matching these")
485-
)
486-
487476
(@subcommand profile_local =>
488477
(about: "Profiles a local rustc with one of several profilers")
489478

@@ -507,6 +496,14 @@ fn main_result() -> anyhow::Result<i32> {
507496
'IncrFull', 'IncrUnchanged', 'IncrPatched', 'All'")
508497
(@arg RUSTDOC: --rustdoc +takes_value "The path to the local rustdoc to benchmark")
509498
)
499+
500+
(@subcommand install_next =>
501+
(about: "Installs the next commit for perf.rust-lang.org")
502+
503+
// Mandatory arguments: (none)
504+
505+
// Options: (none)
506+
)
510507
)
511508
.get_matches();
512509

@@ -694,46 +691,6 @@ fn main_result() -> anyhow::Result<i32> {
694691
Ok(0)
695692
}
696693

697-
("bench_test", Some(sub_m)) => {
698-
// Mandatory arguments: (none)
699-
700-
// Options
701-
let db = sub_m.value_of("DB").unwrap_or(default_db);
702-
let exclude = sub_m.value_of("EXCLUDE");
703-
let include = sub_m.value_of("INCLUDE");
704-
705-
let pool = database::Pool::open(db);
706-
let conn = rt.block_on(pool.connection());
707-
708-
let last_sha = Command::new("git")
709-
.arg("ls-remote")
710-
.arg("https://github.com/rust-lang/rust.git")
711-
.arg("master")
712-
.output()
713-
.unwrap();
714-
let last_sha = String::from_utf8(last_sha.stdout).expect("utf8");
715-
let last_sha = last_sha.split_whitespace().next().expect(&last_sha);
716-
let commit = get_commit_or_fake_it(&last_sha).expect("success");
717-
let sysroot = Sysroot::install(commit.sha.to_string(), "x86_64-unknown-linux-gnu")?;
718-
719-
let benchmarks = get_benchmarks(&benchmark_dir, include, exclude)?;
720-
721-
let res = bench(
722-
&mut rt,
723-
conn,
724-
&ArtifactId::Commit(commit),
725-
&[BuildKind::Check, BuildKind::Doc], // no Debug or Opt builds
726-
&RunKind::all(),
727-
Compiler::from_sysroot(&sysroot),
728-
&benchmarks,
729-
1,
730-
/* call_home */ false,
731-
/* self_profile */ false,
732-
);
733-
res.fail_if_nonzero()?;
734-
Ok(0)
735-
}
736-
737694
("profile_local", Some(sub_m)) => {
738695
// Mandatory arguments
739696
let profiler = Profiler::from_name(sub_m.value_of("PROFILER").unwrap())?;
@@ -781,6 +738,31 @@ fn main_result() -> anyhow::Result<i32> {
781738
Ok(0)
782739
}
783740

741+
("install_next", Some(_sub_m)) => {
742+
// Mandatory arguments: (none)
743+
744+
// Options: (none)
745+
746+
let last_sha = Command::new("git")
747+
.arg("ls-remote")
748+
.arg("https://github.com/rust-lang/rust.git")
749+
.arg("master")
750+
.output()
751+
.unwrap();
752+
let last_sha = String::from_utf8(last_sha.stdout).expect("utf8");
753+
let last_sha = last_sha.split_whitespace().next().expect(&last_sha);
754+
let commit = get_commit_or_fake_it(&last_sha).expect("success");
755+
let mut sysroot = Sysroot::install(commit.sha.to_string(), "x86_64-unknown-linux-gnu")?;
756+
sysroot.preserve(); // don't delete it
757+
758+
// Print the directory containing the toolchain.
759+
sysroot.rustc.pop();
760+
let s = format!("{:?}", sysroot.rustc);
761+
println!("{}", &s[1..s.len() - 1]);
762+
763+
Ok(0)
764+
}
765+
784766
_ => {
785767
let _ = writeln!(stderr(), "{}", matches.usage());
786768
Ok(2)

collector/src/sysroot.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub struct Sysroot {
1919
pub rustdoc: PathBuf,
2020
pub cargo: PathBuf,
2121
pub triple: String,
22+
pub preserve: bool,
2223
}
2324

2425
impl Sysroot {
@@ -42,10 +43,17 @@ impl Sysroot {
4243

4344
Ok(sysroot)
4445
}
46+
47+
pub fn preserve(&mut self) {
48+
self.preserve = true;
49+
}
4550
}
4651

4752
impl Drop for Sysroot {
4853
fn drop(&mut self) {
54+
if self.preserve {
55+
return;
56+
}
4957
fs::remove_dir_all(format!("cache/{}", self.sha)).unwrap_or_else(|err| {
5058
log::info!(
5159
"failed to remove {:?}, please do so manually: {:?}",
@@ -121,6 +129,7 @@ impl SysrootDownload {
121129
cargo: sysroot_bin("cargo")?,
122130
sha: self.rust_sha,
123131
triple: self.triple,
132+
preserve: false,
124133
})
125134
}
126135

0 commit comments

Comments
 (0)