1
1
use crate :: api:: github:: Issue ;
2
2
use crate :: comparison:: {
3
- deserves_attention_icount, deserves_attention_maxrss , write_summary_table ,
4
- write_summary_table_footer , ArtifactComparisonSummary , Direction , Stat ,
3
+ deserves_attention_icount, write_summary_table , write_summary_table_footer ,
4
+ ArtifactComparisonSummary , Direction , Stat ,
5
5
} ;
6
6
use crate :: load:: { Config , SiteCtxt , TryCommit } ;
7
7
@@ -11,7 +11,9 @@ use reqwest::header::USER_AGENT;
11
11
use serde:: { Deserialize , Serialize } ;
12
12
13
13
use collector:: category:: Category ;
14
+
14
15
use std:: collections:: { HashMap , HashSet } ;
16
+
15
17
use std:: { fmt:: Write , sync:: Arc , time:: Duration } ;
16
18
17
19
type BoxedError = Box < dyn std:: error:: Error + Send + Sync > ;
@@ -578,6 +580,40 @@ fn make_comparison_url(commit: &QueuedCommit, stat: Stat) -> String {
578
580
}
579
581
580
582
async fn summarize_run ( ctxt : & SiteCtxt , commit : QueuedCommit , is_master_commit : bool ) -> String {
583
+ let benchmark_map = ctxt. get_benchmark_category_map ( ) . await ;
584
+
585
+ let mut message = format ! (
586
+ "Finished benchmarking commit ({sha}): [comparison url]({comparison_url}).
587
+
588
+ **Summary**: " ,
589
+ sha = commit. sha,
590
+ comparison_url = make_comparison_url( & commit, Stat :: Instructions )
591
+ ) ;
592
+
593
+ let mut table_written = false ;
594
+ let stats = vec ! [
595
+ ( "Instruction count" , Stat :: Instructions , false ) ,
596
+ ( "Max RSS (memory usage)" , Stat :: MaxRSS , true ) ,
597
+ ( "Cycles" , Stat :: Cycles , true ) ,
598
+ ] ;
599
+
600
+ for ( title, stat, hidden) in stats {
601
+ table_written |= write_stat_summary (
602
+ & benchmark_map,
603
+ & commit,
604
+ ctxt,
605
+ & title,
606
+ stat,
607
+ hidden,
608
+ & mut message,
609
+ )
610
+ . await ;
611
+ }
612
+
613
+ if table_written {
614
+ write_summary_table_footer ( & mut message) ;
615
+ }
616
+
581
617
let comparison = match crate :: comparison:: compare (
582
618
collector:: Bound :: Commit ( commit. parent_sha . clone ( ) ) ,
583
619
collector:: Bound :: Commit ( commit. sha . clone ( ) ) ,
@@ -589,7 +625,6 @@ async fn summarize_run(ctxt: &SiteCtxt, commit: QueuedCommit, is_master_commit:
589
625
Ok ( Some ( c) ) => c,
590
626
_ => return String :: from ( "ERROR categorizing benchmark run!" ) ,
591
627
} ;
592
-
593
628
let errors = if !comparison. newly_failed_benchmarks . is_empty ( ) {
594
629
let benchmarks = comparison
595
630
. newly_failed_benchmarks
@@ -601,93 +636,28 @@ async fn summarize_run(ctxt: &SiteCtxt, commit: QueuedCommit, is_master_commit:
601
636
} else {
602
637
String :: new ( )
603
638
} ;
604
-
605
- let benchmark_map = ctxt. get_benchmark_category_map ( ) . await ;
606
639
let ( primary, secondary) = comparison. summarize_by_category ( & benchmark_map) ;
607
640
608
641
const DISAGREEMENT : & str = "If you disagree with this performance assessment, \
609
642
please file an issue in [rust-lang/rustc-perf](https://github.com/rust-lang/rustc-perf/issues/new).";
610
643
let footer = format ! ( "{DISAGREEMENT}{errors}" ) ;
611
644
612
- let inst_comparison_url = make_comparison_url ( & commit, Stat :: Instructions ) ;
613
- let mut message = format ! (
614
- "Finished benchmarking commit ({sha}): [comparison url]({inst_comparison_url}).
615
-
616
- **Summary**: " ,
617
- sha = commit. sha,
618
- ) ;
619
-
620
- let mut table_written = false ;
621
-
622
- write ! (
623
- & mut message,
624
- "## [Instruction count]({inst_comparison_url})"
625
- )
626
- . unwrap ( ) ;
627
- if !primary. is_relevant ( ) && !secondary. is_relevant ( ) {
628
- write ! (
629
- & mut message,
630
- "This benchmark run did not return any relevant results.\n "
631
- )
632
- . unwrap ( ) ;
633
- } else {
634
- let primary_short_summary = generate_short_summary ( & primary) ;
635
- let secondary_short_summary = generate_short_summary ( & secondary) ;
636
-
637
- write ! (
638
- & mut message,
639
- r#"
640
- - Primary benchmarks: {primary_short_summary}
641
- - Secondary benchmarks: {secondary_short_summary}
642
-
643
- "#
644
- )
645
- . unwrap ( ) ;
646
-
647
- write_summary_table ( & primary, & secondary, true , & mut message) ;
648
- table_written = true ;
649
- }
650
-
651
- if let Some ( ( primary, secondary) ) = analyze_secondary_stat (
652
- ctxt,
653
- & commit,
654
- Stat :: MaxRSS ,
655
- & benchmark_map,
656
- deserves_attention_maxrss,
657
- )
658
- . await
659
- {
660
- write ! (
661
- & mut message,
662
- "\n ## [Max RSS]({})" ,
663
- make_comparison_url( & commit, Stat :: MaxRSS )
664
- )
665
- . unwrap ( ) ;
666
- write_summary_table ( & primary, & secondary, true , & mut message) ;
667
- table_written = true ;
668
- }
669
-
670
- if table_written {
671
- write_summary_table_footer ( & mut message) ;
672
- }
673
-
674
645
let direction = primary. direction ( ) . or ( secondary. direction ( ) ) ;
675
646
let next_steps = next_steps ( primary, secondary, direction, is_master_commit) ;
676
647
write ! ( & mut message, "\n {footer}\n {next_steps}" ) . unwrap ( ) ;
677
648
678
649
message
679
650
}
680
651
681
- async fn analyze_secondary_stat < F > (
682
- ctxt : & SiteCtxt ,
652
+ async fn write_stat_summary (
653
+ benchmark_map : & HashMap < Benchmark , Category > ,
683
654
commit : & QueuedCommit ,
655
+ ctxt : & SiteCtxt ,
656
+ title : & str ,
684
657
stat : Stat ,
685
- benchmark_map : & HashMap < Benchmark , Category > ,
686
- is_interesting : F ,
687
- ) -> Option < ( ArtifactComparisonSummary , ArtifactComparisonSummary ) >
688
- where
689
- F : FnOnce ( & ArtifactComparisonSummary , & ArtifactComparisonSummary ) -> bool ,
690
- {
658
+ hidden : bool ,
659
+ message : & mut String ,
660
+ ) -> bool {
691
661
let comparison = match crate :: comparison:: compare (
692
662
collector:: Bound :: Commit ( commit. parent_sha . clone ( ) ) ,
693
663
collector:: Bound :: Commit ( commit. sha . clone ( ) ) ,
@@ -697,18 +667,44 @@ where
697
667
. await
698
668
{
699
669
Ok ( Some ( c) ) => c,
700
- _ => return None ,
670
+ _ => panic ! ( ) , // return Err("ERROR categorizing benchmark run!".to_owned()) ,
701
671
} ;
702
672
673
+ message. push_str ( & format ! (
674
+ "## [{title}]({})\n " ,
675
+ make_comparison_url( commit, stat)
676
+ ) ) ;
677
+
703
678
let ( primary, secondary) = comparison. summarize_by_category ( benchmark_map) ;
704
679
if !primary. is_relevant ( ) && !secondary. is_relevant ( ) {
705
- return None ;
706
- }
707
-
708
- if is_interesting ( & primary, & secondary) {
709
- Some ( ( primary, secondary) )
680
+ message
681
+ . push_str ( "This benchmark run did not return any relevant results for this metric.\n " ) ;
682
+ false
710
683
} else {
711
- None
684
+ let primary_short_summary = generate_short_summary ( & primary) ;
685
+ let secondary_short_summary = generate_short_summary ( & secondary) ;
686
+
687
+ if hidden {
688
+ message. push_str ( "<details>\n <summary>Results</summary>\n \n " ) ;
689
+ }
690
+
691
+ write ! (
692
+ message,
693
+ r#"
694
+ - Primary benchmarks: {primary_short_summary}
695
+ - Secondary benchmarks: {secondary_short_summary}
696
+
697
+ "#
698
+ )
699
+ . unwrap ( ) ;
700
+
701
+ write_summary_table ( & primary, & secondary, true , message) ;
702
+
703
+ if hidden {
704
+ message. push_str ( "</details>\n " ) ;
705
+ }
706
+
707
+ true
712
708
}
713
709
}
714
710
0 commit comments