@@ -114,7 +114,7 @@ async fn summarize_run(
114
114
let benchmark_map = ctxt. get_benchmark_category_map ( ) . await ;
115
115
116
116
let mut message = format ! (
117
- "Finished benchmarking commit ({sha}): [comparison url ]({comparison_url}).\n \n " ,
117
+ "Finished benchmarking commit ({sha}): [comparison URL ]({comparison_url}).\n \n " ,
118
118
sha = commit. sha,
119
119
comparison_url = make_comparison_url( & commit, Metric :: InstructionsUser )
120
120
) ;
@@ -133,116 +133,115 @@ async fn summarize_run(
133
133
} else {
134
134
String :: new ( )
135
135
} ;
136
+
136
137
let ( inst_primary, inst_secondary) = inst_comparison
137
138
. clone ( )
138
139
. summarize_by_category ( & benchmark_map) ;
139
140
141
+ let direction = inst_primary. direction ( ) . join ( inst_secondary. direction ( ) ) ;
142
+ let overall_result = match direction {
143
+ Direction :: Improvement => "✅ improvements" ,
144
+ Direction :: Regression => "❌ regressions" ,
145
+ Direction :: Mixed => "❌✅ regressions and improvements" ,
146
+ Direction :: None => "no relevant changes" ,
147
+ } ;
148
+ let is_regression = deserves_attention_icount ( & inst_primary, & inst_secondary)
149
+ && matches ! ( direction, Direction :: Regression | Direction :: Mixed ) ;
150
+
151
+ writeln ! (
152
+ & mut message,
153
+ "### Overall result: {}{}\n " ,
154
+ overall_result,
155
+ if is_regression {
156
+ " - ACTION NEEDED"
157
+ } else {
158
+ " - no action needed"
159
+ } ,
160
+ )
161
+ . unwrap ( ) ;
162
+
163
+ let next_steps = if is_master_commit {
164
+ master_run_body ( is_regression)
165
+ } else {
166
+ try_run_body ( is_regression)
167
+ } ;
168
+ writeln ! ( & mut message, "{next_steps}\n " ) . unwrap ( ) ;
169
+
170
+ if !errors. is_empty ( ) {
171
+ writeln ! ( & mut message, "\n {errors}" ) . unwrap ( ) ;
172
+ }
173
+
140
174
let mut table_written = false ;
141
175
let metrics = vec ! [
142
176
(
143
177
"Instruction count" ,
144
178
Metric :: InstructionsUser ,
145
- false ,
179
+ true , // highly reliable
146
180
inst_comparison,
147
181
) ,
148
182
(
149
183
"Max RSS (memory usage)" ,
150
184
Metric :: MaxRSS ,
151
- true ,
185
+ false , // not highly reliable
152
186
calculate_metric_comparison( ctxt, & commit, Metric :: MaxRSS ) . await ?,
153
187
) ,
154
188
(
155
189
"Cycles" ,
156
190
Metric :: CyclesUser ,
157
- true ,
191
+ false , // not highly reliable
158
192
calculate_metric_comparison( ctxt, & commit, Metric :: CyclesUser ) . await ?,
159
193
) ,
160
194
] ;
161
195
162
- for ( title, metric, hidden , comparison) in metrics {
196
+ for ( title, metric, highly_reliable , comparison) in metrics {
163
197
message. push_str ( & format ! (
164
198
"\n ### [{title}]({})\n " ,
165
199
make_comparison_url( & commit, metric)
166
200
) ) ;
167
201
168
202
let ( primary, secondary) = comparison. summarize_by_category ( & benchmark_map) ;
169
- table_written |= write_metric_summary ( primary, secondary, hidden , & mut message) ;
203
+ table_written |= write_metric_summary ( primary, secondary, highly_reliable , & mut message) ;
170
204
}
171
205
172
206
if table_written {
173
207
write_summary_table_footer ( & mut message) ;
174
208
}
175
209
176
- const DISAGREEMENT : & str = "If you disagree with this performance assessment, \
177
- please file an issue in [rust-lang/rustc-perf](https://github.com/rust-lang/rustc-perf/issues/new).";
178
- let footer = format ! ( "{DISAGREEMENT}{errors}" ) ;
179
-
180
- let direction = Direction :: join ( inst_primary. direction ( ) , inst_secondary. direction ( ) ) ;
181
- let next_steps = next_steps ( inst_primary, inst_secondary, direction, is_master_commit) ;
182
-
183
- write ! ( & mut message, "\n {footer}\n {next_steps}" ) . unwrap ( ) ;
184
-
185
210
Ok ( message)
186
211
}
187
212
188
213
/// Returns true if a summary table was written to `message`.
189
214
fn write_metric_summary (
190
215
primary : ArtifactComparisonSummary ,
191
216
secondary : ArtifactComparisonSummary ,
192
- hidden : bool ,
217
+ highly_reliable : bool ,
193
218
message : & mut String ,
194
219
) -> bool {
195
220
if !primary. is_relevant ( ) && !secondary. is_relevant ( ) {
196
221
message
197
222
. push_str ( "This benchmark run did not return any relevant results for this metric.\n " ) ;
198
223
false
199
224
} else {
200
- let primary_short_summary = generate_short_summary ( & primary) ;
201
- let secondary_short_summary = generate_short_summary ( & secondary) ;
202
-
203
- if hidden {
225
+ if highly_reliable {
226
+ message. push_str (
227
+ "This is a highly reliable metric that was used to determine the \
228
+ overall result at the top of this comment.\n \n ",
229
+ ) ;
230
+ write_summary_table ( & primary, & secondary, true , false , message) ;
231
+ } else {
232
+ // `<details>` means it is hidden, requiring a click to reveal.
204
233
message. push_str ( "<details>\n <summary>Results</summary>\n \n " ) ;
205
- }
206
-
207
- write ! (
208
- message,
209
- r#"
210
- - Primary benchmarks: {primary_short_summary}
211
- - Secondary benchmarks: {secondary_short_summary}
212
-
213
- "#
214
- )
215
- . unwrap ( ) ;
216
-
217
- write_summary_table ( & primary, & secondary, true , false , message) ;
218
-
219
- if hidden {
234
+ message. push_str (
235
+ "This is a less reliable metric that may be of interest but was not \
236
+ used to determine the overall result at the top of this comment.\n \n ",
237
+ ) ;
238
+ write_summary_table ( & primary, & secondary, true , false , message) ;
220
239
message. push_str ( "</details>\n " ) ;
221
240
}
222
-
223
241
true
224
242
}
225
243
}
226
244
227
- fn next_steps (
228
- primary : ArtifactComparisonSummary ,
229
- secondary : ArtifactComparisonSummary ,
230
- direction : Direction ,
231
- is_master_commit : bool ,
232
- ) -> String {
233
- let deserves_attention = deserves_attention_icount ( & primary, & secondary) ;
234
- let ( is_regression, label) = match ( deserves_attention, direction) {
235
- ( true , Direction :: Regression | Direction :: Mixed ) => ( true , "+perf-regression" ) ,
236
- _ => ( false , "-perf-regression" ) ,
237
- } ;
238
-
239
- if is_master_commit {
240
- master_run_body ( is_regression)
241
- } else {
242
- try_run_body ( label)
243
- }
244
- }
245
-
246
245
fn master_run_body ( is_regression : bool ) -> String {
247
246
if is_regression {
248
247
"
@@ -265,8 +264,8 @@ cc @rust-lang/wg-compiler-performance
265
264
. to_string ( )
266
265
}
267
266
268
- fn try_run_body ( label : & str ) -> String {
269
- let next_steps = if label . starts_with ( "+" ) {
267
+ fn try_run_body ( is_regression : bool ) -> String {
268
+ let next_steps = if is_regression {
270
269
"\n \n **Next Steps**: If you can justify the regressions found in \
271
270
this try perf run, please indicate this with \
272
271
`@rustbot label: +perf-regression-triaged` along with \
@@ -277,6 +276,7 @@ fn try_run_body(label: &str) -> String {
277
276
""
278
277
} ;
279
278
279
+ let sign = if is_regression { "+" } else { "-" } ;
280
280
format ! (
281
281
"
282
282
Benchmarking this pull request likely means that it is \
@@ -286,32 +286,6 @@ for rollup, we strongly recommend not doing so since this PR may lead to changes
286
286
compiler perf.{next_steps}
287
287
288
288
@bors rollup=never
289
- @rustbot label: +S-waiting-on-review -S-waiting-on-perf {label} " ,
289
+ @rustbot label: +S-waiting-on-review -S-waiting-on-perf {sign}perf-regression " ,
290
290
)
291
291
}
292
-
293
- fn generate_short_summary ( summary : & ArtifactComparisonSummary ) -> String {
294
- // Add an "s" to a word unless there's only one.
295
- fn ending ( word : & ' static str , count : usize ) -> std:: borrow:: Cow < ' static , str > {
296
- if count == 1 {
297
- return word. into ( ) ;
298
- }
299
- format ! ( "{}s" , word) . into ( )
300
- }
301
-
302
- let num_improvements = summary. number_of_improvements ( ) ;
303
- let num_regressions = summary. number_of_regressions ( ) ;
304
-
305
- match summary. direction ( ) {
306
- Direction :: Improvement => format ! (
307
- "✅ relevant {} found" ,
308
- ending( "improvement" , num_improvements)
309
- ) ,
310
- Direction :: Regression => format ! (
311
- "❌ relevant {} found" ,
312
- ending( "regression" , num_regressions)
313
- ) ,
314
- Direction :: Mixed => "mixed results" . to_string ( ) ,
315
- Direction :: None => "no relevant changes found" . to_string ( ) ,
316
- }
317
- }
0 commit comments