Use log groups in opt-dist
Some of the output was quite verbose in CI logs, this should help with that.
This commit is contained in:
parent
ffb9b61294
commit
e04b915a1d
@ -9,6 +9,7 @@
|
|||||||
use crate::utils::io::reset_directory;
|
use crate::utils::io::reset_directory;
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
clear_llvm_files, format_env_variables, print_binary_sizes, print_free_disk_space,
|
clear_llvm_files, format_env_variables, print_binary_sizes, print_free_disk_space,
|
||||||
|
with_log_group,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod environment;
|
mod environment;
|
||||||
@ -29,7 +30,8 @@ fn execute_pipeline(
|
|||||||
dist_args: Vec<String>,
|
dist_args: Vec<String>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
reset_directory(&env.opt_artifacts())?;
|
reset_directory(&env.opt_artifacts())?;
|
||||||
env.prepare_rustc_perf()?;
|
|
||||||
|
with_log_group("Building rustc-perf", || env.prepare_rustc_perf())?;
|
||||||
|
|
||||||
// Stage 1: Build PGO instrumented rustc
|
// Stage 1: Build PGO instrumented rustc
|
||||||
// We use a normal build of LLVM, because gathering PGO profiles for LLVM and `rustc` at the
|
// We use a normal build of LLVM, because gathering PGO profiles for LLVM and `rustc` at the
|
||||||
@ -141,12 +143,17 @@ fn main() -> anyhow::Result<()> {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
let mut build_args: Vec<String> = std::env::args().skip(1).collect();
|
let mut build_args: Vec<String> = std::env::args().skip(1).collect();
|
||||||
log::info!("Running optimized build pipeline with args `{}`", build_args.join(" "));
|
println!("Running optimized build pipeline with args `{}`", build_args.join(" "));
|
||||||
log::info!("Environment values\n{}", format_env_variables());
|
|
||||||
|
|
||||||
if let Ok(config) = std::fs::read_to_string("config.toml") {
|
with_log_group("Environment values", || {
|
||||||
log::info!("Contents of `config.toml`:\n{config}");
|
println!("Environment values\n{}", format_env_variables());
|
||||||
}
|
});
|
||||||
|
|
||||||
|
with_log_group("Printing config.toml", || {
|
||||||
|
if let Ok(config) = std::fs::read_to_string("config.toml") {
|
||||||
|
println!("Contents of `config.toml`:\n{config}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Skip components that are not needed for try builds to speed them up
|
// Skip components that are not needed for try builds to speed them up
|
||||||
if is_try_build() {
|
if is_try_build() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use crate::environment::Environment;
|
use crate::environment::Environment;
|
||||||
use crate::exec::{cmd, CmdBuilder};
|
use crate::exec::{cmd, CmdBuilder};
|
||||||
use crate::utils::io::{count_files, delete_directory};
|
use crate::utils::io::{count_files, delete_directory};
|
||||||
|
use crate::utils::with_log_group;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use camino::{Utf8Path, Utf8PathBuf};
|
use camino::{Utf8Path, Utf8PathBuf};
|
||||||
use humansize::BINARY;
|
use humansize::BINARY;
|
||||||
@ -108,9 +109,11 @@ pub fn gather_llvm_profiles(
|
|||||||
) -> anyhow::Result<LlvmPGOProfile> {
|
) -> anyhow::Result<LlvmPGOProfile> {
|
||||||
log::info!("Running benchmarks with PGO instrumented LLVM");
|
log::info!("Running benchmarks with PGO instrumented LLVM");
|
||||||
|
|
||||||
init_compiler_benchmarks(env, &["Debug", "Opt"], &["Full"], LLVM_PGO_CRATES)
|
with_log_group("Running benchmarks", || {
|
||||||
.run()
|
init_compiler_benchmarks(env, &["Debug", "Opt"], &["Full"], LLVM_PGO_CRATES)
|
||||||
.context("Cannot gather LLVM PGO profiles")?;
|
.run()
|
||||||
|
.context("Cannot gather LLVM PGO profiles")
|
||||||
|
})?;
|
||||||
|
|
||||||
let merged_profile = env.opt_artifacts().join("llvm-pgo.profdata");
|
let merged_profile = env.opt_artifacts().join("llvm-pgo.profdata");
|
||||||
log::info!("Merging LLVM PGO profiles to {merged_profile}");
|
log::info!("Merging LLVM PGO profiles to {merged_profile}");
|
||||||
@ -141,10 +144,12 @@ pub fn gather_rustc_profiles(
|
|||||||
|
|
||||||
// Here we're profiling the `rustc` frontend, so we also include `Check`.
|
// Here we're profiling the `rustc` frontend, so we also include `Check`.
|
||||||
// The benchmark set includes various stress tests that put the frontend under pressure.
|
// The benchmark set includes various stress tests that put the frontend under pressure.
|
||||||
init_compiler_benchmarks(env, &["Check", "Debug", "Opt"], &["All"], RUSTC_PGO_CRATES)
|
with_log_group("Running benchmarks", || {
|
||||||
.env("LLVM_PROFILE_FILE", profile_template.as_str())
|
init_compiler_benchmarks(env, &["Check", "Debug", "Opt"], &["All"], RUSTC_PGO_CRATES)
|
||||||
.run()
|
.env("LLVM_PROFILE_FILE", profile_template.as_str())
|
||||||
.context("Cannot gather rustc PGO profiles")?;
|
.run()
|
||||||
|
.context("Cannot gather rustc PGO profiles")
|
||||||
|
})?;
|
||||||
|
|
||||||
let merged_profile = env.opt_artifacts().join("rustc-pgo.profdata");
|
let merged_profile = env.opt_artifacts().join("rustc-pgo.profdata");
|
||||||
log::info!("Merging Rustc PGO profiles to {merged_profile}");
|
log::info!("Merging Rustc PGO profiles to {merged_profile}");
|
||||||
@ -164,9 +169,11 @@ pub fn gather_rustc_profiles(
|
|||||||
pub fn gather_llvm_bolt_profiles(env: &dyn Environment) -> anyhow::Result<LlvmBoltProfile> {
|
pub fn gather_llvm_bolt_profiles(env: &dyn Environment) -> anyhow::Result<LlvmBoltProfile> {
|
||||||
log::info!("Running benchmarks with BOLT instrumented LLVM");
|
log::info!("Running benchmarks with BOLT instrumented LLVM");
|
||||||
|
|
||||||
init_compiler_benchmarks(env, &["Check", "Debug", "Opt"], &["Full"], LLVM_BOLT_CRATES)
|
with_log_group("Running benchmarks", || {
|
||||||
.run()
|
init_compiler_benchmarks(env, &["Check", "Debug", "Opt"], &["Full"], LLVM_BOLT_CRATES)
|
||||||
.context("Cannot gather LLVM BOLT profiles")?;
|
.run()
|
||||||
|
.context("Cannot gather LLVM BOLT profiles")
|
||||||
|
})?;
|
||||||
|
|
||||||
let merged_profile = env.opt_artifacts().join("bolt.profdata");
|
let merged_profile = env.opt_artifacts().join("bolt.profdata");
|
||||||
let profile_root = Utf8PathBuf::from("/tmp/prof.fdata");
|
let profile_root = Utf8PathBuf::from("/tmp/prof.fdata");
|
||||||
@ -178,10 +185,12 @@ pub fn gather_llvm_bolt_profiles(env: &dyn Environment) -> anyhow::Result<LlvmBo
|
|||||||
let mut merge_args = vec!["merge-fdata"];
|
let mut merge_args = vec!["merge-fdata"];
|
||||||
merge_args.extend(profiles.iter().map(|p| p.to_str().unwrap()));
|
merge_args.extend(profiles.iter().map(|p| p.to_str().unwrap()));
|
||||||
|
|
||||||
cmd(&merge_args)
|
with_log_group("Merging BOLT profiles", || {
|
||||||
.redirect_output(merged_profile.clone())
|
cmd(&merge_args)
|
||||||
.run()
|
.redirect_output(merged_profile.clone())
|
||||||
.context("Cannot merge BOLT profiles")?;
|
.run()
|
||||||
|
.context("Cannot merge BOLT profiles")
|
||||||
|
})?;
|
||||||
|
|
||||||
log::info!("LLVM BOLT statistics");
|
log::info!("LLVM BOLT statistics");
|
||||||
log::info!(
|
log::info!(
|
||||||
|
@ -56,3 +56,20 @@ pub fn clear_llvm_files(env: &dyn Environment) -> anyhow::Result<()> {
|
|||||||
delete_directory(&env.build_artifacts().join("lld"))?;
|
delete_directory(&env.build_artifacts().join("lld"))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Wraps all output produced within the `func` closure in a CI output group, if we're running in
|
||||||
|
/// CI.
|
||||||
|
pub fn with_log_group<F: FnOnce() -> R, R>(group: &str, func: F) -> R {
|
||||||
|
if is_in_ci() {
|
||||||
|
println!("::group::{group}");
|
||||||
|
let result = func();
|
||||||
|
println!("::endgroup::");
|
||||||
|
result
|
||||||
|
} else {
|
||||||
|
func()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_in_ci() -> bool {
|
||||||
|
std::env::var("GITHUB_ACTIONS").is_ok()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user