@@ -146,37 +146,37 @@ pub async fn handle_compare(
146
146
async fn populate_report (
147
147
ctxt : & SiteCtxt ,
148
148
comparison : & Comparison ,
149
- report : & mut HashMap < Option < Direction > , Vec < String > > ,
149
+ report : & mut HashMap < Direction , Vec < String > > ,
150
150
) {
151
- if let Some ( summary) = ComparisonSummary :: summarize_comparison ( comparison) {
152
- let relevance = summary. relevance_level ( ) ;
153
- if relevance. at_least_somewhat_relevant ( ) {
154
- if let Some ( direction) = summary. direction ( ) {
155
- let entry = report
156
- . entry ( relevance. very_relevant ( ) . then ( || direction) )
157
- . or_default ( ) ;
158
-
159
- entry. push ( write_triage_summary ( ctxt, comparison) . await )
160
- }
161
- }
162
- }
151
+ let benchmark_map = ctxt. get_benchmark_category_map ( ) . await ;
152
+ let ( primary, secondary) = comparison. clone ( ) . summarize_by_category ( benchmark_map) ;
153
+ // Get the combined direction of the primary and secondary summaries
154
+ let direction = match ( primary. direction ( ) , secondary. direction ( ) ) {
155
+ ( Some ( d1) , Some ( d2) ) if d1 != d2 => Direction :: Mixed ,
156
+ ( Some ( d) , Some ( _) | None ) => d,
157
+ ( None , Some ( d) ) => d,
158
+ ( None , None ) => return ,
159
+ } ;
160
+
161
+ let entry = report. entry ( direction) . or_default ( ) ;
162
+
163
+ entry. push ( write_triage_summary ( comparison, & primary, & secondary) . await )
163
164
}
164
165
165
166
/// A summary of a given comparison
166
167
///
167
168
/// This summary only includes changes that are significant and relevant (as determined by a change's magnitude).
168
169
pub struct ComparisonSummary {
169
- /// Significant comparisons of magnitude small and above
170
- /// and ordered by magnitude from largest to smallest
171
- comparisons : Vec < TestResultComparison > ,
170
+ /// Relevant comparisons ordered by magnitude from largest to smallest
171
+ relevant_comparisons : Vec < TestResultComparison > ,
172
172
/// The cached number of comparisons that are improvements
173
173
num_improvements : usize ,
174
174
/// The cached number of comparisons that are regressions
175
175
num_regressions : usize ,
176
176
}
177
177
178
178
impl ComparisonSummary {
179
- pub fn summarize_comparison ( comparison : & Comparison ) -> Option < Self > {
179
+ pub fn summarize_comparison ( comparison : & Comparison ) -> Self {
180
180
let mut num_improvements = 0 ;
181
181
let mut num_regressions = 0 ;
182
182
@@ -193,10 +193,6 @@ impl ComparisonSummary {
193
193
} )
194
194
. cloned ( )
195
195
. collect :: < Vec < _ > > ( ) ;
196
- // Skip empty commits, sometimes happens if there's a compiler bug or so.
197
- if comparisons. len ( ) == 0 {
198
- return None ;
199
- }
200
196
201
197
let cmp = |b1 : & TestResultComparison , b2 : & TestResultComparison | {
202
198
b2. relative_change ( )
@@ -206,29 +202,23 @@ impl ComparisonSummary {
206
202
} ;
207
203
comparisons. sort_by ( cmp) ;
208
204
209
- Some ( ComparisonSummary {
210
- comparisons,
205
+ ComparisonSummary {
206
+ relevant_comparisons : comparisons,
211
207
num_improvements,
212
208
num_regressions,
213
- } )
214
- }
215
-
216
- pub fn empty ( ) -> Self {
217
- ComparisonSummary {
218
- comparisons : vec ! [ ] ,
219
- num_improvements : 0 ,
220
- num_regressions : 0 ,
221
209
}
222
210
}
223
211
224
212
/// The direction of the changes
225
213
pub fn direction ( & self ) -> Option < Direction > {
226
- if self . comparisons . len ( ) == 0 {
214
+ if self . relevant_comparisons . len ( ) == 0 {
227
215
return None ;
228
216
}
229
217
230
- let ( regressions, improvements) : ( Vec < & TestResultComparison > , _ ) =
231
- self . comparisons . iter ( ) . partition ( |c| c. is_regression ( ) ) ;
218
+ let ( regressions, improvements) : ( Vec < & TestResultComparison > , _ ) = self
219
+ . relevant_comparisons
220
+ . iter ( )
221
+ . partition ( |c| c. is_regression ( ) ) ;
232
222
233
223
if regressions. len ( ) == 0 {
234
224
return Some ( Direction :: Improvement ) ;
@@ -238,7 +228,7 @@ impl ComparisonSummary {
238
228
return Some ( Direction :: Regression ) ;
239
229
}
240
230
241
- let total_num = self . comparisons . len ( ) ;
231
+ let total_num = self . relevant_comparisons . len ( ) ;
242
232
let regressions_ratio = regressions. len ( ) as f64 / total_num as f64 ;
243
233
244
234
let has_medium_and_above_regressions = regressions
@@ -300,18 +290,11 @@ impl ComparisonSummary {
300
290
301
291
/// Arithmetic mean of all changes as a percent
302
292
pub fn arithmetic_mean_of_changes ( & self ) -> f64 {
303
- self . arithmetic_mean ( self . comparisons . iter ( ) )
304
- }
305
-
306
- pub fn num_significant_changes ( & self ) -> usize {
307
- self . comparisons
308
- . iter ( )
309
- . filter ( |c| c. is_significant ( ) )
310
- . count ( )
293
+ self . arithmetic_mean ( self . relevant_comparisons . iter ( ) )
311
294
}
312
295
313
296
pub fn is_empty ( & self ) -> bool {
314
- self . comparisons . is_empty ( )
297
+ self . relevant_comparisons . is_empty ( )
315
298
}
316
299
317
300
fn arithmetic_mean < ' a > (
@@ -329,45 +312,38 @@ impl ComparisonSummary {
329
312
}
330
313
331
314
fn improvements ( & self ) -> impl Iterator < Item = & TestResultComparison > {
332
- self . comparisons . iter ( ) . filter ( |c| c. is_improvement ( ) )
315
+ self . relevant_comparisons
316
+ . iter ( )
317
+ . filter ( |c| c. is_improvement ( ) )
333
318
}
334
319
335
320
fn regressions ( & self ) -> impl Iterator < Item = & TestResultComparison > {
336
- self . comparisons . iter ( ) . filter ( |c| c. is_regression ( ) )
321
+ self . relevant_comparisons
322
+ . iter ( )
323
+ . filter ( |c| c. is_regression ( ) )
337
324
}
338
325
339
326
fn largest_improvement ( & self ) -> Option < & TestResultComparison > {
340
- self . comparisons . iter ( ) . find ( |s| s. is_improvement ( ) )
327
+ self . relevant_comparisons
328
+ . iter ( )
329
+ . find ( |s| s. is_improvement ( ) )
341
330
}
342
331
343
332
fn largest_regression ( & self ) -> Option < & TestResultComparison > {
344
- self . comparisons . iter ( ) . find ( |s| s. is_regression ( ) )
333
+ self . relevant_comparisons . iter ( ) . find ( |s| s. is_regression ( ) )
345
334
}
346
335
347
336
/// The relevance level of the entire comparison
348
- pub fn relevance_level ( & self ) -> RelevanceLevel {
349
- let mut num_small_changes = 0 ;
350
- let mut num_medium_changes = 0 ;
351
- for c in self . comparisons . iter ( ) {
352
- match c. magnitude ( ) {
353
- Magnitude :: Small => num_small_changes += 1 ,
354
- Magnitude :: Medium => num_medium_changes += 1 ,
355
- Magnitude :: Large => return RelevanceLevel :: High ,
356
- Magnitude :: VeryLarge => return RelevanceLevel :: High ,
357
- Magnitude :: VerySmall => unreachable ! ( ) ,
358
- }
359
- }
360
-
361
- match ( num_small_changes, num_medium_changes) {
362
- ( _, m) if m > 1 => RelevanceLevel :: High ,
363
- ( _, 1 ) => RelevanceLevel :: Medium ,
364
- ( s, 0 ) if s > 10 => RelevanceLevel :: Medium ,
365
- _ => RelevanceLevel :: Low ,
366
- }
337
+ pub fn is_relevant ( & self ) -> bool {
338
+ !self . is_empty ( )
367
339
}
368
340
}
369
341
370
- async fn write_triage_summary ( ctxt : & SiteCtxt , comparison : & Comparison ) -> String {
342
+ async fn write_triage_summary (
343
+ comparison : & Comparison ,
344
+ primary : & ComparisonSummary ,
345
+ secondary : & ComparisonSummary ,
346
+ ) -> String {
371
347
use std:: fmt:: Write ;
372
348
let mut result = if let Some ( pr) = comparison. b . pr {
373
349
let title = github:: pr_title ( pr) . await ;
@@ -383,11 +359,6 @@ async fn write_triage_summary(ctxt: &SiteCtxt, comparison: &Comparison) -> Strin
383
359
let link = & compare_link ( start, end) ;
384
360
write ! ( & mut result, " [(Comparison Link)]({})\n " , link) . unwrap ( ) ;
385
361
386
- let benchmark_map = ctxt. get_benchmark_category_map ( ) . await ;
387
- let ( primary, secondary) = comparison. clone ( ) . summarize_by_category ( benchmark_map) ;
388
- let primary = primary. unwrap_or_else ( ComparisonSummary :: empty) ;
389
- let secondary = secondary. unwrap_or_else ( ComparisonSummary :: empty) ;
390
-
391
362
write_summary_table ( & primary, & secondary, false , & mut result) ;
392
363
393
364
result
@@ -506,24 +477,6 @@ pub fn write_summary_table(
506
477
}
507
478
}
508
479
509
- /// How relevant a set of test result comparisons are.
510
- #[ derive( Clone , Copy , Debug ) ]
511
- pub enum RelevanceLevel {
512
- Low ,
513
- Medium ,
514
- High ,
515
- }
516
-
517
- impl RelevanceLevel {
518
- pub fn very_relevant ( self ) -> bool {
519
- matches ! ( self , Self :: High )
520
- }
521
-
522
- pub fn at_least_somewhat_relevant ( self ) -> bool {
523
- matches ! ( self , Self :: High | Self :: Medium )
524
- }
525
- }
526
-
527
480
/// Compare two bounds on a given stat
528
481
///
529
482
/// Returns Ok(None) when no data for the end bound is present
@@ -782,7 +735,7 @@ impl Comparison {
782
735
pub fn summarize_by_category (
783
736
self ,
784
737
category_map : HashMap < Benchmark , Category > ,
785
- ) -> ( Option < ComparisonSummary > , Option < ComparisonSummary > ) {
738
+ ) -> ( ComparisonSummary , ComparisonSummary ) {
786
739
let ( primary, secondary) = self
787
740
. statistics
788
741
. into_iter ( )
@@ -1146,7 +1099,7 @@ impl Magnitude {
1146
1099
async fn generate_report (
1147
1100
start : & Bound ,
1148
1101
end : & Bound ,
1149
- mut report : HashMap < Option < Direction > , Vec < String > > ,
1102
+ mut report : HashMap < Direction , Vec < String > > ,
1150
1103
num_comparisons : usize ,
1151
1104
) -> String {
1152
1105
fn fmt_bound ( bound : & Bound ) -> String {
@@ -1158,14 +1111,9 @@ async fn generate_report(
1158
1111
}
1159
1112
let start = fmt_bound ( start) ;
1160
1113
let end = fmt_bound ( end) ;
1161
- let regressions = report
1162
- . remove ( & Some ( Direction :: Regression ) )
1163
- . unwrap_or_default ( ) ;
1164
- let improvements = report
1165
- . remove ( & Some ( Direction :: Improvement ) )
1166
- . unwrap_or_default ( ) ;
1167
- let mixed = report. remove ( & Some ( Direction :: Mixed ) ) . unwrap_or_default ( ) ;
1168
- let unlabeled = report. remove ( & None ) . unwrap_or_default ( ) ;
1114
+ let regressions = report. remove ( & Direction :: Regression ) . unwrap_or_default ( ) ;
1115
+ let improvements = report. remove ( & Direction :: Improvement ) . unwrap_or_default ( ) ;
1116
+ let mixed = report. remove ( & Direction :: Mixed ) . unwrap_or_default ( ) ;
1169
1117
let untriaged = match github:: untriaged_perf_regressions ( ) . await {
1170
1118
Ok ( u) => u
1171
1119
. iter ( )
@@ -1205,15 +1153,6 @@ Revision range: [{first_commit}..{last_commit}](https://perf.rust-lang.org/?star
1205
1153
1206
1154
{mixed}
1207
1155
1208
- #### Probably changed
1209
-
1210
- The following is a list of comparisons which *probably* represent real performance changes,
1211
- but we're not 100% sure. Please move things from this category into the categories
1212
- above for changes you think *are* definitely relevant and file an issue for each so that
1213
- we can consider how to change our heuristics.
1214
-
1215
- {unlabeled}
1216
-
1217
1156
#### Untriaged Pull Requests
1218
1157
1219
1158
{untriaged}
@@ -1233,7 +1172,6 @@ TODO: Nags
1233
1172
regressions = regressions. join( "\n \n " ) ,
1234
1173
improvements = improvements. join( "\n \n " ) ,
1235
1174
mixed = mixed. join( "\n \n " ) ,
1236
- unlabeled = unlabeled. join( "\n \n " ) ,
1237
1175
untriaged = untriaged
1238
1176
)
1239
1177
}
@@ -1486,6 +1424,5 @@ mod tests {
1486
1424
newly_failed_benchmarks : Default :: default ( ) ,
1487
1425
} ;
1488
1426
ComparisonSummary :: summarize_comparison ( & comparison)
1489
- . unwrap_or_else ( || ComparisonSummary :: empty ( ) )
1490
1427
}
1491
1428
}
0 commit comments