Skip to content

Commit 8d8a13c

Browse files
authored
Merge pull request #2262 from rust-lang/fix-rustc-benchmark
Fix rustc benchmark when the `rust` directory does not exist
2 parents 6c1460f + 6337896 commit 8d8a13c

File tree

1 file changed

+33
-36
lines changed

1 file changed

+33
-36
lines changed

collector/src/compile/execute/rustc.rs

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
//! Performance collection for rust-lang/rust compilation.
22
//!
3-
//! This benchmarks a x.py build --stage 0 compiler/rustc invocation on the
3+
//! This benchmarks a `x.py build compiler/rustc` invocation on the
44
//! latest master compiler.
5-
//!
6-
//! We don't run the (more typical) stage 1 library/test build because there's
7-
//! no real reason for us to compile the standard library twice, and it avoids
8-
//! having to think about how to deduplicate results.
95
106
use crate::toolchain::Toolchain;
117
use crate::utils::git::get_rustc_perf_commit;
@@ -167,43 +163,44 @@ async fn record(
167163
}
168164

169165
fn checkout(artifact: &ArtifactId) -> anyhow::Result<()> {
170-
if Path::new("rust").exists() {
171-
let mut status = Command::new("git")
172-
.current_dir("rust")
173-
.arg("fetch")
174-
.arg("origin")
175-
.arg(match artifact {
176-
ArtifactId::Commit(c) => c.sha.as_str(),
177-
ArtifactId::Tag(id) => id.as_str(),
178-
})
179-
.status()
180-
.context("git fetch origin")?;
181-
182-
if !status.success() {
183-
log::warn!(
184-
"git fetch origin {} failed, this will likely break the build",
185-
artifact
186-
);
187-
}
188-
189-
// Regardless, we fetch the default branch. Upstream Rust started using `git merge-base`
190-
// recently, which (reasonably) finds the wrong base if we think e.g. origin/master
191-
// diverged thousands of commits ago.
192-
status = Command::new("git")
193-
.current_dir("rust")
194-
.arg("fetch")
195-
.arg("origin")
196-
.arg("HEAD")
197-
.status()
198-
.context("git fetch origin HEAD")?;
199-
assert!(status.success(), "git fetch successful");
200-
} else {
166+
if !Path::new("rust").exists() {
201167
let status = Command::new("git")
202168
.arg("clone")
203169
.arg("https://github.com/rust-lang/rust")
204170
.status()
205171
.context("git clone")?;
206172
assert!(status.success(), "git clone successful");
207173
}
174+
175+
let mut status = Command::new("git")
176+
.current_dir("rust")
177+
.arg("fetch")
178+
.arg("origin")
179+
.arg(match artifact {
180+
ArtifactId::Commit(c) => c.sha.as_str(),
181+
ArtifactId::Tag(id) => id.as_str(),
182+
})
183+
.status()
184+
.context("git fetch origin")?;
185+
186+
if !status.success() {
187+
log::warn!(
188+
"git fetch origin {} failed, this will likely break the build",
189+
artifact
190+
);
191+
}
192+
193+
// Regardless, we fetch the default branch. Upstream Rust started using `git merge-base`
194+
// recently, which (reasonably) finds the wrong base if we think e.g. origin/master
195+
// diverged thousands of commits ago.
196+
status = Command::new("git")
197+
.current_dir("rust")
198+
.arg("fetch")
199+
.arg("origin")
200+
.arg("HEAD")
201+
.status()
202+
.context("git fetch origin HEAD")?;
203+
assert!(status.success(), "git fetch successful");
204+
208205
Ok(())
209206
}

0 commit comments

Comments
 (0)