Commit 9b3adcfc authored by behdad's avatar behdad Committed by Commit Bot

Compositor_frame_reporter code cleanup

For each frame there is only one blink_breakdown and viz_breakdown, so
From all stage_data in the stage_history_ only one has viz_breakdown,
and only one has blink breakdown. This means that the breakdowns can be
part of the reporter instead of the stage_data.

Bug=none

Change-Id: I1448ecd539a7cb480fef5d0744efc76ff517b5dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1940386Reviewed-by: default avatarMohsen Izadi <mohsen@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Behdad Bakhshinategh <behdadb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720278}
parent eb99be25
...@@ -210,17 +210,17 @@ void CompositorFrameReporter::OnAbortBeginMainFrame() { ...@@ -210,17 +210,17 @@ void CompositorFrameReporter::OnAbortBeginMainFrame() {
void CompositorFrameReporter::SetBlinkBreakdown( void CompositorFrameReporter::SetBlinkBreakdown(
std::unique_ptr<BeginMainFrameMetrics> blink_breakdown) { std::unique_ptr<BeginMainFrameMetrics> blink_breakdown) {
DCHECK(blink_breakdown_.paint.is_zero());
if (blink_breakdown) if (blink_breakdown)
current_stage_.blink_breakdown = *blink_breakdown; blink_breakdown_ = *blink_breakdown;
else else
current_stage_.blink_breakdown = BeginMainFrameMetrics(); blink_breakdown_ = BeginMainFrameMetrics();
} }
void CompositorFrameReporter::SetVizBreakdown( void CompositorFrameReporter::SetVizBreakdown(
const viz::FrameTimingDetails& viz_breakdown) { const viz::FrameTimingDetails& viz_breakdown) {
DCHECK(current_stage_.viz_breakdown.received_compositor_frame_timestamp DCHECK(viz_breakdown_.received_compositor_frame_timestamp.is_null());
.is_null()); viz_breakdown_ = viz_breakdown;
current_stage_.viz_breakdown = viz_breakdown;
} }
void CompositorFrameReporter::TerminateReporter() { void CompositorFrameReporter::TerminateReporter() {
...@@ -277,31 +277,31 @@ void CompositorFrameReporter::ReportStageHistograms(bool missed_frame) const { ...@@ -277,31 +277,31 @@ void CompositorFrameReporter::ReportStageHistograms(bool missed_frame) const {
: CompositorFrameReporter::MissedFrameReportTypes::kNonMissedFrame; : CompositorFrameReporter::MissedFrameReportTypes::kNonMissedFrame;
for (const StageData& stage : stage_history_) { for (const StageData& stage : stage_history_) {
ReportStageHistogramWithBreakdown( ReportStageHistogramWithBreakdown(report_type, stage);
report_type, FrameSequenceTrackerType::kMaxType, stage);
for (const auto& frame_sequence_tracker_type : *active_trackers_) { for (const auto& frame_sequence_tracker_type : *active_trackers_) {
// Report stage breakdowns. // Report stage breakdowns.
ReportStageHistogramWithBreakdown(report_type, ReportStageHistogramWithBreakdown(report_type, stage,
frame_sequence_tracker_type, stage); frame_sequence_tracker_type);
} }
} }
} }
void CompositorFrameReporter::ReportStageHistogramWithBreakdown( void CompositorFrameReporter::ReportStageHistogramWithBreakdown(
CompositorFrameReporter::MissedFrameReportTypes report_type, CompositorFrameReporter::MissedFrameReportTypes report_type,
FrameSequenceTrackerType frame_sequence_tracker_type, const CompositorFrameReporter::StageData& stage,
const CompositorFrameReporter::StageData& stage) const { FrameSequenceTrackerType frame_sequence_tracker_type) const {
base::TimeDelta stage_delta = stage.end_time - stage.start_time; base::TimeDelta stage_delta = stage.end_time - stage.start_time;
ReportHistogram(report_type, frame_sequence_tracker_type, ReportHistogram(report_type, frame_sequence_tracker_type,
static_cast<int>(stage.stage_type), stage_delta); static_cast<int>(stage.stage_type), stage_delta);
switch (stage.stage_type) { switch (stage.stage_type) {
case StageType::kSendBeginMainFrameToCommit: { case StageType::kSendBeginMainFrameToCommit: {
ReportBlinkBreakdown(report_type, frame_sequence_tracker_type, stage); ReportBlinkBreakdowns(report_type, frame_sequence_tracker_type);
break; break;
} }
case StageType::kSubmitCompositorFrameToPresentationCompositorFrame: { case StageType::kSubmitCompositorFrameToPresentationCompositorFrame: {
ReportVizBreakdown(report_type, frame_sequence_tracker_type, stage); ReportVizBreakdowns(report_type, stage.start_time,
frame_sequence_tracker_type);
break; break;
} }
default: default:
...@@ -309,85 +309,61 @@ void CompositorFrameReporter::ReportStageHistogramWithBreakdown( ...@@ -309,85 +309,61 @@ void CompositorFrameReporter::ReportStageHistogramWithBreakdown(
} }
} }
void CompositorFrameReporter::ReportBlinkBreakdown( void CompositorFrameReporter::ReportBlinkBreakdowns(
CompositorFrameReporter::MissedFrameReportTypes report_type, CompositorFrameReporter::MissedFrameReportTypes report_type,
FrameSequenceTrackerType frame_sequence_tracker_type, FrameSequenceTrackerType frame_sequence_tracker_type) const {
const CompositorFrameReporter::StageData& stage) const { std::vector<std::pair<BlinkBreakdown, base::TimeDelta>> breakdowns = {
ReportHistogram(report_type, frame_sequence_tracker_type, {BlinkBreakdown::kHandleInputEvents,
kBlinkBreakdownInitialIndex + blink_breakdown_.handle_input_events},
static_cast<int>(BlinkBreakdown::kHandleInputEvents), {BlinkBreakdown::kAnimate, blink_breakdown_.animate},
stage.blink_breakdown.handle_input_events); {BlinkBreakdown::kStyleUpdate, blink_breakdown_.style_update},
ReportHistogram( {BlinkBreakdown::kLayoutUpdate, blink_breakdown_.layout_update},
report_type, frame_sequence_tracker_type, {BlinkBreakdown::kPrepaint, blink_breakdown_.prepaint},
kBlinkBreakdownInitialIndex + static_cast<int>(BlinkBreakdown::kAnimate), {BlinkBreakdown::kComposite, blink_breakdown_.composite},
stage.blink_breakdown.animate); {BlinkBreakdown::kPaint, blink_breakdown_.paint},
ReportHistogram(report_type, frame_sequence_tracker_type, {BlinkBreakdown::kScrollingCoordinator,
kBlinkBreakdownInitialIndex + blink_breakdown_.scrolling_coordinator},
static_cast<int>(BlinkBreakdown::kStyleUpdate), {BlinkBreakdown::kCompositeCommit, blink_breakdown_.composite_commit},
stage.blink_breakdown.style_update); {BlinkBreakdown::kUpdateLayers, blink_breakdown_.update_layers}};
ReportHistogram(report_type, frame_sequence_tracker_type,
kBlinkBreakdownInitialIndex + for (const auto& pair : breakdowns) {
static_cast<int>(BlinkBreakdown::kLayoutUpdate), ReportHistogram(report_type, frame_sequence_tracker_type,
stage.blink_breakdown.layout_update); kBlinkBreakdownInitialIndex + static_cast<int>(pair.first),
ReportHistogram( pair.second);
report_type, frame_sequence_tracker_type, }
kBlinkBreakdownInitialIndex + static_cast<int>(BlinkBreakdown::kPrepaint),
stage.blink_breakdown.prepaint);
ReportHistogram(report_type, frame_sequence_tracker_type,
kBlinkBreakdownInitialIndex +
static_cast<int>(BlinkBreakdown::kComposite),
stage.blink_breakdown.composite);
ReportHistogram(
report_type, frame_sequence_tracker_type,
kBlinkBreakdownInitialIndex + static_cast<int>(BlinkBreakdown::kPaint),
stage.blink_breakdown.paint);
ReportHistogram(report_type, frame_sequence_tracker_type,
kBlinkBreakdownInitialIndex +
static_cast<int>(BlinkBreakdown::kScrollingCoordinator),
stage.blink_breakdown.scrolling_coordinator);
ReportHistogram(report_type, frame_sequence_tracker_type,
kBlinkBreakdownInitialIndex +
static_cast<int>(BlinkBreakdown::kCompositeCommit),
stage.blink_breakdown.composite_commit);
ReportHistogram(report_type, frame_sequence_tracker_type,
kBlinkBreakdownInitialIndex +
static_cast<int>(BlinkBreakdown::kUpdateLayers),
stage.blink_breakdown.update_layers);
} }
void CompositorFrameReporter::ReportVizBreakdown( void CompositorFrameReporter::ReportVizBreakdowns(
CompositorFrameReporter::MissedFrameReportTypes report_type, CompositorFrameReporter::MissedFrameReportTypes report_type,
FrameSequenceTrackerType frame_sequence_tracker_type, base::TimeTicks start_time,
const CompositorFrameReporter::StageData& stage) const { FrameSequenceTrackerType frame_sequence_tracker_type) const {
// Check if viz_breakdown is set. // Check if viz_breakdown is set.
if (stage.viz_breakdown.received_compositor_frame_timestamp.is_null()) if (viz_breakdown_.received_compositor_frame_timestamp.is_null())
return; return;
base::TimeDelta submit_to_receive_compositor_frame_delta = base::TimeDelta submit_to_receive_compositor_frame_delta =
stage.viz_breakdown.received_compositor_frame_timestamp - viz_breakdown_.received_compositor_frame_timestamp - start_time;
stage.start_time;
ReportHistogram( ReportHistogram(
report_type, frame_sequence_tracker_type, report_type, frame_sequence_tracker_type,
kVizBreakdownInitialIndex + kVizBreakdownInitialIndex +
static_cast<int>(VizBreakdown::kSubmitToReceiveCompositorFrame), static_cast<int>(VizBreakdown::kSubmitToReceiveCompositorFrame),
submit_to_receive_compositor_frame_delta); submit_to_receive_compositor_frame_delta);
if (stage.viz_breakdown.draw_start_timestamp.is_null()) if (viz_breakdown_.draw_start_timestamp.is_null())
return; return;
base::TimeDelta received_compositor_frame_to_start_draw_delta = base::TimeDelta received_compositor_frame_to_start_draw_delta =
stage.viz_breakdown.draw_start_timestamp - viz_breakdown_.draw_start_timestamp -
stage.viz_breakdown.received_compositor_frame_timestamp; viz_breakdown_.received_compositor_frame_timestamp;
ReportHistogram( ReportHistogram(
report_type, frame_sequence_tracker_type, report_type, frame_sequence_tracker_type,
kVizBreakdownInitialIndex + kVizBreakdownInitialIndex +
static_cast<int>(VizBreakdown::kReceivedCompositorFrameToStartDraw), static_cast<int>(VizBreakdown::kReceivedCompositorFrameToStartDraw),
received_compositor_frame_to_start_draw_delta); received_compositor_frame_to_start_draw_delta);
if (stage.viz_breakdown.swap_timings.is_null()) if (viz_breakdown_.swap_timings.is_null())
return; return;
base::TimeDelta start_draw_to_swap_end_delta = base::TimeDelta start_draw_to_swap_end_delta =
stage.viz_breakdown.swap_timings.swap_end - viz_breakdown_.swap_timings.swap_end -
stage.viz_breakdown.draw_start_timestamp; viz_breakdown_.draw_start_timestamp;
ReportHistogram(report_type, frame_sequence_tracker_type, ReportHistogram(report_type, frame_sequence_tracker_type,
kVizBreakdownInitialIndex + kVizBreakdownInitialIndex +
...@@ -395,7 +371,8 @@ void CompositorFrameReporter::ReportVizBreakdown( ...@@ -395,7 +371,8 @@ void CompositorFrameReporter::ReportVizBreakdown(
start_draw_to_swap_end_delta); start_draw_to_swap_end_delta);
base::TimeDelta swap_end_to_presentation_compositor_frame_delta = base::TimeDelta swap_end_to_presentation_compositor_frame_delta =
stage.end_time - stage.viz_breakdown.swap_timings.swap_end; viz_breakdown_.presentation_feedback.timestamp -
viz_breakdown_.swap_timings.swap_end;
ReportHistogram( ReportHistogram(
report_type, frame_sequence_tracker_type, report_type, frame_sequence_tracker_type,
......
...@@ -136,13 +136,11 @@ class CC_EXPORT CompositorFrameReporter { ...@@ -136,13 +136,11 @@ class CC_EXPORT CompositorFrameReporter {
return impl_frame_finish_time_; return impl_frame_finish_time_;
} }
protected: private:
struct StageData { struct StageData {
StageType stage_type; StageType stage_type;
base::TimeTicks start_time; base::TimeTicks start_time;
base::TimeTicks end_time; base::TimeTicks end_time;
BeginMainFrameMetrics blink_breakdown;
viz::FrameTimingDetails viz_breakdown;
StageData(); StageData();
StageData(StageType stage_type, StageData(StageType stage_type,
base::TimeTicks start_time, base::TimeTicks start_time,
...@@ -151,35 +149,35 @@ class CC_EXPORT CompositorFrameReporter { ...@@ -151,35 +149,35 @@ class CC_EXPORT CompositorFrameReporter {
~StageData(); ~StageData();
}; };
void TerminateReporter();
void EndCurrentStage(base::TimeTicks end_time);
void ReportStageHistograms(bool missed_frame) const;
void ReportStageHistogramWithBreakdown(
MissedFrameReportTypes report_type,
const StageData& stage,
FrameSequenceTrackerType frame_sequence_tracker_type =
FrameSequenceTrackerType::kMaxType) const;
void ReportBlinkBreakdowns(
MissedFrameReportTypes report_type,
FrameSequenceTrackerType frame_sequence_tracker_type) const;
void ReportVizBreakdowns(
MissedFrameReportTypes report_type,
const base::TimeTicks start_time,
FrameSequenceTrackerType frame_sequence_tracker_type) const;
void ReportHistogram(MissedFrameReportTypes report_type,
FrameSequenceTrackerType intraction_type,
const int stage_type_index,
base::TimeDelta time_delta) const;
StageData current_stage_; StageData current_stage_;
BeginMainFrameMetrics blink_breakdown_;
viz::FrameTimingDetails viz_breakdown_;
// Stage data is recorded here. On destruction these stages will be reported // Stage data is recorded here. On destruction these stages will be reported
// to UMA if the termination status is |kPresentedFrame|. Reported data will // to UMA if the termination status is |kPresentedFrame|. Reported data will
// 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_;
private:
void TerminateReporter();
void EndCurrentStage(base::TimeTicks end_time);
void ReportStageHistograms(bool missed_frame) const;
void ReportStageHistogramWithBreakdown(
CompositorFrameReporter::MissedFrameReportTypes report_type,
FrameSequenceTrackerType frame_sequence_tracker_type,
const CompositorFrameReporter::StageData& stage) const;
void ReportBlinkBreakdown(
CompositorFrameReporter::MissedFrameReportTypes report_type,
FrameSequenceTrackerType frame_sequence_tracker_type,
const CompositorFrameReporter::StageData& stage) const;
void ReportVizBreakdown(
CompositorFrameReporter::MissedFrameReportTypes report_type,
FrameSequenceTrackerType frame_sequence_tracker_type,
const CompositorFrameReporter::StageData& stage) const;
void ReportHistogram(
CompositorFrameReporter::MissedFrameReportTypes report_type,
FrameSequenceTrackerType intraction_type,
const int stage_type_index,
base::TimeDelta time_delta) const;
// Returns true if the stage duration is greater than |kAbnormalityPercentile| // Returns true if the stage duration is greater than |kAbnormalityPercentile|
// of its RollingTimeDeltaHistory. // of its RollingTimeDeltaHistory.
base::TimeDelta GetStateNormalUpperLimit(const StageData& stage) const; base::TimeDelta GetStateNormalUpperLimit(const StageData& stage) const;
......
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