@@ -3,7 +3,7 @@ use crate::comparison::{ComparisonSummary, Direction};
3
3
use crate :: load:: { Config , SiteCtxt , TryCommit } ;
4
4
5
5
use anyhow:: Context as _;
6
- use database:: ArtifactId ;
6
+ use database:: { ArtifactId , QueuedCommit } ;
7
7
use hashbrown:: HashSet ;
8
8
use reqwest:: header:: USER_AGENT ;
9
9
use serde:: { Deserialize , Serialize } ;
@@ -509,92 +509,117 @@ pub async fn post_finished(ctxt: &SiteCtxt) {
509
509
}
510
510
let conn = ctxt. conn ( ) . await ;
511
511
let index = ctxt. index . load ( ) ;
512
- let mut commits = index
512
+ let mut already_tested_commits = index
513
513
. commits ( )
514
514
. into_iter ( )
515
515
. map ( |c| c. sha . to_string ( ) )
516
516
. collect :: < HashSet < _ > > ( ) ;
517
- let queued = conn. queued_commits ( ) . await ;
517
+ let ( master_commits, queued_pr_commits, in_progress_artifacts) = futures:: join!(
518
+ collector:: master_commits( ) ,
519
+ conn. queued_commits( ) ,
520
+ conn. in_progress_artifacts( )
521
+ ) ;
522
+ let master_commits = master_commits
523
+ . unwrap ( )
524
+ . into_iter ( )
525
+ . map ( |c| c. sha )
526
+ . collect :: < HashSet < _ > > ( ) ;
518
527
519
- for aid in conn . in_progress_artifacts ( ) . await {
528
+ for aid in in_progress_artifacts {
520
529
match aid {
521
530
ArtifactId :: Commit ( c) => {
522
- commits . remove ( & c. sha ) ;
531
+ already_tested_commits . remove ( & c. sha ) ;
523
532
}
524
533
ArtifactId :: Tag ( _) => {
525
- // do nothing, for now, though eventually we'll want an artifact
526
- // queue
534
+ // do nothing, for now, though eventually we'll want an artifact queue
527
535
}
528
536
}
529
537
}
530
- for commit in queued {
531
- if !commits. contains ( & commit. sha ) {
532
- continue ;
533
- }
534
-
535
- // This commit has been benchmarked.
536
-
538
+ for commit in queued_pr_commits
539
+ . into_iter ( )
540
+ . filter ( |c| already_tested_commits. contains ( & c. sha ) )
541
+ {
537
542
if let Some ( completed) = conn. mark_complete ( & commit. sha ) . await {
538
543
assert_eq ! ( completed, commit) ;
539
544
540
- let comparison_url = format ! (
541
- "https://perf.rust-lang.org/compare.html?start={}&end={}" ,
542
- commit. parent_sha, commit. sha
543
- ) ;
544
- let ( summary, direction) = categorize_benchmark ( & commit, ctxt) . await ;
545
- let label = match direction {
546
- Some ( Direction :: Regression | Direction :: Mixed ) => "+perf-regression" ,
547
- Some ( Direction :: Improvement ) | None => "-perf-regression" ,
548
- } ;
549
- let msg = direction
550
- . map ( |d| {
551
- format ! (
552
- "While you can manually mark this PR as fit \
545
+ let is_master_commit = master_commits. contains ( & commit. sha ) ;
546
+ post_comparison_comment ( commit, ctxt, is_master_commit) . await ;
547
+ }
548
+ }
549
+ }
550
+
551
+ async fn post_comparison_comment ( commit : QueuedCommit , ctxt : & SiteCtxt , is_master_commit : bool ) {
552
+ let comparison_url = format ! (
553
+ "https://perf.rust-lang.org/compare.html?start={}&end={}" ,
554
+ commit. parent_sha, commit. sha
555
+ ) ;
556
+ let ( summary, direction) =
557
+ categorize_benchmark ( commit. sha . clone ( ) , commit. parent_sha , ctxt) . await ;
558
+ let label = match direction {
559
+ Some ( Direction :: Regression | Direction :: Mixed ) => "+perf-regression" ,
560
+ Some ( Direction :: Improvement ) | None => "-perf-regression" ,
561
+ } ;
562
+ let next_steps_msg = direction
563
+ . map ( |d| {
564
+ format ! (
565
+ "{}{}" ,
566
+ if is_master_commit {
567
+ ""
568
+ } else {
569
+ "While you can manually mark this PR as fit \
553
570
for rollup, we strongly recommend not doing so since this PR led to changes in \
554
- compiler perf.{}",
555
- match d {
556
- Direction :: Regression | Direction :: Mixed =>
557
- "\n \n **Next Steps**: If you can justify the \
571
+ compiler perf."
572
+ } ,
573
+ match d {
574
+ Direction :: Regression | Direction :: Mixed =>
575
+ "\n \n **Next Steps**: If you can justify the \
558
576
regressions found in this perf run, please indicate this with \
559
577
`@rustbot label: +perf-regression-triaged` along with \
560
578
sufficient written justification. If you cannot justify the regressions \
561
- please fix the regressions and do another perf run. If the next run shows \
562
- neutral or positive results, the label will be automatically removed.",
563
- Direction :: Improvement => "" ,
564
- }
565
- )
566
- } )
567
- . unwrap_or ( String :: new ( ) ) ;
568
-
569
- post_comment (
570
- & ctxt. config ,
571
- commit. pr ,
572
- format ! (
573
- "Finished benchmarking try commit ({}): [comparison url]({}).
579
+ please fix the regressions (either in this PR if it's not yet merged or \
580
+ in another PR) and do another perf run.",
581
+ Direction :: Improvement => "" ,
582
+ }
583
+ )
584
+ } )
585
+ . unwrap_or ( String :: new ( ) ) ;
586
+ let rollup_msg = if is_master_commit {
587
+ ""
588
+ } else {
589
+ "Benchmarking this pull request likely means that it is \
590
+ perf-sensitive, so we're automatically marking it as not fit \
591
+ for rolling up. "
592
+ } ;
593
+ let bors_msg = if is_master_commit {
594
+ ""
595
+ } else {
596
+ "@bors rollup=never\n "
597
+ } ;
598
+ post_comment (
599
+ & ctxt. config ,
600
+ commit. pr ,
601
+ format ! (
602
+ "Finished benchmarking commit ({}): [comparison url]({}).
574
603
575
604
**Summary**: {}
576
605
577
- Benchmarking this pull request likely means that it is \
578
- perf-sensitive, so we're automatically marking it as not fit \
579
- for rolling up. {}
580
-
581
- @bors rollup=never
606
+ {}{}
607
+ {}
582
608
@rustbot label: +S-waiting-on-review -S-waiting-on-perf {}" ,
583
- commit. sha, comparison_url, summary, msg, label
584
- ) ,
585
- )
586
- . await ;
587
- }
588
- }
609
+ commit. sha, comparison_url, summary, rollup_msg, next_steps_msg, bors_msg, label
610
+ ) ,
611
+ )
612
+ . await ;
589
613
}
590
614
591
615
async fn categorize_benchmark (
592
- commit : & database:: QueuedCommit ,
616
+ commit_sha : String ,
617
+ parent_sha : String ,
593
618
ctxt : & SiteCtxt ,
594
619
) -> ( String , Option < Direction > ) {
595
620
let comparison = match crate :: comparison:: compare (
596
- collector:: Bound :: Commit ( commit . parent_sha . clone ( ) ) ,
597
- collector:: Bound :: Commit ( commit . sha . clone ( ) ) ,
621
+ collector:: Bound :: Commit ( parent_sha) ,
622
+ collector:: Bound :: Commit ( commit_sha ) ,
598
623
"instructions:u" . to_owned ( ) ,
599
624
ctxt,
600
625
)
0 commit comments