Commit e649a2a7 authored by behdad's avatar behdad Committed by Commit Bot

Add DCheck for total latency being equal to sum of parts

The end_time of SendBeginMainToCommit would be set by the time that
OnFinishImplFrame is received, which might be before the MainFrameAbort.
This could result into TotalLatency being smaller than the sum of stages.

Bug: chromium:1048696
Change-Id: I551c495da084c1887410495caab28de91cfa63e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2062575Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Behdad Bakhshinategh <behdadb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747790}
parent 866524e0
...@@ -249,8 +249,13 @@ void CompositorFrameReporter::OnFinishImplFrame(base::TimeTicks timestamp) { ...@@ -249,8 +249,13 @@ void CompositorFrameReporter::OnFinishImplFrame(base::TimeTicks timestamp) {
impl_frame_finish_time_ = timestamp; impl_frame_finish_time_ = timestamp;
} }
void CompositorFrameReporter::OnAbortBeginMainFrame() { void CompositorFrameReporter::OnAbortBeginMainFrame(base::TimeTicks timestamp) {
DCHECK(!did_abort_main_frame_);
did_abort_main_frame_ = true; did_abort_main_frame_ = true;
impl_frame_finish_time_ = timestamp;
// impl_frame_finish_time_ can be used for the end of BeginMain to Commit
// stage
} }
void CompositorFrameReporter::SetBlinkBreakdown( void CompositorFrameReporter::SetBlinkBreakdown(
...@@ -329,6 +334,8 @@ void CompositorFrameReporter::TerminateReporter() { ...@@ -329,6 +334,8 @@ void CompositorFrameReporter::TerminateReporter() {
// Only report compositor latency histograms if the frame was produced. // Only report compositor latency histograms if the frame was produced.
if (report_compositor_latency) { if (report_compositor_latency) {
DCHECK(stage_history_.size()); DCHECK(stage_history_.size());
DCHECK_EQ(SumOfStageHistory(), stage_history_.back().end_time -
stage_history_.front().start_time);
stage_history_.emplace_back(StageType::kTotalLatency, stage_history_.emplace_back(StageType::kTotalLatency,
stage_history_.front().start_time, stage_history_.front().start_time,
stage_history_.back().end_time); stage_history_.back().end_time);
...@@ -514,4 +521,11 @@ void CompositorFrameReporter::ReportEventLatencyHistograms() const { ...@@ -514,4 +521,11 @@ void CompositorFrameReporter::ReportEventLatencyHistograms() const {
} }
} }
base::TimeDelta CompositorFrameReporter::SumOfStageHistory() const {
base::TimeDelta sum;
for (const StageData& stage : stage_history_)
sum += stage.end_time - stage.start_time;
return sum;
}
} // namespace cc } // namespace cc
...@@ -144,7 +144,7 @@ class CC_EXPORT CompositorFrameReporter { ...@@ -144,7 +144,7 @@ class CC_EXPORT CompositorFrameReporter {
int StageHistorySizeForTesting() { return stage_history_.size(); } int StageHistorySizeForTesting() { return stage_history_.size(); }
void OnFinishImplFrame(base::TimeTicks timestamp); void OnFinishImplFrame(base::TimeTicks timestamp);
void OnAbortBeginMainFrame(); void OnAbortBeginMainFrame(base::TimeTicks timestamp);
bool did_finish_impl_frame() const { return did_finish_impl_frame_; } bool did_finish_impl_frame() const { return did_finish_impl_frame_; }
bool did_abort_main_frame() const { return did_abort_main_frame_; } bool did_abort_main_frame() const { return did_abort_main_frame_; }
base::TimeTicks impl_frame_finish_time() const { base::TimeTicks impl_frame_finish_time() const {
...@@ -182,6 +182,9 @@ class CC_EXPORT CompositorFrameReporter { ...@@ -182,6 +182,9 @@ class CC_EXPORT CompositorFrameReporter {
// be divided based on the frame submission status. // be divided based on the frame submission status.
std::vector<StageData> stage_history_; std::vector<StageData> stage_history_;
// This method is only used for DCheck
base::TimeDelta SumOfStageHistory() const;
// List of metrics for events affecting this frame. // List of metrics for events affecting this frame.
std::vector<EventMetrics> events_metrics_; std::vector<EventMetrics> events_metrics_;
......
...@@ -102,7 +102,7 @@ void CompositorFrameReportingController::BeginMainFrameAborted( ...@@ -102,7 +102,7 @@ void CompositorFrameReportingController::BeginMainFrameAborted(
DCHECK(reporters_[PipelineStage::kBeginMainFrame]); DCHECK(reporters_[PipelineStage::kBeginMainFrame]);
DCHECK_EQ(reporters_[PipelineStage::kBeginMainFrame]->frame_id_, id); DCHECK_EQ(reporters_[PipelineStage::kBeginMainFrame]->frame_id_, id);
auto& begin_main_reporter = reporters_[PipelineStage::kBeginMainFrame]; auto& begin_main_reporter = reporters_[PipelineStage::kBeginMainFrame];
begin_main_reporter->OnAbortBeginMainFrame(); begin_main_reporter->OnAbortBeginMainFrame(Now());
} }
void CompositorFrameReportingController::WillCommit() { void CompositorFrameReportingController::WillCommit() {
......
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