@@ -146,37 +146,39 @@ 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 ( Direction :: Improvement ) , Some ( _) | None ) => Direction :: Improvement ,
157
+ ( Some ( Direction :: Regression ) , Some ( _) | None ) => Direction :: Regression ,
158
+ ( Some ( Direction :: Mixed ) , Some ( _) | None ) => Direction :: Mixed ,
159
+ ( None , Some ( d) ) => d,
160
+ ( None , None ) => return ,
161
+ } ;
162
+
163
+ let entry = report. entry ( direction) . or_default ( ) ;
164
+
165
+ entry. push ( write_triage_summary ( comparison, & primary, & secondary) . await )
163
166
}
164
167
165
168
/// A summary of a given comparison
166
169
///
167
170
/// This summary only includes changes that are significant and relevant (as determined by a change's magnitude).
168
171
pub struct ComparisonSummary {
169
- /// Significant comparisons of magnitude small and above
170
- /// and ordered by magnitude from largest to smallest
171
- comparisons : Vec < TestResultComparison > ,
172
+ /// Relevant comparisons ordered by magnitude from largest to smallest
173
+ relevant_comparisons : Vec < TestResultComparison > ,
172
174
/// The cached number of comparisons that are improvements
173
175
num_improvements : usize ,
174
176
/// The cached number of comparisons that are regressions
175
177
num_regressions : usize ,
176
178
}
177
179
178
180
impl ComparisonSummary {
179
- pub fn summarize_comparison ( comparison : & Comparison ) -> Option < Self > {
181
+ pub fn summarize_comparison ( comparison : & Comparison ) -> Self {
180
182
let mut num_improvements = 0 ;
181
183
let mut num_regressions = 0 ;
182
184
@@ -193,10 +195,6 @@ impl ComparisonSummary {
193
195
} )
194
196
. cloned ( )
195
197
. 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
198
201
199
let cmp = |b1 : & TestResultComparison , b2 : & TestResultComparison | {
202
200
b2. relative_change ( )
@@ -206,29 +204,23 @@ impl ComparisonSummary {
206
204
} ;
207
205
comparisons. sort_by ( cmp) ;
208
206
209
- Some ( ComparisonSummary {
210
- comparisons,
207
+ ComparisonSummary {
208
+ relevant_comparisons : comparisons,
211
209
num_improvements,
212
210
num_regressions,
213
- } )
214
- }
215
-
216
- pub fn empty ( ) -> Self {
217
- ComparisonSummary {
218
- comparisons : vec ! [ ] ,
219
- num_improvements : 0 ,
220
- num_regressions : 0 ,
221
211
}
222
212
}
223
213
224
214
/// The direction of the changes
225
215
pub fn direction ( & self ) -> Option < Direction > {
226
- if self . comparisons . len ( ) == 0 {
216
+ if self . relevant_comparisons . len ( ) == 0 {
227
217
return None ;
228
218
}
229
219
230
- let ( regressions, improvements) : ( Vec < & TestResultComparison > , _ ) =
231
- self . comparisons . iter ( ) . partition ( |c| c. is_regression ( ) ) ;
220
+ let ( regressions, improvements) : ( Vec < & TestResultComparison > , _ ) = self
221
+ . relevant_comparisons
222
+ . iter ( )
223
+ . partition ( |c| c. is_regression ( ) ) ;
232
224
233
225
if regressions. len ( ) == 0 {
234
226
return Some ( Direction :: Improvement ) ;
@@ -238,7 +230,7 @@ impl ComparisonSummary {
238
230
return Some ( Direction :: Regression ) ;
239
231
}
240
232
241
- let total_num = self . comparisons . len ( ) ;
233
+ let total_num = self . relevant_comparisons . len ( ) ;
242
234
let regressions_ratio = regressions. len ( ) as f64 / total_num as f64 ;
243
235
244
236
let has_medium_and_above_regressions = regressions
@@ -300,18 +292,11 @@ impl ComparisonSummary {
300
292
301
293
/// Arithmetic mean of all changes as a percent
302
294
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 ( )
295
+ self . arithmetic_mean ( self . relevant_comparisons . iter ( ) )
311
296
}
312
297
313
298
pub fn is_empty ( & self ) -> bool {
314
- self . comparisons . is_empty ( )
299
+ self . relevant_comparisons . is_empty ( )
315
300
}
316
301
317
302
fn arithmetic_mean < ' a > (
@@ -329,45 +314,38 @@ impl ComparisonSummary {
329
314
}
330
315
331
316
fn improvements ( & self ) -> impl Iterator < Item = & TestResultComparison > {
332
- self . comparisons . iter ( ) . filter ( |c| c. is_improvement ( ) )
317
+ self . relevant_comparisons
318
+ . iter ( )
319
+ . filter ( |c| c. is_improvement ( ) )
333
320
}
334
321
335
322
fn regressions ( & self ) -> impl Iterator < Item = & TestResultComparison > {
336
- self . comparisons . iter ( ) . filter ( |c| c. is_regression ( ) )
323
+ self . relevant_comparisons
324
+ . iter ( )
325
+ . filter ( |c| c. is_regression ( ) )
337
326
}
338
327
339
328
fn largest_improvement ( & self ) -> Option < & TestResultComparison > {
340
- self . comparisons . iter ( ) . find ( |s| s. is_improvement ( ) )
329
+ self . relevant_comparisons
330
+ . iter ( )
331
+ . find ( |s| s. is_improvement ( ) )
341
332
}
342
333
343
334
fn largest_regression ( & self ) -> Option < & TestResultComparison > {
344
- self . comparisons . iter ( ) . find ( |s| s. is_regression ( ) )
335
+ self . relevant_comparisons . iter ( ) . find ( |s| s. is_regression ( ) )
345
336
}
346
337
347
338
/// 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
- }
339
+ pub fn is_relevant ( & self ) -> bool {
340
+ !self . is_empty ( )
367
341
}
368
342
}
369
343
370
- async fn write_triage_summary ( ctxt : & SiteCtxt , comparison : & Comparison ) -> String {
344
+ async fn write_triage_summary (
345
+ comparison : & Comparison ,
346
+ primary : & ComparisonSummary ,
347
+ secondary : & ComparisonSummary ,
348
+ ) -> String {
371
349
use std:: fmt:: Write ;
372
350
let mut result = if let Some ( pr) = comparison. b . pr {
373
351
let title = github:: pr_title ( pr) . await ;
@@ -383,11 +361,6 @@ async fn write_triage_summary(ctxt: &SiteCtxt, comparison: &Comparison) -> Strin
383
361
let link = & compare_link ( start, end) ;
384
362
write ! ( & mut result, " [(Comparison Link)]({})\n " , link) . unwrap ( ) ;
385
363
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
364
write_summary_table ( & primary, & secondary, false , & mut result) ;
392
365
393
366
result
@@ -506,24 +479,6 @@ pub fn write_summary_table(
506
479
}
507
480
}
508
481
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
482
/// Compare two bounds on a given stat
528
483
///
529
484
/// Returns Ok(None) when no data for the end bound is present
@@ -782,7 +737,7 @@ impl Comparison {
782
737
pub fn summarize_by_category (
783
738
self ,
784
739
category_map : HashMap < Benchmark , Category > ,
785
- ) -> ( Option < ComparisonSummary > , Option < ComparisonSummary > ) {
740
+ ) -> ( ComparisonSummary , ComparisonSummary ) {
786
741
let ( primary, secondary) = self
787
742
. statistics
788
743
. into_iter ( )
@@ -1146,7 +1101,7 @@ impl Magnitude {
1146
1101
async fn generate_report (
1147
1102
start : & Bound ,
1148
1103
end : & Bound ,
1149
- mut report : HashMap < Option < Direction > , Vec < String > > ,
1104
+ mut report : HashMap < Direction , Vec < String > > ,
1150
1105
num_comparisons : usize ,
1151
1106
) -> String {
1152
1107
fn fmt_bound ( bound : & Bound ) -> String {
@@ -1158,14 +1113,9 @@ async fn generate_report(
1158
1113
}
1159
1114
let start = fmt_bound ( start) ;
1160
1115
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 ( ) ;
1116
+ let regressions = report. remove ( & Direction :: Regression ) . unwrap_or_default ( ) ;
1117
+ let improvements = report. remove ( & Direction :: Improvement ) . unwrap_or_default ( ) ;
1118
+ let mixed = report. remove ( & Direction :: Mixed ) . unwrap_or_default ( ) ;
1169
1119
let untriaged = match github:: untriaged_perf_regressions ( ) . await {
1170
1120
Ok ( u) => u
1171
1121
. iter ( )
@@ -1205,15 +1155,6 @@ Revision range: [{first_commit}..{last_commit}](https://perf.rust-lang.org/?star
1205
1155
1206
1156
{mixed}
1207
1157
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
1158
#### Untriaged Pull Requests
1218
1159
1219
1160
{untriaged}
@@ -1233,7 +1174,6 @@ TODO: Nags
1233
1174
regressions = regressions. join( "\n \n " ) ,
1234
1175
improvements = improvements. join( "\n \n " ) ,
1235
1176
mixed = mixed. join( "\n \n " ) ,
1236
- unlabeled = unlabeled. join( "\n \n " ) ,
1237
1177
untriaged = untriaged
1238
1178
)
1239
1179
}
@@ -1486,6 +1426,5 @@ mod tests {
1486
1426
newly_failed_benchmarks : Default :: default ( ) ,
1487
1427
} ;
1488
1428
ComparisonSummary :: summarize_comparison ( & comparison)
1489
- . unwrap_or_else ( || ComparisonSummary :: empty ( ) )
1490
1429
}
1491
1430
}
0 commit comments