Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(735)

Unified Diff: content/browser/renderer_host/render_widget_host_latency_tracker.cc

Issue 833283003: Reland "Add new latency_info for tracking browser composite time." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename component Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_latency_tracker.cc
diff --git a/content/browser/renderer_host/render_widget_host_latency_tracker.cc b/content/browser/renderer_host/render_widget_host_latency_tracker.cc
index 2280e34a321d859e1218dd6e91fc3f0da8c6985e..d47562b2c3ec210e8b1400561ca779873ac975f1 100644
--- a/content/browser/renderer_host/render_widget_host_latency_tracker.cc
+++ b/content/browser/renderer_host/render_widget_host_latency_tracker.cc
@@ -19,6 +19,9 @@ namespace content {
namespace {
const uint32 kMaxInputCoordinates = LatencyInfo::kMaxInputCoordinates;
+const size_t kBrowserCompositeLatencyHistorySize = 60;
+const double kBrowserCompositeLatencyEstimationPercentile = 90.0;
+const double kBrowserCompositeLatencyEstimationSlack = 1.1;
void UpdateLatencyCoordinatesImpl(const blink::WebTouchEvent& touch,
LatencyInfo* latency) {
@@ -163,7 +166,10 @@ void AddLatencyInfoComponentIds(LatencyInfo* latency,
} // namespace
RenderWidgetHostLatencyTracker::RenderWidgetHostLatencyTracker()
- : last_event_id_(0), latency_component_id_(0), device_scale_factor_(1) {
+ : last_event_id_(0),
+ latency_component_id_(0),
+ device_scale_factor_(1),
+ browser_composite_latency_history_(kBrowserCompositeLatencyHistorySize) {
}
RenderWidgetHostLatencyTracker::~RenderWidgetHostLatencyTracker() {
@@ -257,8 +263,11 @@ void RenderWidgetHostLatencyTracker::OnInputEventAck(
void RenderWidgetHostLatencyTracker::OnSwapCompositorFrame(
std::vector<LatencyInfo>* latencies) {
DCHECK(latencies);
- for (LatencyInfo& latency : *latencies)
+ for (LatencyInfo& latency : *latencies) {
AddLatencyInfoComponentIds(&latency, latency_component_id_);
+ latency.AddLatencyNumber(
+ ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0);
+ }
}
void RenderWidgetHostLatencyTracker::OnFrameSwapped(
@@ -303,6 +312,33 @@ void RenderWidgetHostLatencyTracker::OnFrameSwapped(
100);
}
}
+
+ ui::LatencyInfo::LatencyComponent gpu_swap_component;
+ if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0,
+ &gpu_swap_component)) {
+ return;
+ }
+
+ ui::LatencyInfo::LatencyComponent browser_swap_component;
+ if (latency.FindLatency(
+ ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0,
+ &browser_swap_component)) {
+ base::TimeDelta delta =
+ gpu_swap_component.event_time - browser_swap_component.event_time;
+ browser_composite_latency_history_.InsertSample(delta);
+ }
+}
+
+base::TimeDelta
+RenderWidgetHostLatencyTracker::GetEstimatedBrowserCompositeTime() const {
+ // TODO(brianderson): Remove lower bound on estimate once we're sure it won't
+ // cause regressions.
+ return std::max(
+ browser_composite_latency_history_.Percentile(
+ kBrowserCompositeLatencyEstimationPercentile) *
+ kBrowserCompositeLatencyEstimationSlack,
+ base::TimeDelta::FromMicroseconds(
+ (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60)));
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698