-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
x perf
command for profiling the compiler using rustc-perf
- Loading branch information
Showing
10 changed files
with
301 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::process::Command; | ||
|
||
use crate::core::build_steps::compile::{Std, Sysroot}; | ||
use crate::core::build_steps::tool::RustcPerf; | ||
use crate::core::builder::Builder; | ||
use crate::core::config::DebuginfoLevel; | ||
|
||
/// Performs profiling using `rustc-perf` on a built version of the compiler. | ||
pub fn perf(builder: &Builder<'_>) { | ||
let collector = builder.ensure(RustcPerf { | ||
compiler: builder.compiler(0, builder.config.build), | ||
target: builder.config.build, | ||
}); | ||
|
||
if builder.build.config.rust_debuginfo_level_rustc == DebuginfoLevel::None { | ||
builder.info(r#"WARNING: You are compiling rustc without debuginfo, this will make profiling less useful. | ||
Consider setting `rust.debuginfo-level = 1` in `config.toml`."#); | ||
} | ||
|
||
let compiler = builder.compiler(builder.top_stage, builder.config.build); | ||
builder.ensure(Std::new(compiler, builder.config.build)); | ||
let sysroot = builder.ensure(Sysroot::new(compiler)); | ||
let rustc = sysroot.join("bin/rustc"); | ||
|
||
let results_dir = builder.build.out.join("rustc-perf"); | ||
|
||
let mut cmd = Command::new(collector); | ||
let cmd = cmd | ||
.arg("profile_local") | ||
.arg("eprintln") | ||
.arg("--out-dir") | ||
.arg(&results_dir) | ||
.arg("--include") | ||
.arg("helloworld") | ||
.arg(&rustc); | ||
|
||
builder.info(&format!("Running `rustc-perf` using `{}`", rustc.display())); | ||
|
||
// We need to set the working directory to `src/tools/perf`, so that it can find the directory | ||
// with compile-time benchmarks. | ||
let cmd = cmd.current_dir(builder.src.join("src/tools/rustc-perf")); | ||
builder.build.run(cmd); | ||
|
||
builder.info(&format!("You can find the results at `{}`", results_dir.display())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.