diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-10-06 15:39:27 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-10-06 15:50:10 +1100 |
| commit | 4e8faff3a15968970a6810e0af0eafea14f9f7f1 (patch) | |
| tree | 4a3d9bbfb5f8761f6fbaeabb1dd7cb72cb2075a1 /compiler/rustc_data_structures/src/profiling.rs | |
| parent | 9110d925d0b3e4842376e830f4404a28e1aa2658 (diff) | |
| download | rust-4e8faff3a15968970a6810e0af0eafea14f9f7f1.tar.gz rust-4e8faff3a15968970a6810e0af0eafea14f9f7f1.zip | |
Be consistent about deciding whether to print pass data.
`print_time_passes_entry` unconditionally prints data about a pass. The most commonly used call site, in `VerboseTimingGuard::drop`, guards it with a `should_print_passes` test. But there are a couple of other call sites that don't do that test. This commit moves the `should_print_passes` test within `print_time_passes_entry` so that all passes are treated equally.
Diffstat (limited to 'compiler/rustc_data_structures/src/profiling.rs')
| -rw-r--r-- | compiler/rustc_data_structures/src/profiling.rs | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs index 0980d36c36e..ba1960805d8 100644 --- a/compiler/rustc_data_structures/src/profiling.rs +++ b/compiler/rustc_data_structures/src/profiling.rs @@ -733,27 +733,9 @@ impl Drop for VerboseTimingGuard<'_> { if let Some((start_time, start_rss, ref message)) = self.start_and_message { let end_rss = get_resident_set_size(); let dur = start_time.elapsed(); - - if should_print_passes(dur, start_rss, end_rss) { - print_time_passes_entry(&message, dur, start_rss, end_rss); - } - } - } -} - -fn should_print_passes(dur: Duration, start_rss: Option<usize>, end_rss: Option<usize>) -> bool { - if dur.as_millis() > 5 { - return true; - } - - if let (Some(start_rss), Some(end_rss)) = (start_rss, end_rss) { - let change_rss = end_rss.abs_diff(start_rss); - if change_rss > 0 { - return true; + print_time_passes_entry(&message, dur, start_rss, end_rss); } } - - false } pub fn print_time_passes_entry( @@ -762,6 +744,26 @@ pub fn print_time_passes_entry( start_rss: Option<usize>, end_rss: Option<usize>, ) { + // Print the pass if its duration is greater than 5 ms, or it changed the + // measured RSS. + let is_notable = || { + if dur.as_millis() > 5 { + return true; + } + + if let (Some(start_rss), Some(end_rss)) = (start_rss, end_rss) { + let change_rss = end_rss.abs_diff(start_rss); + if change_rss > 0 { + return true; + } + } + + false + }; + if !is_notable() { + return; + } + let rss_to_mb = |rss| (rss as f64 / 1_000_000.0).round() as usize; let rss_change_to_mb = |rss| (rss as f64 / 1_000_000.0).round() as i128; |
