Commit e5267e9d authored by enne@chromium.org's avatar enne@chromium.org

cc: Abstract out proxy timing history

Pulling this out into a separate class lets it be reused by SingleThreadProxy.

BUG=329552

Review URL: https://codereview.chromium.org/154163005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251471 0039d316-1c4b-4281-b951-d872f2087c98
parent 166a7284
...@@ -439,6 +439,8 @@ ...@@ -439,6 +439,8 @@
'trees/occlusion_tracker.h', 'trees/occlusion_tracker.h',
'trees/proxy.cc', 'trees/proxy.cc',
'trees/proxy.h', 'trees/proxy.h',
'trees/proxy_timing_history.cc',
'trees/proxy_timing_history.h',
'trees/quad_culler.cc', 'trees/quad_culler.cc',
'trees/quad_culler.h', 'trees/quad_culler.h',
'trees/single_thread_proxy.cc', 'trees/single_thread_proxy.cc',
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/trees/proxy_timing_history.h"
const size_t kDurationHistorySize = 60;
const double kCommitAndActivationDurationEstimationPercentile = 50.0;
const double kDrawDurationEstimationPercentile = 100.0;
const int kDrawDurationEstimatePaddingInMicroseconds = 0;
namespace cc {
ProxyTimingHistory::ProxyTimingHistory()
: draw_duration_history_(kDurationHistorySize),
begin_main_frame_to_commit_duration_history_(kDurationHistorySize),
commit_to_activate_duration_history_(kDurationHistorySize) {}
ProxyTimingHistory::~ProxyTimingHistory() {}
base::TimeDelta ProxyTimingHistory::DrawDurationEstimate() const {
base::TimeDelta historical_estimate =
draw_duration_history_.Percentile(kDrawDurationEstimationPercentile);
base::TimeDelta padding = base::TimeDelta::FromMicroseconds(
kDrawDurationEstimatePaddingInMicroseconds);
return historical_estimate + padding;
}
base::TimeDelta ProxyTimingHistory::BeginMainFrameToCommitDurationEstimate()
const {
return begin_main_frame_to_commit_duration_history_.Percentile(
kCommitAndActivationDurationEstimationPercentile);
}
base::TimeDelta ProxyTimingHistory::CommitToActivateDurationEstimate() const {
return commit_to_activate_duration_history_.Percentile(
kCommitAndActivationDurationEstimationPercentile);
}
void ProxyTimingHistory::DidBeginMainFrame() {
begin_main_frame_sent_time_ = base::TimeTicks::HighResNow();
}
void ProxyTimingHistory::DidCommit() {
commit_complete_time_ = base::TimeTicks::HighResNow();
begin_main_frame_to_commit_duration_history_.InsertSample(
commit_complete_time_ - begin_main_frame_sent_time_);
}
void ProxyTimingHistory::DidActivatePendingTree() {
commit_to_activate_duration_history_.InsertSample(
base::TimeTicks::HighResNow() - commit_complete_time_);
}
void ProxyTimingHistory::DidStartDrawing() {
start_draw_time_ = base::TimeTicks::HighResNow();
}
base::TimeDelta ProxyTimingHistory::DidFinishDrawing() {
base::TimeDelta draw_duration =
base::TimeTicks::HighResNow() - start_draw_time_;
draw_duration_history_.InsertSample(draw_duration);
return draw_duration;
}
} // namespace cc
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_TREES_PROXY_TIMING_HISTORY_H_
#define CC_TREES_PROXY_TIMING_HISTORY_H_
#include "cc/base/rolling_time_delta_history.h"
namespace cc {
class ProxyTimingHistory {
public:
ProxyTimingHistory();
~ProxyTimingHistory();
base::TimeDelta DrawDurationEstimate() const;
base::TimeDelta BeginMainFrameToCommitDurationEstimate() const;
base::TimeDelta CommitToActivateDurationEstimate() const;
void DidBeginMainFrame();
void DidCommit();
void DidActivatePendingTree();
void DidStartDrawing();
// Returns draw duration.
base::TimeDelta DidFinishDrawing();
protected:
RollingTimeDeltaHistory draw_duration_history_;
RollingTimeDeltaHistory begin_main_frame_to_commit_duration_history_;
RollingTimeDeltaHistory commit_to_activate_duration_history_;
base::TimeTicks begin_main_frame_sent_time_;
base::TimeTicks commit_complete_time_;
base::TimeTicks start_draw_time_;
};
} // namespace cc
#endif // CC_TREES_PROXY_TIMING_HISTORY_H_
...@@ -33,11 +33,6 @@ namespace { ...@@ -33,11 +33,6 @@ namespace {
// Measured in seconds. // Measured in seconds.
const double kSmoothnessTakesPriorityExpirationDelay = 0.25; const double kSmoothnessTakesPriorityExpirationDelay = 0.25;
const size_t kDurationHistorySize = 60;
const double kCommitAndActivationDurationEstimationPercentile = 50.0;
const double kDrawDurationEstimationPercentile = 100.0;
const int kDrawDurationEstimatePaddingInMicroseconds = 0;
class SwapPromiseChecker { class SwapPromiseChecker {
public: public:
explicit SwapPromiseChecker(cc::LayerTreeHost* layer_tree_host) explicit SwapPromiseChecker(cc::LayerTreeHost* layer_tree_host)
...@@ -135,9 +130,6 @@ ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(ThreadProxy* proxy, ...@@ -135,9 +130,6 @@ ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(ThreadProxy* proxy,
input_throttled_until_commit(false), input_throttled_until_commit(false),
animations_frozen_until_next_draw(false), animations_frozen_until_next_draw(false),
renew_tree_priority_pending(false), renew_tree_priority_pending(false),
draw_duration_history(kDurationHistorySize),
begin_main_frame_to_commit_duration_history(kDurationHistorySize),
commit_to_activate_duration_history(kDurationHistorySize),
weak_factory(proxy) {} weak_factory(proxy) {}
ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {}
...@@ -790,7 +782,7 @@ void ThreadProxy::ScheduledActionSendBeginMainFrame() { ...@@ -790,7 +782,7 @@ void ThreadProxy::ScheduledActionSendBeginMainFrame() {
impl().begin_main_frame_sent_completion_event->Signal(); impl().begin_main_frame_sent_completion_event->Signal();
impl().begin_main_frame_sent_completion_event = NULL; impl().begin_main_frame_sent_completion_event = NULL;
} }
impl().begin_main_frame_sent_time = base::TimeTicks::HighResNow(); impl().timing_history.DidBeginMainFrame();
} }
void ThreadProxy::BeginMainFrame( void ThreadProxy::BeginMainFrame(
...@@ -1096,9 +1088,7 @@ void ThreadProxy::ScheduledActionCommit() { ...@@ -1096,9 +1088,7 @@ void ThreadProxy::ScheduledActionCommit() {
impl().next_frame_is_newly_committed_frame = true; impl().next_frame_is_newly_committed_frame = true;
impl().commit_complete_time = base::TimeTicks::HighResNow(); impl().timing_history.DidCommit();
impl().begin_main_frame_to_commit_duration_history.InsertSample(
impl().commit_complete_time - impl().begin_main_frame_sent_time);
// SetVisible kicks off the next scheduler action, so this must be last. // SetVisible kicks off the next scheduler action, so this must be last.
impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible());
...@@ -1135,7 +1125,7 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal( ...@@ -1135,7 +1125,7 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal(
DCHECK(IsImplThread()); DCHECK(IsImplThread());
DCHECK(impl().layer_tree_host_impl.get()); DCHECK(impl().layer_tree_host_impl.get());
base::TimeTicks start_time = base::TimeTicks::HighResNow(); impl().timing_history.DidStartDrawing();
base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); base::TimeDelta draw_duration_estimate = DrawDurationEstimate();
base::AutoReset<bool> mark_inside(&impl().inside_draw, true); base::AutoReset<bool> mark_inside(&impl().inside_draw, true);
...@@ -1245,8 +1235,8 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal( ...@@ -1245,8 +1235,8 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal(
if (draw_frame) { if (draw_frame) {
CheckOutputSurfaceStatusOnImplThread(); CheckOutputSurfaceStatusOnImplThread();
base::TimeDelta draw_duration = base::TimeTicks::HighResNow() - start_time; base::TimeDelta draw_duration = impl().timing_history.DidFinishDrawing();
impl().draw_duration_history.InsertSample(draw_duration);
base::TimeDelta draw_duration_overestimate; base::TimeDelta draw_duration_overestimate;
base::TimeDelta draw_duration_underestimate; base::TimeDelta draw_duration_underestimate;
if (draw_duration > draw_duration_estimate) if (draw_duration > draw_duration_estimate)
...@@ -1353,21 +1343,15 @@ void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { ...@@ -1353,21 +1343,15 @@ void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) {
} }
base::TimeDelta ThreadProxy::DrawDurationEstimate() { base::TimeDelta ThreadProxy::DrawDurationEstimate() {
base::TimeDelta historical_estimate = impl().draw_duration_history.Percentile( return impl().timing_history.DrawDurationEstimate();
kDrawDurationEstimationPercentile);
base::TimeDelta padding = base::TimeDelta::FromMicroseconds(
kDrawDurationEstimatePaddingInMicroseconds);
return historical_estimate + padding;
} }
base::TimeDelta ThreadProxy::BeginMainFrameToCommitDurationEstimate() { base::TimeDelta ThreadProxy::BeginMainFrameToCommitDurationEstimate() {
return impl().begin_main_frame_to_commit_duration_history.Percentile( return impl().timing_history.BeginMainFrameToCommitDurationEstimate();
kCommitAndActivationDurationEstimationPercentile);
} }
base::TimeDelta ThreadProxy::CommitToActivateDurationEstimate() { base::TimeDelta ThreadProxy::CommitToActivateDurationEstimate() {
return impl().commit_to_activate_duration_history.Percentile( return impl().timing_history.CommitToActivateDurationEstimate();
kCommitAndActivationDurationEstimationPercentile);
} }
void ThreadProxy::PostBeginImplFrameDeadline(const base::Closure& closure, void ThreadProxy::PostBeginImplFrameDeadline(const base::Closure& closure,
...@@ -1711,8 +1695,7 @@ void ThreadProxy::DidActivatePendingTree() { ...@@ -1711,8 +1695,7 @@ void ThreadProxy::DidActivatePendingTree() {
UpdateBackgroundAnimateTicking(); UpdateBackgroundAnimateTicking();
impl().commit_to_activate_duration_history.InsertSample( impl().timing_history.DidActivatePendingTree();
base::TimeTicks::HighResNow() - impl().commit_complete_time);
} }
void ThreadProxy::DidManageTiles() { void ThreadProxy::DidManageTiles() {
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "cc/animation/animation_events.h" #include "cc/animation/animation_events.h"
#include "cc/base/completion_event.h" #include "cc/base/completion_event.h"
#include "cc/base/rolling_time_delta_history.h"
#include "cc/resources/resource_update_controller.h" #include "cc/resources/resource_update_controller.h"
#include "cc/scheduler/scheduler.h" #include "cc/scheduler/scheduler.h"
#include "cc/trees/layer_tree_host_impl.h" #include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/proxy.h" #include "cc/trees/proxy.h"
#include "cc/trees/proxy_timing_history.h"
namespace base { namespace base {
class SingleThreadTaskRunner; class SingleThreadTaskRunner;
...@@ -298,15 +298,7 @@ class ThreadProxy : public Proxy, ...@@ -298,15 +298,7 @@ class ThreadProxy : public Proxy,
base::TimeTicks smoothness_takes_priority_expiration_time; base::TimeTicks smoothness_takes_priority_expiration_time;
bool renew_tree_priority_pending; bool renew_tree_priority_pending;
RollingTimeDeltaHistory draw_duration_history; ProxyTimingHistory timing_history;
RollingTimeDeltaHistory begin_main_frame_to_commit_duration_history;
RollingTimeDeltaHistory commit_to_activate_duration_history;
// Used for computing samples added to
// begin_main_frame_to_commit_duration_history_ and
// activation_duration_history_.
base::TimeTicks begin_main_frame_sent_time;
base::TimeTicks commit_complete_time;
scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl; scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl;
base::WeakPtrFactory<ThreadProxy> weak_factory; base::WeakPtrFactory<ThreadProxy> weak_factory;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment