1
1
use crate :: api:: github:: Issue ;
2
2
use crate :: comparison:: {
3
- deserves_attention, write_summary_table, ArtifactComparisonSummary , Direction ,
3
+ deserves_attention, write_summary_table, write_summary_table_footer, ArtifactComparisonSummary ,
4
+ Direction , Magnitude ,
4
5
} ;
5
6
use crate :: load:: { Config , SiteCtxt , TryCommit } ;
6
7
7
8
use anyhow:: Context as _;
8
- use database:: { ArtifactId , QueuedCommit } ;
9
+ use database:: { ArtifactId , Benchmark , QueuedCommit } ;
9
10
use reqwest:: header:: USER_AGENT ;
10
11
use serde:: { Deserialize , Serialize } ;
11
12
12
- use std:: collections:: HashSet ;
13
+ use collector:: category:: Category ;
14
+ use std:: collections:: { HashMap , HashSet } ;
13
15
use std:: { fmt:: Write , sync:: Arc , time:: Duration } ;
14
16
15
17
type BoxedError = Box < dyn std:: error:: Error + Send + Sync > ;
@@ -566,13 +568,21 @@ async fn post_comparison_comment(ctxt: &SiteCtxt, commit: QueuedCommit, is_maste
566
568
post_comment ( & ctxt. config , pr, body) . await ;
567
569
}
568
570
569
- async fn summarize_run ( ctxt : & SiteCtxt , commit : QueuedCommit , is_master_commit : bool ) -> String {
570
- let comparison_url = format ! (
571
+ fn make_comparison_url ( commit : & QueuedCommit , stat : Option < & str > ) -> String {
572
+ let mut url = format ! (
571
573
"https://perf.rust-lang.org/compare.html?start={}&end={}" ,
572
574
commit. parent_sha, commit. sha
573
575
) ;
576
+ if let Some ( stat) = stat {
577
+ write ! ( & mut url, "&stat={stat}" ) . unwrap ( ) ;
578
+ }
579
+ url
580
+ }
581
+
582
+ async fn summarize_run ( ctxt : & SiteCtxt , commit : QueuedCommit , is_master_commit : bool ) -> String {
583
+ let inst_comparison_url = make_comparison_url ( & commit, None ) ;
574
584
let comparison = match crate :: comparison:: compare (
575
- collector:: Bound :: Commit ( commit. parent_sha ) ,
585
+ collector:: Bound :: Commit ( commit. parent_sha . clone ( ) ) ,
576
586
collector:: Bound :: Commit ( commit. sha . clone ( ) ) ,
577
587
"instructions:u" . to_owned ( ) ,
578
588
ctxt,
@@ -603,12 +613,19 @@ async fn summarize_run(ctxt: &SiteCtxt, commit: QueuedCommit, is_master_commit:
603
613
let footer = format ! ( "{DISAGREEMENT}{errors}" ) ;
604
614
605
615
let mut message = format ! (
606
- "Finished benchmarking commit ({sha}): [comparison url]({comparison_url }).
616
+ "Finished benchmarking commit ({sha}): [comparison url]({inst_comparison_url }).
607
617
608
618
**Summary**: " ,
609
619
sha = commit. sha,
610
620
) ;
611
621
622
+ let mut table_written = false ;
623
+
624
+ write ! (
625
+ & mut message,
626
+ "## [Instruction count]({inst_comparison_url})"
627
+ )
628
+ . unwrap ( ) ;
612
629
if !primary. is_relevant ( ) && !secondary. is_relevant ( ) {
613
630
write ! (
614
631
& mut message,
@@ -630,6 +647,29 @@ async fn summarize_run(ctxt: &SiteCtxt, commit: QueuedCommit, is_master_commit:
630
647
. unwrap ( ) ;
631
648
632
649
write_summary_table ( & primary, & secondary, true , & mut message) ;
650
+ table_written = true ;
651
+ }
652
+
653
+ if let Some ( ( primary, secondary) ) = analyze_secondary_stat (
654
+ ctxt,
655
+ & commit,
656
+ "max-rss" ,
657
+ & benchmark_map,
658
+ is_max_rss_interesting,
659
+ )
660
+ . await
661
+ {
662
+ write ! (
663
+ & mut message,
664
+ "\n ## [Max RSS]({})" ,
665
+ make_comparison_url( & commit, Some ( "max-rss" ) )
666
+ )
667
+ . unwrap ( ) ;
668
+ write_summary_table ( & primary, & secondary, true , & mut message) ;
669
+ table_written = true ;
670
+ }
671
+
672
+ if table_written {
633
673
write_summary_table_footer ( & mut message) ;
634
674
}
635
675
@@ -640,6 +680,56 @@ async fn summarize_run(ctxt: &SiteCtxt, commit: QueuedCommit, is_master_commit:
640
680
message
641
681
}
642
682
683
+ // TODO: determine how should this work
684
+ // Should this be separate from `deserves_attention`?
685
+ fn is_max_rss_interesting (
686
+ primary : & ArtifactComparisonSummary ,
687
+ _secondary : & ArtifactComparisonSummary ,
688
+ ) -> bool {
689
+ if primary
690
+ . largest_change ( )
691
+ . map ( |c| c. magnitude ( ) >= Magnitude :: Large )
692
+ . unwrap_or ( false )
693
+ {
694
+ return true ;
695
+ }
696
+
697
+ primary. num_changes ( ) >= 20
698
+ }
699
+
700
+ async fn analyze_secondary_stat <
701
+ F : FnOnce ( & ArtifactComparisonSummary , & ArtifactComparisonSummary ) -> bool ,
702
+ > (
703
+ ctxt : & SiteCtxt ,
704
+ commit : & QueuedCommit ,
705
+ stat : & str ,
706
+ benchmark_map : & HashMap < Benchmark , Category > ,
707
+ is_interesting : F ,
708
+ ) -> Option < ( ArtifactComparisonSummary , ArtifactComparisonSummary ) > {
709
+ let comparison = match crate :: comparison:: compare (
710
+ collector:: Bound :: Commit ( commit. parent_sha . clone ( ) ) ,
711
+ collector:: Bound :: Commit ( commit. sha . clone ( ) ) ,
712
+ stat. to_string ( ) ,
713
+ ctxt,
714
+ )
715
+ . await
716
+ {
717
+ Ok ( Some ( c) ) => c,
718
+ _ => return None ,
719
+ } ;
720
+
721
+ let ( primary, secondary) = comparison. summarize_by_category ( benchmark_map) ;
722
+ if !primary. is_relevant ( ) && !secondary. is_relevant ( ) {
723
+ return None ;
724
+ }
725
+
726
+ if is_interesting ( & primary, & secondary) {
727
+ Some ( ( primary, secondary) )
728
+ } else {
729
+ None
730
+ }
731
+ }
732
+
643
733
fn next_steps (
644
734
primary : ArtifactComparisonSummary ,
645
735
secondary : ArtifactComparisonSummary ,
0 commit comments