@@ -158,30 +158,21 @@ pub struct SelfProfilerRef {
158158 // actually enabled.
159159 event_filter_mask : EventFilter ,
160160
161- // Print verbose generic activities to stdout
161+ // Print verbose generic activities to stderr?
162162 print_verbose_generic_activities : bool ,
163-
164- // Print extra verbose generic activities to stdout
165- print_extra_verbose_generic_activities : bool ,
166163}
167164
168165impl SelfProfilerRef {
169166 pub fn new (
170167 profiler : Option < Arc < SelfProfiler > > ,
171168 print_verbose_generic_activities : bool ,
172- print_extra_verbose_generic_activities : bool ,
173169 ) -> SelfProfilerRef {
174170 // If there is no SelfProfiler then the filter mask is set to NONE,
175171 // ensuring that nothing ever tries to actually access it.
176172 let event_filter_mask =
177173 profiler. as_ref ( ) . map_or ( EventFilter :: empty ( ) , |p| p. event_filter_mask ) ;
178174
179- SelfProfilerRef {
180- profiler,
181- event_filter_mask,
182- print_verbose_generic_activities,
183- print_extra_verbose_generic_activities,
184- }
175+ SelfProfilerRef { profiler, event_filter_mask, print_verbose_generic_activities }
185176 }
186177
187178 /// This shim makes sure that calls only get executed if the filter mask
@@ -214,7 +205,7 @@ impl SelfProfilerRef {
214205 /// Start profiling a verbose generic activity. Profiling continues until the
215206 /// VerboseTimingGuard returned from this call is dropped. In addition to recording
216207 /// a measureme event, "verbose" generic activities also print a timing entry to
217- /// stdout if the compiler is invoked with -Ztime or -Ztime-passes.
208+ /// stderr if the compiler is invoked with -Ztime-passes.
218209 pub fn verbose_generic_activity < ' a > (
219210 & ' a self ,
220211 event_label : & ' static str ,
@@ -225,19 +216,16 @@ impl SelfProfilerRef {
225216 VerboseTimingGuard :: start ( message, self . generic_activity ( event_label) )
226217 }
227218
228- /// Start profiling an extra verbose generic activity. Profiling continues until the
229- /// VerboseTimingGuard returned from this call is dropped. In addition to recording
230- /// a measureme event, "extra verbose" generic activities also print a timing entry to
231- /// stdout if the compiler is invoked with -Ztime-passes.
232- pub fn extra_verbose_generic_activity < ' a , A > (
219+ /// Like `verbose_generic_activity`, but with an extra arg.
220+ pub fn verbose_generic_activity_with_arg < ' a , A > (
233221 & ' a self ,
234222 event_label : & ' static str ,
235223 event_arg : A ,
236224 ) -> VerboseTimingGuard < ' a >
237225 where
238226 A : Borrow < str > + Into < String > ,
239227 {
240- let message = if self . print_extra_verbose_generic_activities {
228+ let message = if self . print_verbose_generic_activities {
241229 Some ( format ! ( "{}({})" , event_label, event_arg. borrow( ) ) )
242230 } else {
243231 None
@@ -745,27 +733,9 @@ impl Drop for VerboseTimingGuard<'_> {
745733 if let Some ( ( start_time, start_rss, ref message) ) = self . start_and_message {
746734 let end_rss = get_resident_set_size ( ) ;
747735 let dur = start_time. elapsed ( ) ;
748-
749- if should_print_passes ( dur, start_rss, end_rss) {
750- print_time_passes_entry ( & message, dur, start_rss, end_rss) ;
751- }
752- }
753- }
754- }
755-
756- fn should_print_passes ( dur : Duration , start_rss : Option < usize > , end_rss : Option < usize > ) -> bool {
757- if dur. as_millis ( ) > 5 {
758- return true ;
759- }
760-
761- if let ( Some ( start_rss) , Some ( end_rss) ) = ( start_rss, end_rss) {
762- let change_rss = end_rss. abs_diff ( start_rss) ;
763- if change_rss > 0 {
764- return true ;
736+ print_time_passes_entry ( & message, dur, start_rss, end_rss) ;
765737 }
766738 }
767-
768- false
769739}
770740
771741pub fn print_time_passes_entry (
@@ -774,6 +744,26 @@ pub fn print_time_passes_entry(
774744 start_rss : Option < usize > ,
775745 end_rss : Option < usize > ,
776746) {
747+ // Print the pass if its duration is greater than 5 ms, or it changed the
748+ // measured RSS.
749+ let is_notable = || {
750+ if dur. as_millis ( ) > 5 {
751+ return true ;
752+ }
753+
754+ if let ( Some ( start_rss) , Some ( end_rss) ) = ( start_rss, end_rss) {
755+ let change_rss = end_rss. abs_diff ( start_rss) ;
756+ if change_rss > 0 {
757+ return true ;
758+ }
759+ }
760+
761+ false
762+ } ;
763+ if !is_notable ( ) {
764+ return ;
765+ }
766+
777767 let rss_to_mb = |rss| ( rss as f64 / 1_000_000.0 ) . round ( ) as usize ;
778768 let rss_change_to_mb = |rss| ( rss as f64 / 1_000_000.0 ) . round ( ) as i128 ;
779769
0 commit comments