@@ -10,7 +10,7 @@ use crate::selector::{self, Tag};
1010
1111use collector:: category:: Category ;
1212use collector:: Bound ;
13- use serde:: Serialize ;
13+ use serde:: { Deserialize , Serialize } ;
1414
1515use std:: cmp:: Ordering ;
1616use std:: collections:: { HashMap , HashSet } ;
@@ -45,11 +45,11 @@ pub async fn handle_triage(
4545 let mut before = start. clone ( ) ;
4646
4747 let mut num_comparisons = 0 ;
48- let stat = "instructions:u" . to_owned ( ) ;
48+ let stat = Stat :: Instructions ;
4949 let benchmark_map = ctxt. get_benchmark_category_map ( ) . await ;
5050 loop {
5151 let comparison =
52- match compare_given_commits ( before, next. clone ( ) , stat. clone ( ) , ctxt, & master_commits)
52+ match compare_given_commits ( before, next. clone ( ) , stat, ctxt, & master_commits)
5353 . await
5454 . map_err ( |e| format ! ( "error comparing commits: {}" , e) ) ?
5555 {
@@ -172,14 +172,46 @@ async fn populate_report(
172172 ( None , None ) => return ,
173173 } ;
174174
175- let include_in_triage = deserves_attention ( & primary, & secondary) ;
175+ let include_in_triage = deserves_attention_icount ( & primary, & secondary) ;
176176
177177 if include_in_triage {
178178 let entry = report. entry ( direction) . or_default ( ) ;
179179 entry. push ( write_triage_summary ( comparison, & primary, & secondary) . await ) ;
180180 }
181181}
182182
183+ #[ derive( Copy , Clone , Debug , PartialEq , Serialize , Deserialize ) ]
184+ pub enum Stat {
185+ #[ serde( rename = "instructions:u" ) ]
186+ Instructions ,
187+ #[ serde( rename = "cycles:u" ) ]
188+ Cycles ,
189+ #[ serde( rename = "faults" ) ]
190+ Faults ,
191+ #[ serde( rename = "max-rss" ) ]
192+ MaxRSS ,
193+ #[ serde( rename = "task-clock" ) ]
194+ TaskClock ,
195+ #[ serde( rename = "wall-time" ) ]
196+ WallTime ,
197+ #[ serde( rename = "cpu-clock" ) ]
198+ CpuClock ,
199+ }
200+
201+ impl Stat {
202+ pub fn as_str ( & self ) -> & ' static str {
203+ match self {
204+ Self :: Instructions => "instructions:u" ,
205+ Self :: Cycles => "cycles:u" ,
206+ Self :: Faults => "faults" ,
207+ Self :: MaxRSS => "max-rss" ,
208+ Self :: TaskClock => "task-clock" ,
209+ Self :: WallTime => "wall-time" ,
210+ Self :: CpuClock => "cpu-clock" ,
211+ }
212+ }
213+ }
214+
183215/// A summary of a given comparison
184216///
185217/// This summary only includes changes that are significant and relevant (as determined by a change's magnitude).
@@ -367,7 +399,7 @@ impl ArtifactComparisonSummary {
367399///
368400/// For example, this can be used to determine if artifact comparisons with regressions should be labeled with the
369401/// `perf-regression` GitHub label or should be shown in the perf triage report.
370- pub ( crate ) fn deserves_attention (
402+ pub ( crate ) fn deserves_attention_icount (
371403 primary : & ArtifactComparisonSummary ,
372404 secondary : & ArtifactComparisonSummary ,
373405) -> bool {
@@ -384,6 +416,21 @@ pub(crate) fn deserves_attention(
384416 }
385417}
386418
419+ pub ( crate ) fn deserves_attention_maxrss (
420+ primary : & ArtifactComparisonSummary ,
421+ secondary : & ArtifactComparisonSummary ,
422+ ) -> bool {
423+ let primary_big_changes = primary
424+ . improvements ( )
425+ . filter ( |comparison| comparison. magnitude ( ) >= Magnitude :: Large )
426+ . count ( ) ;
427+ let secondary_big_changes = secondary
428+ . improvements ( )
429+ . filter ( |comparison| comparison. magnitude ( ) >= Magnitude :: Large )
430+ . count ( ) ;
431+ primary_big_changes >= 10 || secondary_big_changes >= 20
432+ }
433+
387434async fn write_triage_summary (
388435 comparison : & ArtifactComparison ,
389436 primary : & ArtifactComparisonSummary ,
@@ -554,7 +601,7 @@ pub fn write_summary_table_footer(result: &mut String) {
554601pub async fn compare (
555602 start : Bound ,
556603 end : Bound ,
557- stat : String ,
604+ stat : Stat ,
558605 ctxt : & SiteCtxt ,
559606) -> Result < Option < ArtifactComparison > , BoxedError > {
560607 let master_commits = & ctxt. get_master_commits ( ) . commits ;
@@ -566,7 +613,7 @@ pub async fn compare(
566613async fn compare_given_commits (
567614 start : Bound ,
568615 end : Bound ,
569- stat : String ,
616+ stat : Stat ,
570617 ctxt : & SiteCtxt ,
571618 master_commits : & [ collector:: MasterCommit ] ,
572619) -> Result < Option < ArtifactComparison > , BoxedError > {
@@ -585,7 +632,7 @@ async fn compare_given_commits(
585632 . set :: < String > ( Tag :: Benchmark , selector:: Selector :: All )
586633 . set :: < String > ( Tag :: Scenario , selector:: Selector :: All )
587634 . set :: < String > ( Tag :: Profile , selector:: Selector :: All )
588- . set ( Tag :: Metric , selector:: Selector :: One ( stat. clone ( ) ) ) ;
635+ . set ( Tag :: Metric , selector:: Selector :: One ( stat. as_str ( ) ) ) ;
589636
590637 // `responses` contains series iterators. The first element in the iterator is the data
591638 // for `a` and the second is the data for `b`
@@ -832,7 +879,7 @@ impl HistoricalDataMap {
832879 ctxt : & SiteCtxt ,
833880 from : ArtifactId ,
834881 master_commits : & [ collector:: MasterCommit ] ,
835- stat : String ,
882+ stat : Stat ,
836883 ) -> Result < Self , BoxedError > {
837884 let mut historical_data = HashMap :: new ( ) ;
838885
@@ -854,7 +901,7 @@ impl HistoricalDataMap {
854901 . set :: < String > ( Tag :: Benchmark , selector:: Selector :: All )
855902 . set :: < String > ( Tag :: Scenario , selector:: Selector :: All )
856903 . set :: < String > ( Tag :: Profile , selector:: Selector :: All )
857- . set ( Tag :: Metric , selector:: Selector :: One ( stat) ) ;
904+ . set ( Tag :: Metric , selector:: Selector :: One ( stat. as_str ( ) ) ) ;
858905
859906 let mut previous_commit_series = ctxt
860907 . statistic_series ( query, previous_commits. clone ( ) )
0 commit comments