Commit 62dc7540 authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

[throughput] Report scrolling-thread metric in AllInteractions.

We currently report the 'slower thread' metric in the aggregated
top-level metrics (AllInteractions and AllSequences). But now that
we have a 'scrolling thread' metric, report that instead.

BUG=1035460

Change-Id: Ide012ecf9c92aeeaba86fcdfeb812958e85a0656
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2128370Reviewed-by: default avatarXida Chen <xidachen@chromium.org>
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754658}
parent 09a69329
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/histogram_tester.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace cc { namespace cc {
...@@ -167,4 +168,43 @@ TEST(FrameSequenceMetricsTest, IrrelevantMetricsNotReported) { ...@@ -167,4 +168,43 @@ TEST(FrameSequenceMetricsTest, IrrelevantMetricsNotReported) {
"Graphics.Smoothness.PercentDroppedFrames.SlowerThread.RAF", 0u); "Graphics.Smoothness.PercentDroppedFrames.SlowerThread.RAF", 0u);
} }
TEST(FrameSequenceMetricsTest, ScrollingThreadMetricsReportedForInteractions) {
auto setup = []() {
auto metrics = std::make_unique<FrameSequenceMetrics>(
FrameSequenceTrackerType::kTouchScroll, nullptr);
metrics->impl_throughput().frames_expected = 100;
metrics->impl_throughput().frames_produced = 80;
metrics->main_throughput().frames_expected = 100;
metrics->main_throughput().frames_produced = 60;
return metrics;
};
const char metric[] =
"Graphics.Smoothness.PercentDroppedFrames.AllInteractions";
{
// The main-thread metric should be reported in AllInteractions when
// main-thread is the scrolling-thread.
base::HistogramTester histograms;
auto metrics = setup();
EXPECT_TRUE(metrics->HasEnoughDataForReporting());
metrics->SetScrollingThread(FrameSequenceMetrics::ThreadType::kMain);
metrics->ReportMetrics();
histograms.ExpectTotalCount(metric, 1u);
EXPECT_THAT(histograms.GetAllSamples(metric),
testing::ElementsAre(base::Bucket(40, 1)));
}
{
// The compositor-thread metric should be reported in AllInteractions when
// compositor-thread is the scrolling-thread.
base::HistogramTester histograms;
auto metrics = setup();
EXPECT_TRUE(metrics->HasEnoughDataForReporting());
metrics->SetScrollingThread(FrameSequenceMetrics::ThreadType::kCompositor);
metrics->ReportMetrics();
histograms.ExpectTotalCount(metric, 1u);
EXPECT_THAT(histograms.GetAllSamples(metric),
testing::ElementsAre(base::Bucket(20, 1)));
}
}
} // namespace cc } // namespace cc
...@@ -108,13 +108,15 @@ bool ShouldReportForAnimation(FrameSequenceTrackerType sequence_type, ...@@ -108,13 +108,15 @@ bool ShouldReportForAnimation(FrameSequenceTrackerType sequence_type,
return false; return false;
} }
bool ShouldReportForInteraction(FrameSequenceTrackerType sequence_type, bool ShouldReportForInteraction(FrameSequenceMetrics* metrics,
FrameSequenceMetrics::ThreadType thread_type) { FrameSequenceMetrics::ThreadType thread_type) {
const auto sequence_type = metrics->type();
// For touch/wheel scroll, the slower thread is the one we want to report. For // For touch/wheel scroll, the slower thread is the one we want to report. For
// pinch-zoom, it's the compositor-thread. // pinch-zoom, it's the compositor-thread.
if (sequence_type == FrameSequenceTrackerType::kTouchScroll || if (sequence_type == FrameSequenceTrackerType::kTouchScroll ||
sequence_type == FrameSequenceTrackerType::kWheelScroll) sequence_type == FrameSequenceTrackerType::kWheelScroll)
return thread_type == FrameSequenceMetrics::ThreadType::kSlower; return thread_type == metrics->GetEffectiveThread();
if (sequence_type == FrameSequenceTrackerType::kPinchZoom) if (sequence_type == FrameSequenceTrackerType::kPinchZoom)
return thread_type == FrameSequenceMetrics::ThreadType::kCompositor; return thread_type == FrameSequenceMetrics::ThreadType::kCompositor;
...@@ -232,11 +234,11 @@ void FrameSequenceMetrics::ReportMetrics() { ...@@ -232,11 +234,11 @@ void FrameSequenceMetrics::ReportMetrics() {
// Report the throughput metrics. // Report the throughput metrics.
base::Optional<int> impl_throughput_percent = ThroughputData::ReportHistogram( base::Optional<int> impl_throughput_percent = ThroughputData::ReportHistogram(
throughput_ukm_reporter_, type_, ThreadType::kCompositor, this, ThreadType::kCompositor,
GetIndexForMetric(FrameSequenceMetrics::ThreadType::kCompositor, type_), GetIndexForMetric(FrameSequenceMetrics::ThreadType::kCompositor, type_),
impl_throughput_); impl_throughput_);
base::Optional<int> main_throughput_percent = ThroughputData::ReportHistogram( base::Optional<int> main_throughput_percent = ThroughputData::ReportHistogram(
throughput_ukm_reporter_, type_, ThreadType::kMain, this, ThreadType::kMain,
GetIndexForMetric(FrameSequenceMetrics::ThreadType::kMain, type_), GetIndexForMetric(FrameSequenceMetrics::ThreadType::kMain, type_),
main_throughput_); main_throughput_);
...@@ -246,7 +248,7 @@ void FrameSequenceMetrics::ReportMetrics() { ...@@ -246,7 +248,7 @@ void FrameSequenceMetrics::ReportMetrics() {
base::Optional<int> aggregated_throughput_percent; base::Optional<int> aggregated_throughput_percent;
if (should_report_slower_thread) { if (should_report_slower_thread) {
aggregated_throughput_percent = ThroughputData::ReportHistogram( aggregated_throughput_percent = ThroughputData::ReportHistogram(
throughput_ukm_reporter_, type_, ThreadType::kSlower, this, ThreadType::kSlower,
GetIndexForMetric(FrameSequenceMetrics::ThreadType::kSlower, type_), GetIndexForMetric(FrameSequenceMetrics::ThreadType::kSlower, type_),
aggregated_throughput_); aggregated_throughput_);
if (aggregated_throughput_percent.has_value() && throughput_ukm_reporter_) { if (aggregated_throughput_percent.has_value() && throughput_ukm_reporter_) {
...@@ -1092,11 +1094,11 @@ std::unique_ptr<FrameSequenceMetrics> FrameSequenceTracker::TakeMetrics() { ...@@ -1092,11 +1094,11 @@ std::unique_ptr<FrameSequenceMetrics> FrameSequenceTracker::TakeMetrics() {
} }
base::Optional<int> FrameSequenceMetrics::ThroughputData::ReportHistogram( base::Optional<int> FrameSequenceMetrics::ThroughputData::ReportHistogram(
ThroughputUkmReporter* ukm_reporter, FrameSequenceMetrics* metrics,
FrameSequenceTrackerType sequence_type,
ThreadType thread_type, ThreadType thread_type,
int metric_index, int metric_index,
const ThroughputData& data) { const ThroughputData& data) {
const auto sequence_type = metrics->type();
DCHECK_LT(sequence_type, FrameSequenceTrackerType::kMaxType); DCHECK_LT(sequence_type, FrameSequenceTrackerType::kMaxType);
STATIC_HISTOGRAM_POINTER_GROUP( STATIC_HISTOGRAM_POINTER_GROUP(
...@@ -1120,8 +1122,9 @@ base::Optional<int> FrameSequenceMetrics::ThroughputData::ReportHistogram( ...@@ -1120,8 +1122,9 @@ base::Optional<int> FrameSequenceMetrics::ThroughputData::ReportHistogram(
const bool is_animation = const bool is_animation =
ShouldReportForAnimation(sequence_type, thread_type); ShouldReportForAnimation(sequence_type, thread_type);
const bool is_interaction = const bool is_interaction = ShouldReportForInteraction(metrics, thread_type);
ShouldReportForInteraction(sequence_type, thread_type);
ThroughputUkmReporter* const ukm_reporter = metrics->ukm_reporter();
if (is_animation) { if (is_animation) {
UMA_HISTOGRAM_PERCENTAGE( UMA_HISTOGRAM_PERCENTAGE(
......
...@@ -71,12 +71,10 @@ class CC_EXPORT FrameSequenceMetrics { ...@@ -71,12 +71,10 @@ class CC_EXPORT FrameSequenceMetrics {
// Returns the throughput in percent, a return value of base::nullopt // Returns the throughput in percent, a return value of base::nullopt
// indicates that no throughput metric is reported. // indicates that no throughput metric is reported.
static base::Optional<int> ReportHistogram( static base::Optional<int> ReportHistogram(FrameSequenceMetrics* metrics,
ThroughputUkmReporter* ukm_reporter, ThreadType thread_type,
FrameSequenceTrackerType sequence_type, int metric_index,
ThreadType thread_type, const ThroughputData& data);
int metric_index,
const ThroughputData& data);
void Merge(const ThroughputData& data) { void Merge(const ThroughputData& data) {
frames_expected += data.frames_expected; frames_expected += data.frames_expected;
...@@ -128,6 +126,11 @@ class CC_EXPORT FrameSequenceMetrics { ...@@ -128,6 +126,11 @@ class CC_EXPORT FrameSequenceMetrics {
} }
uint32_t frames_checkerboarded() const { return frames_checkerboarded_; } uint32_t frames_checkerboarded() const { return frames_checkerboarded_; }
FrameSequenceTrackerType type() const { return type_; }
ThroughputUkmReporter* ukm_reporter() const {
return throughput_ukm_reporter_;
}
private: private:
void ComputeAggregatedThroughput(); void ComputeAggregatedThroughput();
const FrameSequenceTrackerType type_; const FrameSequenceTrackerType type_;
......
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