Commit 0dd0f0b4 authored by oysteine's avatar oysteine Committed by Commit bot

Revert of Revert of Report viewport memory and timing correctly for Slimming...

Revert of Revert of Report viewport memory and timing correctly for Slimming Paint. (patchset #1 id:1 of https://codereview.chromium.org/885753004/)

Reason for revert:
This CL wasn't the culprit after all, it seems.

Original issue's description:
> Revert of Report viewport memory and timing correctly for Slimming Paint. (patchset #3 id:60001 of https://codereview.chromium.org/867803003/)
>
> Reason for revert:
> Reverting due to https://crbug.com/453131
>
> Original issue's description:
> > Report viewport memory and timing correctly for Slimming Paint.
> >
> > The rasterize_and_record benchmark was not using data from the
> > DisplayItemList. Now it does.
> >
> > R=ajuma@chromium.org,vmpstr@chromium.org
> > BUG=451448
> >
> > Committed: https://crrev.com/c76f528131949d7fe60b7facf1e7b40362aacfd5
> > Cr-Commit-Position: refs/heads/master@{#313420}
>
> TBR=ajuma@chromium.org,vmpstr@chromium.org,schenney@chromium.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=451448
>
> Committed: https://crrev.com/fae3da55913e8e163faabf787b26791a96938ab7
> Cr-Commit-Position: refs/heads/master@{#314226}

TBR=ajuma@chromium.org,vmpstr@chromium.org,schenney@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=451448

Review URL: https://codereview.chromium.org/886673003

Cr-Commit-Position: refs/heads/master@{#314260}
parent c69d6c6e
...@@ -13,8 +13,10 @@ ...@@ -13,8 +13,10 @@
#include "base/values.h" #include "base/values.h"
#include "cc/debug/lap_timer.h" #include "cc/debug/lap_timer.h"
#include "cc/debug/rasterize_and_record_benchmark_impl.h" #include "cc/debug/rasterize_and_record_benchmark_impl.h"
#include "cc/layers/content_layer_client.h"
#include "cc/layers/layer.h" #include "cc/layers/layer.h"
#include "cc/layers/picture_layer.h" #include "cc/layers/picture_layer.h"
#include "cc/resources/display_item_list.h"
#include "cc/resources/picture_pile.h" #include "cc/resources/picture_pile.h"
#include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_host_common.h" #include "cc/trees/layer_tree_host_common.h"
...@@ -27,6 +29,11 @@ namespace { ...@@ -27,6 +29,11 @@ namespace {
const int kDefaultRecordRepeatCount = 100; const int kDefaultRecordRepeatCount = 100;
// Parameters for LapTimer.
const int kTimeLimitMillis = 1;
const int kWarmupRuns = 0;
const int kTimeCheckInterval = 1;
const char* kModeSuffixes[Picture::RECORDING_MODE_COUNT] = { const char* kModeSuffixes[Picture::RECORDING_MODE_COUNT] = {
"", "",
"_sk_null_canvas", "_sk_null_canvas",
...@@ -102,17 +109,29 @@ void RasterizeAndRecordBenchmark::Run(Layer* layer) { ...@@ -102,17 +109,29 @@ void RasterizeAndRecordBenchmark::Run(Layer* layer) {
} }
void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) {
ContentLayerClient* painter = layer->client();
gfx::Size content_bounds = layer->content_bounds();
DCHECK(host_); DCHECK(host_);
gfx::Size tile_grid_size = host_->settings().default_tile_size;
gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect( gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect(
layer->visible_content_rect(), 1.f / layer->contents_scale_x()); layer->visible_content_rect(), 1.f / layer->contents_scale_x());
if (visible_content_rect.IsEmpty()) if (visible_content_rect.IsEmpty())
return; return;
if (host_->settings().use_display_lists) {
RunOnDisplayListLayer(layer, visible_content_rect);
} else {
RunOnPictureLayer(layer, visible_content_rect);
}
}
void RasterizeAndRecordBenchmark::RunOnPictureLayer(
PictureLayer* layer,
const gfx::Rect& visible_content_rect) {
ContentLayerClient* painter = layer->client();
DCHECK(host_ && !host_->settings().use_display_lists);
gfx::Size tile_grid_size = host_->settings().default_tile_size;
for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT; for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT;
mode_index++) { mode_index++) {
Picture::RecordingMode mode = Picture::RecordingMode mode =
...@@ -120,11 +139,6 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { ...@@ -120,11 +139,6 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) {
base::TimeDelta min_time = base::TimeDelta::Max(); base::TimeDelta min_time = base::TimeDelta::Max();
size_t memory_used = 0; size_t memory_used = 0;
// Parameters for LapTimer.
const int kTimeLimitMillis = 1;
const int kWarmupRuns = 0;
const int kTimeCheckInterval = 1;
for (int i = 0; i < record_repeat_count_; ++i) { for (int i = 0; i < record_repeat_count_; ++i) {
// Run for a minimum amount of time to avoid problems with timer // Run for a minimum amount of time to avoid problems with timer
// quantization when the layer is very small. // quantization when the layer is very small.
...@@ -135,13 +149,19 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { ...@@ -135,13 +149,19 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) {
do { do {
picture = Picture::Create(visible_content_rect, painter, tile_grid_size, picture = Picture::Create(visible_content_rect, painter, tile_grid_size,
false, mode); false, mode);
if (memory_used) {
// Verify we are recording the same thing each time.
DCHECK(memory_used == picture->ApproximateMemoryUsage());
} else {
memory_used = picture->ApproximateMemoryUsage();
}
timer.NextLap(); timer.NextLap();
} while (!timer.HasTimeLimitExpired()); } while (!timer.HasTimeLimitExpired());
base::TimeDelta duration = base::TimeDelta duration =
base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); base::TimeDelta::FromMillisecondsD(timer.MsPerLap());
if (duration < min_time) if (duration < min_time)
min_time = duration; min_time = duration;
memory_used = picture->ApproximateMemoryUsage();
} }
if (mode == Picture::RECORD_NORMALLY) { if (mode == Picture::RECORD_NORMALLY) {
...@@ -153,6 +173,58 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { ...@@ -153,6 +173,58 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) {
} }
} }
void RasterizeAndRecordBenchmark::RunOnDisplayListLayer(
PictureLayer* layer,
const gfx::Rect& visible_content_rect) {
ContentLayerClient* painter = layer->client();
DCHECK(host_ && host_->settings().use_display_lists);
base::TimeDelta min_time = base::TimeDelta::Max();
size_t memory_used = 0;
// TODO(schenney): What are the corresponding Picture::RecordingMode modes
// for Slimming Paint. We could disable SkPicture creation in
// DrawingDisplayItems, or we could only generate the display list and not
// do any work on it in the compositor, or something else, or all of the
// above.
scoped_refptr<DisplayItemList> display_list;
for (int i = 0; i < record_repeat_count_; ++i) {
// Run for a minimum amount of time to avoid problems with timer
// quantization when the layer is very small.
LapTimer timer(kWarmupRuns,
base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
kTimeCheckInterval);
do {
// TODO(schenney): Cached content will not be regenerated, which skews
// the results significantly in favor of Slimming Paint (or should).
// Add a flag or API call to disable caching, and maybe run the test
// twice, without and with caching.
display_list = painter->PaintContentsToDisplayList(
visible_content_rect, ContentLayerClient::GRAPHICS_CONTEXT_ENABLED);
if (memory_used) {
// Verify we are recording the same thing each time.
DCHECK(memory_used == display_list->PictureMemoryUsage());
} else {
memory_used = display_list->PictureMemoryUsage();
}
timer.NextLap();
} while (!timer.HasTimeLimitExpired());
base::TimeDelta duration =
base::TimeDelta::FromMillisecondsD(timer.MsPerLap());
if (duration < min_time)
min_time = duration;
}
record_results_.bytes_used += memory_used;
record_results_.pixels_recorded +=
visible_content_rect.width() * visible_content_rect.height();
record_results_.total_best_time[Picture::RECORD_NORMALLY] += min_time;
}
RasterizeAndRecordBenchmark::RecordResults::RecordResults() RasterizeAndRecordBenchmark::RecordResults::RecordResults()
: pixels_recorded(0), bytes_used(0) { : pixels_recorded(0), bytes_used(0) {
} }
......
...@@ -38,6 +38,10 @@ class RasterizeAndRecordBenchmark : public MicroBenchmark { ...@@ -38,6 +38,10 @@ class RasterizeAndRecordBenchmark : public MicroBenchmark {
private: private:
void Run(Layer* layer); void Run(Layer* layer);
void RunOnDisplayListLayer(PictureLayer* layer,
const gfx::Rect& visible_content_rect);
void RunOnPictureLayer(PictureLayer* layer,
const gfx::Rect& visible_content_rect);
void RecordRasterResults(scoped_ptr<base::Value> results); void RecordRasterResults(scoped_ptr<base::Value> results);
......
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