Commit 0d94bf4c authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

[thorughput] Extend fps meter to show throughput

This CL extends fps meter to show the throughput. More specifically,
we show the unified throughput of the main && compositor thread for
the Universal tracker. At this moment, the number will be updated every
5 seconds as long as there is a new throughput reported during the
5-second period.

The result looks like:
https://drive.google.com/file/d/1LUxfbK8IINxLFoPi1FoxI_IvnimrXhoR/view?usp=sharing

Bug: 1064290
Change-Id: I257333c0b580eddc570eeb971d913b93256db008
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135537
Commit-Queue: Xida Chen <xidachen@chromium.org>
Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756879}
parent 52d97b7e
......@@ -553,6 +553,15 @@ void HeadsUpDisplayLayerImpl::UpdateHudContents() {
FrameRateCounter* fps_counter = layer_tree_impl()->frame_rate_counter();
fps_graph_.value = fps_counter->GetAverageFPS();
fps_counter->GetMinAndMaxFPS(&fps_graph_.min, &fps_graph_.max);
current_throughput = layer_tree_impl()->current_universal_throughput();
if (current_throughput.has_value()) {
if (!max_throughput.has_value() ||
current_throughput.value() > max_throughput.value())
max_throughput = current_throughput;
if (!min_throughput.has_value() ||
current_throughput.value() < min_throughput.value())
min_throughput = current_throughput;
}
}
if (debug_state.ShowMemoryStats()) {
......@@ -682,7 +691,8 @@ SkRect HeadsUpDisplayLayerImpl::DrawFPSDisplay(
const int kHistogramWidth = 37;
int width = kGraphWidth + kHistogramWidth + 4 * kPadding;
int height = kTitleFontHeight + kFontHeight + kGraphHeight + 6 * kPadding + 2;
int height =
2 * kTitleFontHeight + 2 * kFontHeight + kGraphHeight + 10 * kPadding + 2;
int left = 0;
SkRect area = SkRect::MakeXYWH(left, top, width, height);
......@@ -702,6 +712,7 @@ SkRect HeadsUpDisplayLayerImpl::DrawFPSDisplay(
SkRect::MakeXYWH(graph_bounds.right() + kGap, graph_bounds.top(),
kHistogramWidth, kGraphHeight);
// Draw the fps meter.
const std::string title("Frame Rate");
const std::string value_text =
base::StringPrintf("%5.1f fps", fps_graph_.value);
......@@ -722,7 +733,32 @@ SkRect HeadsUpDisplayLayerImpl::DrawFPSDisplay(
DrawGraphLines(canvas, &flags, graph_bounds, fps_graph_);
// Collect graph and histogram data.
// Draw the throughput meter.
int current_top = histogram_bounds.bottom() + kPadding;
const std::string throughput_title("Throughput");
const std::string throughput_value_text =
current_throughput.has_value()
? base::StringPrintf("%d %%", current_throughput.value())
: base::StringPrintf("n/a");
VLOG(1) << throughput_value_text;
flags.setColor(DebugColors::HUDTitleColor());
DrawText(canvas, flags, throughput_title, TextAlign::kLeft, kTitleFontHeight,
title_bounds.left(), title_bounds.bottom() + current_top);
flags.setColor(DebugColors::FPSDisplayTextAndGraphColor());
DrawText(canvas, flags, throughput_value_text, TextAlign::kLeft, kFontHeight,
text_bounds.left(), text_bounds.bottom() + current_top);
if (min_throughput.has_value()) {
const std::string throughput_min_max_text = base::StringPrintf(
"%d-%d", min_throughput.value(), max_throughput.value());
DrawText(canvas, flags, throughput_min_max_text, TextAlign::kRight,
kFontHeight, text_bounds.right(),
text_bounds.bottom() + current_top);
}
// Collect fps graph and histogram data.
SkPath path;
const int kHistogramSize = 20;
......
......@@ -164,6 +164,11 @@ class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl {
int layout_shift_rects_fade_step_ = 0;
std::vector<DebugRect> paint_rects_;
std::vector<DebugRect> layout_shift_debug_rects_;
base::Optional<int> current_throughput;
// The worst and best throughput we have seen so far, they either both have no
// value, or both have value.
base::Optional<int> min_throughput;
base::Optional<int> max_throughput;
base::TimeTicks time_of_last_graph_update_;
};
......
......@@ -533,8 +533,16 @@ void FrameSequenceTrackerCollection::NotifyFramePresented(
accumulated_metrics_.erase(key);
}
if (metrics->HasEnoughDataForReporting())
if (metrics->HasEnoughDataForReporting()) {
if (tracker->type() == FrameSequenceTrackerType::kUniversal) {
uint32_t frames_expected = metrics->impl_throughput().frames_expected;
uint32_t frames_produced =
metrics->aggregated_throughput().frames_produced;
current_universal_throughput_ = std::floor(
100 * frames_produced / static_cast<float>(frames_expected));
}
metrics->ReportMetrics();
}
if (metrics->HasDataLeftForReporting())
accumulated_metrics_[key] = std::move(metrics);
}
......
......@@ -232,6 +232,10 @@ class CC_EXPORT FrameSequenceTrackerCollection {
void SetUkmManager(UkmManager* manager);
base::Optional<int> current_universal_throughput() {
return current_universal_throughput_;
}
private:
friend class FrameSequenceTrackerTest;
......@@ -261,6 +265,7 @@ class CC_EXPORT FrameSequenceTrackerCollection {
std::pair<FrameSequenceTrackerType, FrameSequenceMetrics::ThreadType>,
std::unique_ptr<FrameSequenceMetrics>>
accumulated_metrics_;
base::Optional<int> current_universal_throughput_;
};
// Tracks a sequence of frames to determine the throughput. It tracks this by
......
......@@ -18,6 +18,7 @@
#include "base/containers/flat_set.h"
#include "base/memory/memory_pressure_listener.h"
#include "base/memory/shared_memory_mapping.h"
#include "base/optional.h"
#include "base/sequenced_task_runner.h"
#include "base/time/time.h"
#include "cc/base/synced_property.h"
......@@ -637,6 +638,9 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandler,
std::unique_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
FrameRateCounter* fps_counter() { return fps_counter_.get(); }
base::Optional<int> current_universal_throughput() {
return frame_trackers_.current_universal_throughput();
}
MemoryHistory* memory_history() { return memory_history_.get(); }
DebugRectHistory* debug_rect_history() { return debug_rect_history_.get(); }
viz::ClientResourceProvider* resource_provider() {
......
......@@ -1585,6 +1585,10 @@ FrameRateCounter* LayerTreeImpl::frame_rate_counter() const {
return host_impl_->fps_counter();
}
base::Optional<int> LayerTreeImpl::current_universal_throughput() {
return host_impl_->current_universal_throughput();
}
MemoryHistory* LayerTreeImpl::memory_history() const {
return host_impl_->memory_history();
}
......
......@@ -128,6 +128,7 @@ class CC_EXPORT LayerTreeImpl {
ImageDecodeCache* image_decode_cache() const;
ImageAnimationController* image_animation_controller() const;
FrameRateCounter* frame_rate_counter() const;
base::Optional<int> current_universal_throughput();
MemoryHistory* memory_history() const;
DebugRectHistory* debug_rect_history() const;
bool IsActiveTree() 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