Skip to content

Commit 86804fa

Browse files
committed
Add support for custom targets
1 parent 53d130f commit 86804fa

4 files changed

Lines changed: 96 additions & 73 deletions

File tree

‎collector/src/benchmark_set/mod.rs‎

Lines changed: 64 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,63 @@ pub fn get_benchmark_sets_for_target(target: Target) -> Vec<BenchmarkSet> {
6464
compile(SYN),
6565
compile(TOKIO_WEBPUSH_SIMPLE),
6666
];
67+
let all_nonstable = || {
68+
vec![
69+
compile(AWAIT_CALL_TREE),
70+
compile(CARGO_0_87_1),
71+
compile(BITMAPS_3_2_1),
72+
compile(BITMAPS_3_2_1_NEW_SOLVER),
73+
compile(CLAP_DERIVE_4_5_32),
74+
compile(COERCIONS),
75+
compile(CRANELIFT_CODEGEN_0_119_0),
76+
compile(CTFE_STRESS_5),
77+
compile(DEEP_VECTOR),
78+
compile(DEEPLY_NESTED_MULTI),
79+
compile(DERIVE),
80+
compile(DIESEL_2_2_10),
81+
compile(EXTERNS),
82+
compile(EZA_0_21_2),
83+
// We split here on x86_64 for the two machines
84+
compile(HELLOWORLD),
85+
compile(HELLOWORLD_TINY),
86+
compile(HTML5EVER_0_31_0),
87+
compile(HTML5EVER_0_31_0_NEW_SOLVER),
88+
compile(HYPER_1_6_0),
89+
compile(IMAGE_0_25_6),
90+
compile(INCLUDE_BLOB),
91+
compile(ISSUE_46449),
92+
compile(ISSUE_58319),
93+
compile(ISSUE_88862),
94+
compile(LARGE_WORKSPACE),
95+
compile(LIBC_0_2_172),
96+
compile(MANY_ASSOC_ITEMS),
97+
compile(MATCH_STRESS),
98+
compile(NALGEBRA_0_33_0),
99+
compile(NALGEBRA_0_33_0_NEW_SOLVER),
100+
compile(PROJECTION_CACHING),
101+
compile(REGEX_AUTOMATA_0_4_8),
102+
compile(REGRESSION_31157),
103+
compile(RIPGREP_14_1_1),
104+
compile(RIPGREP_14_1_1_TINY),
105+
compile(SERDE_1_0_219),
106+
compile(SERDE_1_0_219_NEW_SOLVER),
107+
compile(SERDE_1_0_219_THREADS4),
108+
compile(SERDE_DERIVE_1_0_219),
109+
compile(STM32F4_0_15_1),
110+
compile(SYN_2_0_101),
111+
compile(SYN_2_0_101_NEW_SOLVER),
112+
compile(TOKEN_STREAM_STRESS),
113+
compile(TT_MUNCHER),
114+
compile(TUPLE_STRESS),
115+
compile(TYPENUM_1_18_0),
116+
compile(UCD),
117+
compile(UNICODE_NORMALIZATION_0_1_24),
118+
compile(UNIFY_LINEARLY),
119+
compile(UNUSED_WARNINGS),
120+
compile(WF_PROJECTION_STRESS_65510),
121+
compile(WG_GRAMMAR),
122+
]
123+
};
67124

68125
match target {
69126
Target::X86_64UnknownLinuxGnu => {
@@ -136,64 +193,13 @@ pub fn get_benchmark_sets_for_target(target: Target) -> Vec<BenchmarkSet> {
136193
]
137194
}
138195
Target::AArch64UnknownLinuxGnu => {
139-
let set = vec![
140-
compile(AWAIT_CALL_TREE),
141-
compile(CARGO_0_87_1),
142-
compile(BITMAPS_3_2_1),
143-
compile(BITMAPS_3_2_1_NEW_SOLVER),
144-
compile(CLAP_DERIVE_4_5_32),
145-
compile(COERCIONS),
146-
compile(CRANELIFT_CODEGEN_0_119_0),
147-
compile(CTFE_STRESS_5),
148-
compile(DEEP_VECTOR),
149-
compile(DEEPLY_NESTED_MULTI),
150-
compile(DERIVE),
151-
compile(DIESEL_2_2_10),
152-
compile(EXTERNS),
153-
compile(EZA_0_21_2),
154-
// We split here on x86_64 for the two machines
155-
compile(HELLOWORLD),
156-
compile(HELLOWORLD_TINY),
157-
compile(HTML5EVER_0_31_0),
158-
compile(HTML5EVER_0_31_0_NEW_SOLVER),
159-
compile(HYPER_1_6_0),
160-
compile(IMAGE_0_25_6),
161-
compile(INCLUDE_BLOB),
162-
compile(ISSUE_46449),
163-
compile(ISSUE_58319),
164-
compile(ISSUE_88862),
165-
compile(LARGE_WORKSPACE),
166-
compile(LIBC_0_2_172),
167-
compile(MANY_ASSOC_ITEMS),
168-
compile(MATCH_STRESS),
169-
compile(NALGEBRA_0_33_0),
170-
compile(NALGEBRA_0_33_0_NEW_SOLVER),
171-
compile(PROJECTION_CACHING),
172-
compile(REGEX_AUTOMATA_0_4_8),
173-
compile(REGRESSION_31157),
174-
compile(RIPGREP_14_1_1),
175-
compile(RIPGREP_14_1_1_TINY),
176-
compile(SERDE_1_0_219),
177-
compile(SERDE_1_0_219_NEW_SOLVER),
178-
compile(SERDE_1_0_219_THREADS4),
179-
compile(SERDE_DERIVE_1_0_219),
180-
compile(STM32F4_0_15_1),
181-
compile(SYN_2_0_101),
182-
compile(SYN_2_0_101_NEW_SOLVER),
183-
compile(TOKEN_STREAM_STRESS),
184-
compile(TT_MUNCHER),
185-
compile(TUPLE_STRESS),
186-
compile(TYPENUM_1_18_0),
187-
compile(UCD),
188-
compile(UNICODE_NORMALIZATION_0_1_24),
189-
compile(UNIFY_LINEARLY),
190-
compile(UNUSED_WARNINGS),
191-
compile(WF_PROJECTION_STRESS_65510),
192-
compile(WG_GRAMMAR),
193-
];
194-
195196
vec![BenchmarkSet {
196-
members: stable.into_iter().chain(set).collect(),
197+
members: stable.into_iter().chain(all_nonstable()).collect(),
198+
}]
199+
}
200+
Target::Custom(_) => {
201+
vec![BenchmarkSet {
202+
members: stable.into_iter().chain(all_nonstable()).collect(),
197203
}]
198204
}
199205
}
@@ -282,7 +288,7 @@ mod tests {
282288
fn check_benchmark_set_aarch64() {
283289
let sets = get_benchmark_sets_for_target(Target::AArch64UnknownLinuxGnu);
284290

285-
assert!(sets.len() == 1);
291+
assert_eq!(sets.len(), 1);
286292

287293
check_benchmark_sets(&sets);
288294
}

‎collector/src/compile/benchmark/target.rs‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1+
use database::{intern_target_name, TargetName};
12
use std::{fmt, str::FromStr};
23

34
/// Target representing an Rust target triple, for a full list of targets and
45
/// their support see;
56
/// https://doc.rust-lang.org/nightly/rustc/platform-support.html
6-
///
7-
/// Presently we only support x86_64
8-
/// FIXME: we actually support Windows and aarch64, but that isn't captured here.
97
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, serde::Deserialize)]
108
pub enum Target {
119
/// `x86_64-unknown-linux-gnu`
1210
X86_64UnknownLinuxGnu,
1311

1412
/// `aarch64-unknown-linux-gnu`
1513
AArch64UnknownLinuxGnu,
14+
/// Custom target
15+
Custom(TargetName),
1616
}
1717

1818
impl FromStr for Target {
1919
type Err = String;
2020
fn from_str(s: &str) -> Result<Self, Self::Err> {
21-
Ok(match s.to_ascii_lowercase().as_str() {
21+
Ok(match s {
2222
"x86_64-unknown-linux-gnu" => Target::X86_64UnknownLinuxGnu,
2323
"aarch64-unknown-linux-gnu" => Target::AArch64UnknownLinuxGnu,
24-
_ => return Err(format!("{s} is not a valid target")),
24+
name => Target::Custom(intern_target_name(name)),
2525
})
2626
}
2727
}
@@ -37,6 +37,7 @@ impl Target {
3737
match self {
3838
Target::X86_64UnknownLinuxGnu => "x86_64-unknown-linux-gnu",
3939
Target::AArch64UnknownLinuxGnu => "aarch64-unknown-linux-gnu",
40+
Target::Custom(name) => name.as_str(),
4041
}
4142
}
4243

@@ -56,6 +57,7 @@ impl From<database::Target> for Target {
5657
match value {
5758
database::Target::X86_64UnknownLinuxGnu => Self::X86_64UnknownLinuxGnu,
5859
database::Target::AArch64UnknownLinuxGnu => Self::AArch64UnknownLinuxGnu,
60+
database::Target::Custom(name) => Self::Custom(name),
5961
}
6062
}
6163
}
@@ -65,6 +67,7 @@ impl From<Target> for database::Target {
6567
match value {
6668
Target::X86_64UnknownLinuxGnu => database::Target::X86_64UnknownLinuxGnu,
6769
Target::AArch64UnknownLinuxGnu => database::Target::AArch64UnknownLinuxGnu,
70+
Target::Custom(name) => database::Target::Custom(name),
6871
}
6972
}
7073
}

‎database/src/lib.rs‎

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ pub use pool::{Connection, Pool};
1919

2020
intern!(pub struct Metric);
2121
intern!(pub struct Benchmark);
22+
intern!(pub struct TargetName);
23+
24+
pub fn intern_target_name(target: &str) -> TargetName {
25+
intern(target)
26+
}
2227

2328
#[derive(Debug, PartialEq, Eq)]
2429
pub struct QueuedCommit {
@@ -366,25 +371,29 @@ impl PartialOrd for Scenario {
366371
/// their support see;
367372
/// https://doc.rust-lang.org/nightly/rustc/platform-support.html
368373
///
369-
/// Presently we only support x86_64
374+
/// We separate "first-party" targets for which we have additional support, and a fallback
375+
/// that can be used to use rustc-perf for any target.
370376
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
371377
pub enum Target {
372378
/// `x86_64-unknown-linux-gnu`
373379
X86_64UnknownLinuxGnu,
374380

375381
/// `aarch64-unknown-linux-gnu`
376382
AArch64UnknownLinuxGnu,
383+
Custom(TargetName),
377384
}
378385

379386
impl Target {
380387
pub fn as_str(self) -> &'static str {
381388
match self {
382389
Target::X86_64UnknownLinuxGnu => "x86_64-unknown-linux-gnu",
383390
Target::AArch64UnknownLinuxGnu => "aarch64-unknown-linux-gnu",
391+
Target::Custom(name) => name.as_str(),
384392
}
385393
}
386394

387-
pub fn all() -> Vec<Self> {
395+
/// Targets that we primarily support in the website.
396+
pub fn primary_targets() -> Vec<Self> {
388397
vec![Self::X86_64UnknownLinuxGnu, Self::AArch64UnknownLinuxGnu]
389398
}
390399

@@ -397,18 +406,18 @@ impl Target {
397406
// 2026/01/12 (Jamesbarford) - presently rustc-perf only support `x86_64`'s
398407
// in the pipeline and has two machines running. AArch64 will be run in
399408
// the background and we do not want to wait for it to complete benchmarking
400-
pub fn is_optional(self) -> bool {
401-
self != Target::X86_64UnknownLinuxGnu
409+
pub fn is_optional(&self) -> bool {
410+
*self != Target::X86_64UnknownLinuxGnu
402411
}
403412
}
404413

405414
impl FromStr for Target {
406415
type Err = String;
407416
fn from_str(s: &str) -> Result<Self, Self::Err> {
408-
Ok(match s.to_ascii_lowercase().as_str() {
417+
Ok(match s {
409418
"x86_64-unknown-linux-gnu" => Target::X86_64UnknownLinuxGnu,
410419
"aarch64-unknown-linux-gnu" => Target::AArch64UnknownLinuxGnu,
411-
_ => return Err(format!("{s} is not a valid target")),
420+
other => Target::Custom(intern(other)),
412421
})
413422
}
414423
}
@@ -667,7 +676,7 @@ mod index_serde {
667676
}
668677
}
669678

670-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
679+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
671680
pub enum DbLabel {
672681
StatisticDescription {
673682
benchmark: Benchmark,
@@ -1130,7 +1139,12 @@ pub fn parse_profiles(profiles: &str) -> Result<Vec<Profile>, String> {
11301139
}
11311140

11321141
pub fn parse_targets(targets: &str) -> Result<Vec<Target>, String> {
1133-
parse_comma_separated(targets, "target")
1142+
let primary = Target::primary_targets();
1143+
let targets = parse_comma_separated(targets, "target")?;
1144+
if !targets.iter().all(|t| primary.contains(t)) {
1145+
return Err("Only primary targets can be specified".to_string());
1146+
}
1147+
Ok(targets)
11341148
}
11351149

11361150
/// Cached information about benchmark requests in the DB

‎site/src/request_handlers/github.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ fn parse_benchmark_parameters<'a>(
365365
parse_targets(targets).map_err(|e| {
366366
format!(
367367
"Cannot parse targets: {e}. Valid values are: {}",
368-
Target::all()
368+
Target::primary_targets()
369369
.iter()
370370
.map(|b| b.as_str())
371371
.collect::<Vec<_>>()
@@ -597,7 +597,7 @@ Otherwise LGTM."#),
597597
insta::assert_compact_debug_snapshot!(parse_queue_command("@rust-timer queue targets=x86_64-unknown-linux-gnu"),
598598
@r#"Some(Ok(QueueCommand { params: BenchmarkParameters { backends: None, profiles: None, targets: Some("x86_64-unknown-linux-gnu") } }))"#);
599599
insta::assert_compact_debug_snapshot!(parse_queue_command("@rust-timer queue targets=x86_64-unknown-linux-gnu,67-unknown-none"),
600-
@r#"Some(Err("Cannot parse targets: Invalid target: 67-unknown-none. Valid values are: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu"))"#);
600+
@r#"Some(Err("Cannot parse targets: Only primary targets can be specified. Valid values are: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu"))"#);
601601
}
602602

603603
#[test]

0 commit comments

Comments
 (0)