Skip to content

Commit 1b641c3

Browse files
committed
Store artifact type to perf-config.json in the collector download command
1 parent 7b480f5 commit 1b641c3

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

collector/src/bin/collector.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use collector::compile::benchmark::category::Category;
88
use collector::compile::benchmark::profile::Profile;
99
use collector::compile::benchmark::scenario::Scenario;
1010
use collector::compile::benchmark::{
11-
compile_benchmark_dir, get_compile_benchmarks, Benchmark, BenchmarkName,
11+
compile_benchmark_dir, get_compile_benchmarks, ArtifactType, Benchmark, BenchmarkName,
1212
};
1313
use collector::{runtime, utils, CollectorCtx, CollectorStepBuilder};
1414
use database::{ArtifactId, ArtifactIdNumber, Commit, CommitType, Connection, Pool};
@@ -586,6 +586,10 @@ struct DownloadCommand {
586586
#[arg(long, short('c'), value_enum, global = true, default_value = "primary")]
587587
category: Category,
588588

589+
/// What artifact type (library or binary) does the benchmark build.
590+
#[arg(long, short('a'), value_enum, global = true, default_value = "library")]
591+
artifact: ArtifactType,
592+
589593
#[command(subcommand)]
590594
command: DownloadSubcommand,
591595
}
@@ -948,9 +952,15 @@ fn main_result() -> anyhow::Result<i32> {
948952
}
949953
};
950954

951-
add_perf_config(&target_dir, cmd.category);
955+
add_perf_config(&target_dir, cmd.category, cmd.artifact);
952956

953-
println!("Benchmark stored at {}", target_dir.display());
957+
println!(
958+
r#"Benchmark stored at {dir} using category `{}` and artifact type `{}`.
959+
Make sure to modify `{dir}/perf-config.json` if the category/artifact don't match your expectations."#,
960+
cmd.category,
961+
cmd.artifact,
962+
dir = target_dir.display(),
963+
);
954964
Ok(0)
955965
}
956966
}
@@ -1249,9 +1259,10 @@ async fn record_toolchain_sizes(
12491259
record(conn, aid, "libLLVM", paths.lib_llvm.as_deref()).await;
12501260
}
12511261

1252-
fn add_perf_config(directory: &Path, category: Category) {
1262+
fn add_perf_config(directory: &Path, category: Category, artifact: ArtifactType) {
12531263
let data = serde_json::json!({
1254-
"category": category.to_string()
1264+
"category": category,
1265+
"artifact": artifact
12551266
});
12561267

12571268
let mut file = BufWriter::new(

collector/src/compile/benchmark/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::utils::wait_for_future;
88
use anyhow::{bail, Context};
99
use log::debug;
1010
use std::collections::{HashMap, HashSet};
11+
use std::fmt::{Display, Formatter};
1112
use std::fs::File;
1213
use std::mem::ManuallyDrop;
1314
use std::path::{Path, PathBuf};
@@ -22,14 +23,25 @@ fn default_runs() -> usize {
2223
3
2324
}
2425

25-
#[derive(Debug, Default, PartialEq, Copy, Clone, serde::Deserialize)]
26+
#[derive(
27+
Debug, Default, PartialEq, Copy, Clone, serde::Serialize, serde::Deserialize, clap::ValueEnum,
28+
)]
2629
#[serde(rename_all = "lowercase")]
2730
pub enum ArtifactType {
2831
Binary,
2932
#[default]
3033
Library,
3134
}
3235

36+
impl Display for ArtifactType {
37+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
38+
match self {
39+
ArtifactType::Binary => f.write_str("binary"),
40+
ArtifactType::Library => f.write_str("library"),
41+
}
42+
}
43+
}
44+
3345
/// This is the internal representation of an individual benchmark's
3446
/// perf-config.json file.
3547
#[derive(Debug, Clone, serde::Deserialize)]

0 commit comments

Comments
 (0)