Skip to content

Report errors during preparation of crates #1552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,17 @@ profilers whose results are not affected by system noise (e.g. `callgrind` or `e

`RUST_LOG=debug` can be specified to enable verbose logging, which is useful
for debugging `collector` itself.


## How `rustc` wrapping works
When a crate is benchmarked or profiled, the real `rustc` is replaced with the `rustc-fake` binary,
which parses commands passed from the `collector` and invokes the actual profiling or benchmarking
tool.

Profiling/benchmarking a crate is performed in two steps:
1) Preparation - here all dependencies are compiled and build scripts are executed.
During this step, `cargo` is invoked with `... -- --skip-this-rustc`, which causes `rustc-fake` to skip
compilation of the final/leaf crate. Cargo only passes arguments after `--` to the final crate,
therefore this does not affect the compilation of dependencies.
2) Profiling/benchmarking - `cargo` is invoked with `--wrap-rustc-with <TOOL>`, which executes the
specified profiling tool by `rustc-fake`.
7 changes: 5 additions & 2 deletions collector/src/benchmark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,18 @@ impl Benchmark {
for (profile, prep_dir) in &profile_dirs {
let server = server.clone();
s.spawn::<_, anyhow::Result<()>>(move |_| {
// Panic the thread if an error occurs to make sure that the whole scope will
// also panic if there was some error.
self.mk_cargo_process(compiler, prep_dir.path(), *profile)
.jobserver(server)
.run_rustc(false)?;
.run_rustc(false)
.unwrap();
Ok(())
});
}
Ok(())
})
.unwrap()?;
.expect("Preparation has failed")?;

for (profile, prep_dir) in profile_dirs {
eprintln!("Running {}: {:?} + {:?}", self.name, profile, scenarios);
Expand Down