Skip to content

Commit 81ddb42

Browse files
Merge pull request #1140 from nnethercote/overhaul-rustc-benchmark
Overhaul how the `rustc` benchmark works.
2 parents f2d9af4 + d013f6d commit 81ddb42

File tree

6 files changed

+121
-87
lines changed

6 files changed

+121
-87
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ jobs:
6464
strategy:
6565
matrix:
6666
BENCH_INCLUDE_EXCLUDE_OPTS: [
67-
"--exclude webrender-wrench,style-servo,cargo,rustc",
68-
"--include webrender-wrench,style-servo,cargo --exclude rustc",
67+
"--exclude webrender-wrench,style-servo,cargo",
68+
"--include webrender-wrench,style-servo,cargo",
6969
]
7070
PROFILE_KINDS: [
7171
"Check,Doc,Debug",

collector/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ The following options alter the behaviour of the `bench_local` subcommand.
107107
comma-separated list of benchmark names. When this option is specified, a
108108
benchmark is included in the run only if its name matches one or more of the
109109
given names.
110+
- `--bench-rustc`: there is a special `rustc` benchmark that involves
111+
downloading a recent Rust compiler and measuring the time taken to compile
112+
it. This benchmark works very differently to all the other benchmarks. For
113+
example, `--runs` and `--builds` don't affect it, and the given `ID` is used
114+
as the `rust-lang/rust` ref (falling back to `HEAD` if the `ID` is not a
115+
valid ref). It is for advanced and CI use only. This option enables it.
110116
- `--runs $RUNS`: the run kinds to be benchmarked. The possible choices are one
111117
or more (comma-separated) of `Full`, `IncrFull`, `IncrUnchanged`,
112118
`IncrPatched`, and `All`. The default is `All`. Note that `IncrFull` is

collector/collect.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ while : ; do
2626
rm todo-artifacts
2727
touch todo-artifacts
2828

29-
target/release/collector bench_next $SITE_URL --self-profile --db $DATABASE;
29+
target/release/collector bench_next $SITE_URL --self-profile --bench-rustc --db $DATABASE;
3030
echo finished run at `date`;
3131
done

collector/src/execute.rs

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -571,13 +571,9 @@ pub trait Processor {
571571
fn finished_first_collection(&mut self, _: ProfileKind) -> bool {
572572
false
573573
}
574-
575-
fn measure_rustc(&mut self, _: Compiler<'_>) -> anyhow::Result<()> {
576-
Ok(())
577-
}
578574
}
579575

580-
pub struct MeasureProcessor<'a> {
576+
pub struct BenchProcessor<'a> {
581577
rt: &'a mut Runtime,
582578
benchmark: &'a BenchmarkName,
583579
conn: &'a mut dyn database::Connection,
@@ -589,7 +585,7 @@ pub struct MeasureProcessor<'a> {
589585
tries: u8,
590586
}
591587

592-
impl<'a> MeasureProcessor<'a> {
588+
impl<'a> BenchProcessor<'a> {
593589
pub fn new(
594590
rt: &'a mut Runtime,
595591
conn: &'a mut dyn database::Connection,
@@ -615,7 +611,7 @@ impl<'a> MeasureProcessor<'a> {
615611
assert!(has_tracelog);
616612
}
617613

618-
MeasureProcessor {
614+
BenchProcessor {
619615
rt,
620616
upload: None,
621617
conn,
@@ -722,6 +718,16 @@ impl<'a> MeasureProcessor<'a> {
722718
self.rt
723719
.block_on(async move { while let Some(()) = buf.next().await {} });
724720
}
721+
722+
pub fn measure_rustc(&mut self, compiler: Compiler<'_>) -> anyhow::Result<()> {
723+
rustc::measure(
724+
self.rt,
725+
self.conn,
726+
compiler,
727+
self.artifact,
728+
self.artifact_row_id,
729+
)
730+
}
725731
}
726732

727733
struct Upload(std::process::Child, tempfile::NamedTempFile);
@@ -812,7 +818,7 @@ impl Upload {
812818
}
813819
}
814820

815-
impl<'a> Processor for MeasureProcessor<'a> {
821+
impl<'a> Processor for BenchProcessor<'a> {
816822
fn profiler(&self, _profile: ProfileKind) -> Profiler {
817823
if self.is_first_collection && self.is_self_profile {
818824
if cfg!(unix) {
@@ -897,16 +903,6 @@ impl<'a> Processor for MeasureProcessor<'a> {
897903
}
898904
}
899905
}
900-
901-
fn measure_rustc(&mut self, compiler: Compiler<'_>) -> anyhow::Result<()> {
902-
rustc::measure(
903-
self.rt,
904-
self.conn,
905-
compiler,
906-
self.artifact,
907-
self.artifact_row_id,
908-
)
909-
}
910906
}
911907

912908
pub struct ProfileProcessor<'a> {
@@ -1231,15 +1227,6 @@ impl<'a> Processor for ProfileProcessor<'a> {
12311227

12321228
impl Benchmark {
12331229
pub fn new(name: String, path: PathBuf) -> anyhow::Result<Self> {
1234-
if name == "rustc" {
1235-
return Ok(Benchmark {
1236-
name: BenchmarkName(name),
1237-
path,
1238-
patches: vec![],
1239-
config: BenchmarkConfig::default(),
1240-
});
1241-
}
1242-
12431230
let mut patches = vec![];
12441231
for entry in fs::read_dir(&path)? {
12451232
let entry = entry?;
@@ -1359,10 +1346,6 @@ impl Benchmark {
13591346
) -> anyhow::Result<()> {
13601347
let iterations = iterations.unwrap_or(self.config.runs);
13611348

1362-
if self.name.0 == "rustc" {
1363-
return processor.measure_rustc(compiler).context("measure rustc");
1364-
}
1365-
13661349
if self.config.disabled || profile_kinds.is_empty() {
13671350
eprintln!("Skipping {}: disabled", self.name);
13681351
bail!("disabled benchmark");

collector/src/execute/rustc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ use std::{collections::HashMap, process::Command};
1515
use std::{path::Path, time::Duration};
1616
use tokio::runtime::Runtime;
1717

18+
/// Measure the special rustc benchmark.
1819
pub fn measure(
1920
rt: &mut Runtime,
2021
conn: &mut dyn database::Connection,
2122
compiler: Compiler<'_>,
2223
artifact: &database::ArtifactId,
2324
aid: database::ArtifactIdNumber,
2425
) -> anyhow::Result<()> {
26+
eprintln!("Running rustc");
27+
2528
checkout(&artifact).context("checking out rust-lang/rust")?;
2629

2730
record(rt, conn, compiler, artifact, aid)?;

0 commit comments

Comments
 (0)