Commit 66ff272d authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

[cc/metrics] Show stats from effective-thread in trace.

In the FrameSequenceTracker trace events, include stats only from the
'effective thread' (i.e. the thread driving the effect), instead of
including both main and compositor-threads.

BUG=1095186

Change-Id: I60666ce16a288a9d4a7fcd9cc27418fd4807b6b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261398
Auto-Submit: Sadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Reviewed-by: default avatarXida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781949}
parent 199cc2b8
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
#include "cc/metrics/frame_sequence_metrics.h" #include "cc/metrics/frame_sequence_metrics.h"
#include <memory>
#include <string>
#include <utility>
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/strcat.h" #include "base/strings/strcat.h"
...@@ -398,6 +402,22 @@ base::Optional<int> FrameSequenceMetrics::ThroughputData::ReportHistogram( ...@@ -398,6 +402,22 @@ base::Optional<int> FrameSequenceMetrics::ThroughputData::ReportHistogram(
return percent; return percent;
} }
std::unique_ptr<base::trace_event::TracedValue>
FrameSequenceMetrics::ThroughputData::ToTracedValue(
const ThroughputData& impl,
const ThroughputData& main,
ThreadType effective_thread) {
auto dict = std::make_unique<base::trace_event::TracedValue>();
if (effective_thread == ThreadType::kMain) {
dict->SetInteger("main-frames-produced", main.frames_produced);
dict->SetInteger("main-frames-expected", main.frames_expected);
} else {
dict->SetInteger("impl-frames-produced", impl.frames_produced);
dict->SetInteger("impl-frames-expected", impl.frames_expected);
}
return dict;
}
FrameSequenceMetrics::TraceData::TraceData(FrameSequenceMetrics* m) FrameSequenceMetrics::TraceData::TraceData(FrameSequenceMetrics* m)
: metrics(m) { : metrics(m) {
TRACE_EVENT_CATEGORY_GROUP_ENABLED("cc,benchmark", &enabled); TRACE_EVENT_CATEGORY_GROUP_ENABLED("cc,benchmark", &enabled);
...@@ -411,7 +431,8 @@ void FrameSequenceMetrics::TraceData::Terminate() { ...@@ -411,7 +431,8 @@ void FrameSequenceMetrics::TraceData::Terminate() {
TRACE_EVENT_NESTABLE_ASYNC_END2( TRACE_EVENT_NESTABLE_ASYNC_END2(
"cc,benchmark", "FrameSequenceTracker", TRACE_ID_LOCAL(trace_id), "args", "cc,benchmark", "FrameSequenceTracker", TRACE_ID_LOCAL(trace_id), "args",
ThroughputData::ToTracedValue(metrics->impl_throughput(), ThroughputData::ToTracedValue(metrics->impl_throughput(),
metrics->main_throughput()), metrics->main_throughput(),
metrics->GetEffectiveThread()),
"checkerboard", metrics->frames_checkerboarded()); "checkerboard", metrics->frames_checkerboarded());
trace_id = nullptr; trace_id = nullptr;
} }
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef CC_METRICS_FRAME_SEQUENCE_METRICS_H_ #ifndef CC_METRICS_FRAME_SEQUENCE_METRICS_H_
#define CC_METRICS_FRAME_SEQUENCE_METRICS_H_ #define CC_METRICS_FRAME_SEQUENCE_METRICS_H_
#include <memory>
#include "base/callback.h" #include "base/callback.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/trace_event/traced_value.h" #include "base/trace_event/traced_value.h"
...@@ -44,7 +46,8 @@ class CC_EXPORT FrameSequenceMetrics { ...@@ -44,7 +46,8 @@ class CC_EXPORT FrameSequenceMetrics {
struct ThroughputData { struct ThroughputData {
static std::unique_ptr<base::trace_event::TracedValue> ToTracedValue( static std::unique_ptr<base::trace_event::TracedValue> ToTracedValue(
const ThroughputData& impl, const ThroughputData& impl,
const ThroughputData& main); const ThroughputData& main,
ThreadType effective_thred);
// 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.
......
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
#include "cc/metrics/frame_sequence_tracker.h" #include "cc/metrics/frame_sequence_tracker.h"
#include <algorithm>
#include <memory>
#include <string>
#include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
...@@ -665,18 +670,6 @@ bool FrameSequenceTracker::IsExpectingMainFrame() const { ...@@ -665,18 +670,6 @@ bool FrameSequenceTracker::IsExpectingMainFrame() const {
return !main_frames_.empty() || last_main_not_processed; return !main_frames_.empty() || last_main_not_processed;
} }
std::unique_ptr<base::trace_event::TracedValue>
FrameSequenceMetrics::ThroughputData::ToTracedValue(
const ThroughputData& impl,
const ThroughputData& main) {
auto dict = std::make_unique<base::trace_event::TracedValue>();
dict->SetInteger("impl-frames-produced", impl.frames_produced);
dict->SetInteger("impl-frames-expected", impl.frames_expected);
dict->SetInteger("main-frames-produced", main.frames_produced);
dict->SetInteger("main-frames-expected", main.frames_expected);
return dict;
}
bool FrameSequenceTracker::ShouldReportMetricsNow( bool FrameSequenceTracker::ShouldReportMetricsNow(
const viz::BeginFrameArgs& args) const { const viz::BeginFrameArgs& args) const {
return metrics_->HasEnoughDataForReporting() && return metrics_->HasEnoughDataForReporting() &&
......
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