Skip to content

Unify some CLI options between compile time and runtime benchmarks #1472

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
Oct 19, 2022
Merged
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
78 changes: 36 additions & 42 deletions collector/src/bin/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,16 +496,6 @@ struct LocalOptions {
#[clap(long)]
id: Option<String>,

/// Measure the build profiles in this comma-separated list
#[clap(
long = "profiles",
alias = "builds", // the old name, for backward compatibility
value_parser = ProfileArgParser,
// Don't run rustdoc by default
default_value = "Check,Debug,Opt",
)]
profiles: ProfileArg,

/// The path to the local Cargo to use
#[clap(long, parse(from_os_str))]
cargo: Option<PathBuf>,
Expand All @@ -517,10 +507,19 @@ struct LocalOptions {
/// Include only benchmarks matching a prefix in this comma-separated list
#[clap(long)]
include: Option<String>,
}

/// The path to the local rustdoc to measure
#[clap(long, parse(from_os_str))]
rustdoc: Option<PathBuf>,
#[derive(Debug, clap::Args)]
struct CompileTimeOptions {
/// Measure the build profiles in this comma-separated list
#[clap(
long = "profiles",
alias = "builds", // the old name, for backward compatibility
value_parser = ProfileArgParser,
// Don't run rustdoc by default
default_value = "Check,Debug,Opt",
)]
profiles: ProfileArg,

/// Measure the scenarios in this comma-separated list
#[clap(
Expand All @@ -530,6 +529,10 @@ struct LocalOptions {
default_value = "All"
)]
scenarios: ScenarioArg,

/// The path to the local rustdoc to measure
#[clap(long, parse(from_os_str))]
rustdoc: Option<PathBuf>,
}

#[derive(Debug, clap::Args)]
Expand Down Expand Up @@ -562,19 +565,8 @@ struct BenchRustcOption {
enum Commands {
/// Benchmarks the performance of programs generated by a local rustc
BenchRuntimeLocal {
/// The path to the local rustc to measure
rustc: String,
/// Identifier to associate benchmark results with
#[clap(long)]
id: Option<String>,

/// Exclude all benchmarks matching a prefix in this comma-separated list
#[clap(long)]
exclude: Option<String>,

/// Include only benchmarks matching a prefix in this comma-separated list
#[clap(long)]
include: Option<String>,
#[clap(flatten)]
local: LocalOptions,

/// How many iterations of each benchmark should be executed.
#[clap(long, default_value = "5")]
Expand All @@ -585,6 +577,9 @@ enum Commands {
#[clap(flatten)]
local: LocalOptions,

#[clap(flatten)]
opts: CompileTimeOptions,

#[clap(flatten)]
db: DbOption,

Expand Down Expand Up @@ -632,6 +627,9 @@ enum Commands {
#[clap(flatten)]
local: LocalOptions,

#[clap(flatten)]
opts: CompileTimeOptions,

/// Output directory
#[clap(long = "out-dir", default_value = "results/")]
out_dir: PathBuf,
Expand Down Expand Up @@ -705,38 +703,33 @@ fn main_result() -> anyhow::Result<i32> {
let target_triple = format!("{}-unknown-linux-gnu", std::env::consts::ARCH);

match args.command {
Commands::BenchRuntimeLocal {
rustc,
id,
exclude,
include,
iterations,
} => {
Commands::BenchRuntimeLocal { local, iterations } => {
bench_runtime(
&rustc,
id.as_deref(),
BenchmarkFilter::new(exclude, include),
&local.rustc,
local.id.as_deref(),
BenchmarkFilter::new(local.exclude, local.include),
runtime_benchmark_dir,
iterations,
)?;
Ok(0)
}
Commands::BenchLocal {
local,
opts,
db,
bench_rustc,
iterations,
self_profile,
} => {
let profiles = &local.profiles.0;
let scenarios = &local.scenarios.0;
let profiles = &opts.profiles.0;
let scenarios = &opts.scenarios.0;

let pool = database::Pool::open(&db.db);

let toolchain = get_local_toolchain(
&profiles,
&local.rustc,
local.rustdoc.as_deref(),
opts.rustdoc.as_deref(),
local.cargo.as_deref(),
local.id.as_deref(),
"",
Expand Down Expand Up @@ -852,6 +845,7 @@ fn main_result() -> anyhow::Result<i32> {
Commands::ProfileLocal {
profiler,
local,
opts,
out_dir,
rustc2,
jobs,
Expand All @@ -864,8 +858,8 @@ fn main_result() -> anyhow::Result<i32> {
);
}

let profiles = &local.profiles.0;
let scenarios = &local.scenarios.0;
let profiles = &opts.profiles.0;
let scenarios = &opts.scenarios.0;

let mut benchmarks = get_compile_benchmarks(
&compile_benchmark_dir,
Expand All @@ -887,7 +881,7 @@ fn main_result() -> anyhow::Result<i32> {
let toolchain = get_local_toolchain(
&profiles,
&rustc,
local.rustdoc.as_deref(),
opts.rustdoc.as_deref(),
local.cargo.as_deref(),
local.id.as_deref(),
suffix,
Expand Down