Bug 1530978 - Show profiler stats averaged over half a second instead of 600 frames. r=gw
authorNicolas Silva <nsilva@mozilla.com>
Wed, 27 Feb 2019 20:00:56 +0000
changeset 461937 ec7068a12a7b90ad6ceb368a4ee6097986b21559
parent 461936 de9645abe21adfafb8ab0df41d4325f6a33f8dc4
child 461938 6a9be28daf6e47f812310a8b4f78153f8cf5b6a8
push id35634
push userrmaries@mozilla.com
push dateSat, 02 Mar 2019 09:26:10 +0000
treeherdermozilla-central@4166cae81546 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw
bugs1530978
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530978 - Show profiler stats averaged over half a second instead of 600 frames. r=gw Differential Revision: https://phabricator.services.mozilla.com/D21392
gfx/wr/webrender/src/profiler.rs
--- a/gfx/wr/webrender/src/profiler.rs
+++ b/gfx/wr/webrender/src/profiler.rs
@@ -557,17 +557,17 @@ pub struct RendererProfileCounters {
     pub vao_count_and_size: ResourceProfileCounter,
     pub color_targets: IntProfileCounter,
     pub alpha_targets: IntProfileCounter,
     pub texture_data_uploaded: IntProfileCounter,
 }
 
 pub struct RendererProfileTimers {
     pub cpu_time: TimeProfileCounter,
-    pub gpu_time: TimeProfileCounter,
+    pub gpu_graph: TimeProfileCounter,
     pub gpu_samples: Vec<GpuTimer<GpuProfileTag>>,
 }
 
 impl RendererProfileCounters {
     pub fn new() -> Self {
         RendererProfileCounters {
             frame_counter: IntProfileCounter::new("Frame"),
             frame_time: AverageTimeProfileCounter::new("FPS", true, ONE_SECOND_NS / 2),
@@ -587,19 +587,19 @@ impl RendererProfileCounters {
         self.alpha_targets.reset();
         self.texture_data_uploaded.reset();
     }
 }
 
 impl RendererProfileTimers {
     pub fn new() -> Self {
         RendererProfileTimers {
-            cpu_time: TimeProfileCounter::new("Compositor CPU Time", false),
+            cpu_time: TimeProfileCounter::new("Renderer CPU Time", false),
             gpu_samples: Vec::new(),
-            gpu_time: TimeProfileCounter::new("GPU Time", false),
+            gpu_graph: TimeProfileCounter::new("GPU Time", false),
         }
     }
 }
 
 struct GraphStats {
     min_value: f32,
     mean_value: f32,
     max_value: f32,
@@ -876,37 +876,45 @@ struct DrawState {
     x_left: f32,
     y_left: f32,
     x_right: f32,
     y_right: f32,
 }
 
 pub struct Profiler {
     draw_state: DrawState,
-    backend_time: ProfileGraph,
-    compositor_time: ProfileGraph,
-    gpu_time: ProfileGraph,
+    backend_graph: ProfileGraph,
+    renderer_graph: ProfileGraph,
+    gpu_graph: ProfileGraph,
+    ipc_graph: ProfileGraph,
+    backend_time: AverageTimeProfileCounter,
+    renderer_time: AverageTimeProfileCounter,
+    gpu_time: AverageTimeProfileCounter,
+    ipc_time: AverageTimeProfileCounter,
     gpu_frames: GpuFrameCollection,
-    ipc_time: ProfileGraph,
 }
 
 impl Profiler {
     pub fn new() -> Self {
         Profiler {
             draw_state: DrawState {
                 x_left: 0.0,
                 y_left: 0.0,
                 x_right: 0.0,
                 y_right: 0.0,
             },
-            backend_time: ProfileGraph::new(600, "Backend:"),
-            compositor_time: ProfileGraph::new(600, "Compositor:"),
-            gpu_time: ProfileGraph::new(600, "GPU:"),
+            backend_graph: ProfileGraph::new(600, "Backend:"),
+            renderer_graph: ProfileGraph::new(600, "Renderer:"),
+            gpu_graph: ProfileGraph::new(600, "GPU:"),
+            ipc_graph: ProfileGraph::new(600, "IPC:"),
             gpu_frames: GpuFrameCollection::new(),
-            ipc_time: ProfileGraph::new(600, "IPC:"),
+            backend_time: AverageTimeProfileCounter::new("Backend:", false, ONE_SECOND_NS / 2),
+            renderer_time: AverageTimeProfileCounter::new("Renderer:", false, ONE_SECOND_NS / 2),
+            ipc_time: AverageTimeProfileCounter::new("IPC:", false, ONE_SECOND_NS / 2),
+            gpu_time: AverageTimeProfileCounter::new("GPU:", false, ONE_SECOND_NS / 2),
         }
     }
 
     fn draw_counters<T: ProfileCounter + ?Sized>(
         counters: &[&T],
         debug_renderer: &mut DebugRenderer,
         left: bool,
         draw_state: &mut DrawState,
@@ -1116,18 +1124,19 @@ impl Profiler {
         Profiler::draw_counters(
             &[
                 &renderer_profile.frame_time as &ProfileCounter,
                 &renderer_profile.color_targets,
                 &renderer_profile.alpha_targets,
                 &renderer_profile.draw_calls,
                 &renderer_profile.vertices,
                 &renderer_profile.texture_data_uploaded,
+                &self.ipc_time,
                 &self.backend_time,
-                &self.compositor_time,
+                &self.renderer_time,
                 &self.gpu_time,
             ],
             debug_renderer,
             true,
             &mut self.draw_state,
         );
     }
 
@@ -1205,17 +1214,17 @@ impl Profiler {
             true,
             &mut self.draw_state
         );
 
         Profiler::draw_counters(
             &[
                 &backend_profile.total_time,
                 &renderer_timers.cpu_time,
-                &renderer_timers.gpu_time,
+                &renderer_timers.gpu_graph,
             ],
             debug_renderer,
             false,
             &mut self.draw_state
         );
 
         if !gpu_samplers.is_empty() {
             let mut samplers = Vec::<PercentageProfileCounter>::new();
@@ -1246,31 +1255,31 @@ impl Profiler {
                 &samplers,
                 debug_renderer,
                 false,
                 &mut self.draw_state,
             );
         }
 
         let rect =
-            self.backend_time
+            self.backend_graph
                 .draw_graph(self.draw_state.x_right, self.draw_state.y_right, "CPU (backend)", debug_renderer);
         self.draw_state.y_right += rect.size.height + PROFILE_PADDING;
-        let rect = self.compositor_time.draw_graph(
+        let rect = self.renderer_graph.draw_graph(
             self.draw_state.x_right,
             self.draw_state.y_right,
-            "CPU (compositor)",
+            "CPU (renderer)",
             debug_renderer,
         );
         self.draw_state.y_right += rect.size.height + PROFILE_PADDING;
         let rect =
-            self.ipc_time
+            self.ipc_graph
                 .draw_graph(self.draw_state.x_right, self.draw_state.y_right, "DisplayList IPC", debug_renderer);
         self.draw_state.y_right += rect.size.height + PROFILE_PADDING;
-        let rect = self.gpu_time
+        let rect = self.gpu_graph
             .draw_graph(self.draw_state.x_right, self.draw_state.y_right, "GPU", debug_renderer);
         self.draw_state.y_right += rect.size.height + PROFILE_PADDING;
         let rect = self.gpu_frames
             .draw(self.draw_state.x_left, f32::max(self.draw_state.y_left, self.draw_state.y_right), debug_renderer);
         self.draw_state.y_right += rect.size.height + PROFILE_PADDING;
     }
 
     pub fn draw_profile(
@@ -1284,31 +1293,35 @@ impl Profiler {
         debug_renderer: &mut DebugRenderer,
         compact: bool,
     ) {
         self.draw_state.x_left = 20.0;
         self.draw_state.y_left = 40.0;
         self.draw_state.x_right = 450.0;
         self.draw_state.y_right = 40.0;
 
-        let mut gpu_time = 0;
-        let gpu_timers = mem::replace(&mut renderer_timers.gpu_samples, Vec::new());
-        for sample in &gpu_timers {
-            gpu_time += sample.time_ns;
+        let mut gpu_graph = 0;
+        let gpu_graphrs = mem::replace(&mut renderer_timers.gpu_samples, Vec::new());
+        for sample in &gpu_graphrs {
+            gpu_graph += sample.time_ns;
         }
-        renderer_timers.gpu_time.set(gpu_time);
+        renderer_timers.gpu_graph.set(gpu_graph);
 
-        self.backend_time
+        self.backend_graph
             .push(backend_profile.total_time.nanoseconds);
-        self.compositor_time
+        self.backend_time.set(backend_profile.total_time.nanoseconds);
+        self.renderer_graph
             .push(renderer_timers.cpu_time.nanoseconds);
-        self.ipc_time
+        self.renderer_time.set(renderer_timers.cpu_time.nanoseconds);
+        self.ipc_graph
             .push(backend_profile.ipc.total_time.nanoseconds);
-        self.gpu_time.push(gpu_time);
-        self.gpu_frames.push(gpu_time, gpu_timers);
+        self.ipc_time.set(backend_profile.ipc.total_time.nanoseconds);
+        self.gpu_graph.push(gpu_graph);
+        self.gpu_time.set(gpu_graph);
+        self.gpu_frames.push(gpu_graph, gpu_graphrs);
 
         if compact {
             self.draw_compact_profile(
                 renderer_profile,
                 debug_renderer,
             );
         } else {
             self.draw_full_profile(