@@ -158,30 +158,21 @@ pub struct SelfProfilerRef {
158
158
// actually enabled.
159
159
event_filter_mask : EventFilter ,
160
160
161
- // Print verbose generic activities to stdout
161
+ // Print verbose generic activities to stderr?
162
162
print_verbose_generic_activities : bool ,
163
-
164
- // Print extra verbose generic activities to stdout
165
- print_extra_verbose_generic_activities : bool ,
166
163
}
167
164
168
165
impl SelfProfilerRef {
169
166
pub fn new (
170
167
profiler : Option < Arc < SelfProfiler > > ,
171
168
print_verbose_generic_activities : bool ,
172
- print_extra_verbose_generic_activities : bool ,
173
169
) -> SelfProfilerRef {
174
170
// If there is no SelfProfiler then the filter mask is set to NONE,
175
171
// ensuring that nothing ever tries to actually access it.
176
172
let event_filter_mask =
177
173
profiler. as_ref ( ) . map_or ( EventFilter :: empty ( ) , |p| p. event_filter_mask ) ;
178
174
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 }
185
176
}
186
177
187
178
/// This shim makes sure that calls only get executed if the filter mask
@@ -214,7 +205,7 @@ impl SelfProfilerRef {
214
205
/// Start profiling a verbose generic activity. Profiling continues until the
215
206
/// VerboseTimingGuard returned from this call is dropped. In addition to recording
216
207
/// 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.
218
209
pub fn verbose_generic_activity < ' a > (
219
210
& ' a self ,
220
211
event_label : & ' static str ,
@@ -225,19 +216,16 @@ impl SelfProfilerRef {
225
216
VerboseTimingGuard :: start ( message, self . generic_activity ( event_label) )
226
217
}
227
218
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 > (
233
221
& ' a self ,
234
222
event_label : & ' static str ,
235
223
event_arg : A ,
236
224
) -> VerboseTimingGuard < ' a >
237
225
where
238
226
A : Borrow < str > + Into < String > ,
239
227
{
240
- let message = if self . print_extra_verbose_generic_activities {
228
+ let message = if self . print_verbose_generic_activities {
241
229
Some ( format ! ( "{}({})" , event_label, event_arg. borrow( ) ) )
242
230
} else {
243
231
None
@@ -745,27 +733,9 @@ impl Drop for VerboseTimingGuard<'_> {
745
733
if let Some ( ( start_time, start_rss, ref message) ) = self . start_and_message {
746
734
let end_rss = get_resident_set_size ( ) ;
747
735
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) ;
765
737
}
766
738
}
767
-
768
- false
769
739
}
770
740
771
741
pub fn print_time_passes_entry (
@@ -774,6 +744,26 @@ pub fn print_time_passes_entry(
774
744
start_rss : Option < usize > ,
775
745
end_rss : Option < usize > ,
776
746
) {
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
+
777
767
let rss_to_mb = |rss| ( rss as f64 / 1_000_000.0 ) . round ( ) as usize ;
778
768
let rss_change_to_mb = |rss| ( rss as f64 / 1_000_000.0 ) . round ( ) as i128 ;
779
769
0 commit comments