Skip to content

Commit f8a61f3

Browse files
authored
Merge pull request #2329 from Kobzol/codegen-backend-validation
Validate codegen backends in bot commands and mention them in help
2 parents 8e0d5e2 + 7894dec commit f8a61f3

File tree

3 files changed

+60
-28
lines changed

3 files changed

+60
-28
lines changed

database/src/lib.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,10 @@ impl CodegenBackend {
406406
CodegenBackend::Cranelift => "cranelift",
407407
}
408408
}
409+
410+
pub fn all_values() -> &'static [Self] {
411+
&[Self::Llvm, Self::Cranelift]
412+
}
409413
}
410414

411415
impl FromStr for CodegenBackend {
@@ -1009,12 +1013,7 @@ impl BenchmarkRequest {
10091013
return Ok(vec![CodegenBackend::Llvm]);
10101014
}
10111015

1012-
self.backends
1013-
.split(',')
1014-
.map(|s| {
1015-
CodegenBackend::from_str(s).map_err(|_| anyhow::anyhow!("Invalid backend: {s}"))
1016-
})
1017-
.collect()
1016+
parse_backends(&self.backends).map_err(|e| anyhow::anyhow!("{e}"))
10181017
}
10191018

10201019
/// Get the profiles for the request
@@ -1040,6 +1039,13 @@ impl BenchmarkRequest {
10401039
}
10411040
}
10421041

1042+
pub fn parse_backends(backends: &str) -> Result<Vec<CodegenBackend>, String> {
1043+
backends
1044+
.split(',')
1045+
.map(|s| CodegenBackend::from_str(s).map_err(|_| format!("Invalid backend: {s}")))
1046+
.collect()
1047+
}
1048+
10431049
/// Cached information about benchmark requests in the DB
10441050
pub struct BenchmarkRequestIndex {
10451051
/// Tags (SHA or release name) of all known benchmark requests
Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,61 @@
11
{% extends "layout.html" %}
22
{% block head %}
33
<style>
4-
.help-content {
5-
font-family: Helvetica, Arial, sans-serif;
6-
line-height: 140%;
7-
font-size: 16px;
8-
max-width: 50em;
9-
}
4+
.help-content {
5+
font-family: Helvetica, Arial, sans-serif;
6+
line-height: 140%;
7+
font-size: 16px;
8+
max-width: 50em;
9+
}
1010

11-
.help-content code {
12-
background: #eee;
13-
border-radius: 5px;
14-
padding: 2px;
15-
}
11+
.help-content code {
12+
background: #eee;
13+
border-radius: 5px;
14+
padding: 2px;
15+
}
1616
</style>
1717
{% endblock %}
1818

1919
{% block content %}
2020
<div class="help-content">
2121
<h3><b><code>@rust-timer</code> commands</b></h3>
2222
<p><code>@rust-timer</code> supports several commands, the most common (and simple) being
23-
<code>@rust-timer queue</code>. This command is usually invoked as <code>@bors try @rust-timer queue</code>,
24-
which starts a bors "try" run (not a merge). <code>@rust-timer</code> will wait for the try run to finish,
23+
<code>@rust-timer queue</code>. This command is usually invoked as <code>@bors try @rust-timer
24+
queue</code>,
25+
which starts a bors "try" run (not a merge). <code>@rust-timer</code> will wait for the try run
26+
to finish,
2527
and if it succeeds will then queue a perf run.
2628
</p>
2729
<p><code>@rust-timer queue</code> has a few extra options that can be useful:</p>
2830
<ul>
29-
<li><code>include=&lt;INCLUDE&gt;</code> is a comma-separated list of benchmark prefixes. A benchmark is included in
31+
<li><code>include=&lt;INCLUDE&gt;</code> is a comma-separated list of benchmark prefixes. A
32+
benchmark is included in
3033
the run only if its name matches one of the given prefixes.
3134
</li>
32-
<li><code>exclude=&lt;EXCLUDE&gt;</code> is a comma-separated list of benchmark prefixes, and the inverse of <code>include=</code>.
33-
A benchmark is excluded from the run if its name matches one of the given prefixes.</li>
35+
<li><code>exclude=&lt;EXCLUDE&gt;</code> is a comma-separated list of benchmark prefixes, and
36+
the inverse of <code>include=</code>.
37+
A benchmark is excluded from the run if its name matches one of the given prefixes.
38+
</li>
3439
<li><code>runs=&lt;RUNS&gt;</code> configures how many times the benchmark is run. <code>&lt;RUNS&gt;</code>
35-
is an integer. All benchmarks run at least once by default, but some run more than one time. You can use
36-
the <code>runs</code> option to override the default run count and make every benchmark run for
40+
is an integer. All benchmarks run at least once by default, but some run more than one time.
41+
You can use
42+
the <code>runs</code> option to override the default run count and make every benchmark run
43+
for
3744
<code>&lt;RUNS&gt;</code> times.
3845
</li>
46+
<li><code>backends=&lt;BACKENDS&gt;</code> configures which codegen backends should be
47+
benchmarked.
48+
By default, only the LLVM backend is benchmarked. If you select a non-default codegen backend,
49+
rustc-perf will also gather data for this backend for the parent/baseline commit, so that we
50+
have something to compare to.
51+
</li>
3952
</ul>
40-
<p><code>@rust-timer build $commit</code> will queue a perf run for the given commit <code>$commit</code>.
53+
<p><code>@rust-timer build $commit</code> will queue a perf run for the given commit
54+
<code>$commit</code>.
4155
It is usually invoked with the commit from a successful "try" run. (The
4256
<code>queue</code> command can be seen as a shortcut that automatically selects the
4357
"try" run's commit for the <code>build</code> command)
44-
This command also supports the same <code>include</code>, <code>exclude</code>, and <code>runs</code> options
45-
as <code>@rust-timer queue</code>.
58+
This command also supports the same options as <code>@rust-timer queue</code>.
4659
</p>
4760
</div>
4861
{% endblock %}

site/src/request_handlers/github.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::github::{
66
use crate::job_queue::should_use_job_queue;
77
use crate::load::SiteCtxt;
88

9-
use database::BenchmarkRequest;
9+
use database::{parse_backends, BenchmarkRequest, CodegenBackend};
1010
use hashbrown::HashMap;
1111
use std::sync::Arc;
1212

@@ -265,6 +265,19 @@ fn parse_benchmark_parameters<'a>(
265265
};
266266
params.runs = Some(runs as i32);
267267
}
268+
if let Some(backends) = &params.backends {
269+
// Make sure that the backends are correct
270+
parse_backends(backends).map_err(|e| {
271+
format!(
272+
"Cannot parse backends: {e}. Valid values are: {}",
273+
CodegenBackend::all_values()
274+
.iter()
275+
.map(|b| b.as_str())
276+
.collect::<Vec<_>>()
277+
.join(", ")
278+
)
279+
})?;
280+
}
268281

269282
if !args.is_empty() {
270283
Err(format!(

0 commit comments

Comments
 (0)