diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/cc.gyp | 2 | ||||
-rw-r--r-- | cc/debug/OWNERS | 3 | ||||
-rw-r--r-- | cc/debug/benchmark_instrumentation.cc | 30 | ||||
-rw-r--r-- | cc/debug/benchmark_instrumentation.h | 30 | ||||
-rw-r--r-- | cc/debug/rendering_stats.cc | 14 | ||||
-rw-r--r-- | cc/debug/rendering_stats.h | 2 | ||||
-rw-r--r-- | cc/debug/rendering_stats_instrumentation.h | 14 | ||||
-rw-r--r-- | cc/layers/picture_layer.cc | 6 | ||||
-rw-r--r-- | cc/resources/picture.cc | 29 | ||||
-rw-r--r-- | cc/resources/picture.h | 8 | ||||
-rw-r--r-- | cc/resources/picture_pile.cc | 3 | ||||
-rw-r--r-- | cc/resources/picture_pile_impl.cc | 9 | ||||
-rw-r--r-- | cc/resources/raster_worker_pool.cc | 25 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.cc | 7 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 4 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.cc | 4 | ||||
-rw-r--r-- | cc/trees/thread_proxy.cc | 4 |
17 files changed, 96 insertions, 98 deletions
@@ -69,6 +69,8 @@ 'base/tiling_data.cc', 'base/tiling_data.h', 'base/util.h', + 'debug/benchmark_instrumentation.cc', + 'debug/benchmark_instrumentation.h', 'debug/debug_colors.cc', 'debug/debug_colors.h', 'debug/debug_rect_history.cc', diff --git a/cc/debug/OWNERS b/cc/debug/OWNERS index a46edee..2de2d9b 100644 --- a/cc/debug/OWNERS +++ b/cc/debug/OWNERS @@ -2,3 +2,6 @@ per-file benchmark_instrumentation.h=set noparent per-file benchmark_instrumentation.h=ernstm@chromium.org per-file benchmark_instrumentation.h=nduca@chromium.org +per-file benchmark_instrumentation.cc=set noparent +per-file benchmark_instrumentation.cc=ernstm@chromium.org +per-file benchmark_instrumentation.cc=nduca@chromium.org diff --git a/cc/debug/benchmark_instrumentation.cc b/cc/debug/benchmark_instrumentation.cc new file mode 100644 index 0000000..bf2b022 --- /dev/null +++ b/cc/debug/benchmark_instrumentation.cc @@ -0,0 +1,30 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/debug/trace_event.h" +#include "cc/debug/benchmark_instrumentation.h" + +namespace cc { + +// Please do not change the trace events in this file without updating +// tools/perf/measurements/rendering_stats.py accordingly. +// The benchmarks search for events and their arguments by name. + +void BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent( + const MainThreadRenderingStats& stats) { + TRACE_EVENT_INSTANT1("benchmark", + "BenchmarkInstrumentation::MainThreadRenderingStats", + TRACE_EVENT_SCOPE_THREAD, + "data", stats.AsTraceableData()); +} + +void BenchmarkInstrumentation::IssueImplThreadRenderingStatsEvent( + const ImplThreadRenderingStats& stats) { + TRACE_EVENT_INSTANT1("benchmark", + "BenchmarkInstrumentation::ImplThreadRenderingStats", + TRACE_EVENT_SCOPE_THREAD, + "data", stats.AsTraceableData()); +} + +} // namespace cc diff --git a/cc/debug/benchmark_instrumentation.h b/cc/debug/benchmark_instrumentation.h index 615fbe9..2614814 100644 --- a/cc/debug/benchmark_instrumentation.h +++ b/cc/debug/benchmark_instrumentation.h @@ -5,28 +5,18 @@ #ifndef CC_DEBUG_BENCHMARK_INSTRUMENTATION_H_ #define CC_DEBUG_BENCHMARK_INSTRUMENTATION_H_ -#include "base/debug/trace_event.h" +#include "cc/debug/rendering_stats.h" namespace cc { -namespace benchmark_instrumentation { -// Please do not change the string constants in this file (or the TRACE_EVENT -// calls that use them) without updating -// tools/perf/measurements/rasterize_and_record_benchmark.py accordingly. -// The benchmark searches for events and their arguments by name. -const char kCategory[] = "cc,benchmark"; -const char kSourceFrameNumber[] = "source_frame_number"; -const char kData[] = "data"; -const char kWidth[] = "width"; -const char kHeight[] = "height"; -const char kNumPixelsRasterized[] = "num_pixels_rasterized"; -const char kLayerTreeHostUpdateLayers[] = "LayerTreeHost::UpdateLayers"; -const char kPictureLayerUpdate[] = "PictureLayer::Update"; -const char kRunRasterOnThread[] = "RasterWorkerPoolTaskImpl::RunRasterOnThread"; -const char kRecordLoop[] = "RecordLoop"; -const char kRasterLoop[] = "RasterLoop"; -const char kPictureRecord[] = "Picture::Record"; -const char kPictureRaster[] = "Picture::Raster"; -} // namespace benchmark_instrumentation + +class CC_EXPORT BenchmarkInstrumentation { + public: + static void IssueMainThreadRenderingStatsEvent( + const MainThreadRenderingStats& stats); + static void IssueImplThreadRenderingStatsEvent( + const ImplThreadRenderingStats& stats); +}; + } // namespace cc #endif // CC_DEBUG_BENCHMARK_INSTRUMENTATION_H_ diff --git a/cc/debug/rendering_stats.cc b/cc/debug/rendering_stats.cc index 6d9f615..16bf091 100644 --- a/cc/debug/rendering_stats.cc +++ b/cc/debug/rendering_stats.cc @@ -12,13 +12,6 @@ MainThreadRenderingStats::MainThreadRenderingStats() painted_pixel_count(0), recorded_pixel_count(0) {} -void MainThreadRenderingStats::IssueTraceEvent() const { - TRACE_EVENT_INSTANT1("benchmark", - "MainThreadRenderingStats::IssueTraceEvent", - TRACE_EVENT_SCOPE_THREAD, - "data", AsTraceableData()); -} - scoped_refptr<base::debug::ConvertableToTraceFormat> MainThreadRenderingStats::AsTraceableData() const { scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); @@ -42,13 +35,6 @@ ImplThreadRenderingStats::ImplThreadRenderingStats() : frame_count(0), rasterized_pixel_count(0) {} -void ImplThreadRenderingStats::IssueTraceEvent() const { - TRACE_EVENT_INSTANT1("benchmark", - "ImplThreadRenderingStats::IssueTraceEvent", - TRACE_EVENT_SCOPE_THREAD, - "data", AsTraceableData()); -} - scoped_refptr<base::debug::ConvertableToTraceFormat> ImplThreadRenderingStats::AsTraceableData() const { scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); diff --git a/cc/debug/rendering_stats.h b/cc/debug/rendering_stats.h index 1e2aaa3..ff1dbef 100644 --- a/cc/debug/rendering_stats.h +++ b/cc/debug/rendering_stats.h @@ -39,7 +39,6 @@ struct CC_EXPORT MainThreadRenderingStats { int64 recorded_pixel_count; MainThreadRenderingStats(); - void IssueTraceEvent() const; scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableData() const; void Add(const MainThreadRenderingStats& other); }; @@ -53,7 +52,6 @@ struct CC_EXPORT ImplThreadRenderingStats { int64 rasterized_pixel_count; ImplThreadRenderingStats(); - void IssueTraceEvent() const; scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableData() const; void Add(const ImplThreadRenderingStats& other); }; diff --git a/cc/debug/rendering_stats_instrumentation.h b/cc/debug/rendering_stats_instrumentation.h index fcecb37..4508600 100644 --- a/cc/debug/rendering_stats_instrumentation.h +++ b/cc/debug/rendering_stats_instrumentation.h @@ -19,11 +19,11 @@ class CC_EXPORT RenderingStatsInstrumentation { virtual ~RenderingStatsInstrumentation(); // Return current main thread rendering stats. - MainThreadRenderingStats GetMainThreadRenderingStats() { + const MainThreadRenderingStats& main_thread_rendering_stats() { return main_stats_; } // Return current impl thread rendering stats. - ImplThreadRenderingStats GetImplThreadRenderingStats() { + const ImplThreadRenderingStats& impl_thread_rendering_stats() { return impl_stats_; } // Return the accumulated, combined rendering stats. @@ -36,15 +36,6 @@ class CC_EXPORT RenderingStatsInstrumentation { // clear current stats. void AccumulateAndClearImplThreadStats(); - // Issue trace event for current main thread rendering stats. - void IssueTraceEventForMainThreadStats() { - main_stats_.IssueTraceEvent(); - } - // Issue trace event for current impl thread rendering stats. - void IssueTraceEventForImplThreadStats() { - impl_stats_.IssueTraceEvent(); - } - // Read and write access to the record_rendering_stats_ flag is not locked to // improve performance. The flag is commonly turned off and hardly changes // it's value during runtime. @@ -66,6 +57,7 @@ class CC_EXPORT RenderingStatsInstrumentation { RenderingStatsInstrumentation(); private: + // TODO(ernstm): rename to *_thread_rendering_stats_* MainThreadRenderingStats main_stats_; MainThreadRenderingStats main_stats_accu_; ImplThreadRenderingStats impl_stats_; diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index 1c12664..89157a3 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -4,7 +4,6 @@ #include "cc/layers/picture_layer.h" -#include "cc/debug/benchmark_instrumentation.h" #include "cc/debug/devtools_instrumentation.h" #include "cc/layers/content_layer_client.h" #include "cc/layers/picture_layer_impl.h" @@ -75,9 +74,8 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue, // Do not early-out of this function so that PicturePile::Update has a chance // to record pictures due to changing visibility of this layer. - TRACE_EVENT1(benchmark_instrumentation::kCategory, - benchmark_instrumentation::kPictureLayerUpdate, - benchmark_instrumentation::kSourceFrameNumber, + TRACE_EVENT1("cc", "PictureLayer::Update", + "source_frame_number", layer_tree_host()->source_frame_number()); bool updated = Layer::Update(queue, occlusion); diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc index 94ab870..8083050 100644 --- a/cc/resources/picture.cc +++ b/cc/resources/picture.cc @@ -13,7 +13,6 @@ #include "base/values.h" #include "cc/base/math_util.h" #include "cc/base/util.h" -#include "cc/debug/benchmark_instrumentation.h" #include "cc/debug/traced_picture.h" #include "cc/debug/traced_value.h" #include "cc/layers/content_layer_client.h" @@ -204,9 +203,8 @@ void Picture::CloneForDrawing(int num_threads) { void Picture::Record(ContentLayerClient* painter, const SkTileGridPicture::TileGridInfo& tile_grid_info) { - TRACE_EVENT1(benchmark_instrumentation::kCategory, - benchmark_instrumentation::kPictureRecord, - benchmark_instrumentation::kData, AsTraceableRecordData()); + TRACE_EVENT1("cc", "Picture::Record", + "data", AsTraceableRecordData()); DCHECK(!tile_grid_info.fTileInterval.isEmpty()); picture_ = skia::AdoptRef(new SkTileGridPicture( @@ -293,15 +291,14 @@ void Picture::GatherPixelRefs( max_pixel_cell_ = gfx::Point(max_x, max_y); } -void Picture::Raster( +int Picture::Raster( SkCanvas* canvas, SkDrawPictureCallback* callback, gfx::Rect content_rect, float contents_scale) { - TRACE_EVENT_BEGIN1(benchmark_instrumentation::kCategory, - benchmark_instrumentation::kPictureRaster, - "data", - AsTraceableRasterData(content_rect, contents_scale)); + TRACE_EVENT_BEGIN1( + "cc", "Picture::Raster", + "data", AsTraceableRasterData(content_rect, contents_scale)); DCHECK(picture_); @@ -313,10 +310,10 @@ void Picture::Raster( SkIRect bounds; canvas->getClipDeviceBounds(&bounds); canvas->restore(); - TRACE_EVENT_END1(benchmark_instrumentation::kCategory, - benchmark_instrumentation::kPictureRaster, - benchmark_instrumentation::kNumPixelsRasterized, - bounds.width() * bounds.height()); + TRACE_EVENT_END1( + "cc", "Picture::Raster", + "num_pixels_rasterized", bounds.width() * bounds.height()); + return bounds.width() * bounds.height(); } void Picture::Replay(SkCanvas* canvas) { @@ -478,10 +475,8 @@ scoped_refptr<base::debug::ConvertableToTraceFormat> Picture::AsTraceableRecordData() const { scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); - record_data->SetInteger(benchmark_instrumentation::kWidth, - layer_rect_.width()); - record_data->SetInteger(benchmark_instrumentation::kHeight, - layer_rect_.height()); + record_data->SetInteger("width", layer_rect_.width()); + record_data->SetInteger("height", layer_rect_.height()); return TracedValue::FromValue(record_data.release()); } diff --git a/cc/resources/picture.h b/cc/resources/picture.h index 6a7aca7..8210e86 100644 --- a/cc/resources/picture.h +++ b/cc/resources/picture.h @@ -68,10 +68,10 @@ class CC_EXPORT Picture bool HasRecording() const { return picture_.get() != NULL; } // Apply this contents scale and raster the content rect into the canvas. - void Raster(SkCanvas* canvas, - SkDrawPictureCallback* callback, - gfx::Rect content_rect, - float contents_scale); + int Raster(SkCanvas* canvas, + SkDrawPictureCallback* callback, + gfx::Rect content_rect, + float contents_scale); // Draw the picture directly into the given canvas, without applying any // clip/scale/layer transformations. diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc index d2d82f5..d1cb0e1 100644 --- a/cc/resources/picture_pile.cc +++ b/cc/resources/picture_pile.cc @@ -9,7 +9,6 @@ #include <vector> #include "cc/base/region.h" -#include "cc/debug/benchmark_instrumentation.h" #include "cc/debug/rendering_stats_instrumentation.h" #include "cc/resources/picture_pile_impl.h" @@ -114,8 +113,6 @@ bool PicturePile::Update( pic != pic_list.end(); ++pic) { if (!(*pic)->HasRecording()) { modified_pile = true; - TRACE_EVENT0(benchmark_instrumentation::kCategory, - benchmark_instrumentation::kRecordLoop); base::TimeDelta best_duration = base::TimeDelta::FromInternalValue( std::numeric_limits<int64>::max()); for (int i = 0; i < repeat_count; i++) { diff --git a/cc/resources/picture_pile_impl.cc b/cc/resources/picture_pile_impl.cc index 8f98350..95b333c 100644 --- a/cc/resources/picture_pile_impl.cc +++ b/cc/resources/picture_pile_impl.cc @@ -7,7 +7,6 @@ #include "base/debug/trace_event.h" #include "cc/base/region.h" -#include "cc/debug/benchmark_instrumentation.h" #include "cc/debug/debug_colors.h" #include "cc/resources/picture_pile_impl.h" #include "skia/ext/analysis_canvas.h" @@ -201,14 +200,14 @@ void PicturePileImpl::RasterCommon( base::TimeDelta best_duration = base::TimeDelta::FromInternalValue(std::numeric_limits<int64>::max()); int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); + int rasterized_pixel_count = 0; - TRACE_EVENT0(benchmark_instrumentation::kCategory, - benchmark_instrumentation::kRasterLoop); for (int j = 0; j < repeat_count; ++j) { base::TimeTicks start_time; if (rendering_stats_instrumentation) start_time = rendering_stats_instrumentation->StartRecording(); - (*i)->Raster(canvas, callback, content_clip, contents_scale); + rasterized_pixel_count = + (*i)->Raster(canvas, callback, content_clip, contents_scale); if (rendering_stats_instrumentation) { base::TimeDelta duration = rendering_stats_instrumentation->EndRecording(start_time); @@ -216,8 +215,6 @@ void PicturePileImpl::RasterCommon( } } if (rendering_stats_instrumentation) { - int64 rasterized_pixel_count = - repeat_count * content_clip.width() * content_clip.height(); rendering_stats_instrumentation->AddRaster(best_duration, rasterized_pixel_count); } diff --git a/cc/resources/raster_worker_pool.cc b/cc/resources/raster_worker_pool.cc index e7f1907..b7dd504 100644 --- a/cc/resources/raster_worker_pool.cc +++ b/cc/resources/raster_worker_pool.cc @@ -7,7 +7,6 @@ #include "base/json/json_writer.h" #include "base/metrics/histogram.h" #include "base/values.h" -#include "cc/debug/benchmark_instrumentation.h" #include "cc/debug/devtools_instrumentation.h" #include "cc/debug/traced_value.h" #include "cc/resources/picture_pile_impl.h" @@ -103,9 +102,8 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask { gfx::Size size, int stride) { TRACE_EVENT2( - benchmark_instrumentation::kCategory, - benchmark_instrumentation::kRunRasterOnThread, - benchmark_instrumentation::kData, + "cc", "RasterWorkerPoolTaskImpl::RunRasterOnThread", + "data", TracedValue::FromValue(DataAsValue().release()), "raster_mode", TracedValue::FromValue(RasterModeAsValue(raster_mode_).release())); @@ -166,14 +164,23 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask { canvas.setDrawFilter(draw_filter.get()); base::TimeDelta prev_rasterize_time = - rendering_stats_->GetImplThreadRenderingStats().rasterize_time; - - picture_clone->RasterToBitmap( - &canvas, content_rect_, contents_scale_, rendering_stats_); + rendering_stats_->impl_thread_rendering_stats().rasterize_time; + + // Only record rasterization time for highres tiles, because + // lowres tiles are not required for activation and therefore + // introduce noise in the measurement (sometimes they get rasterized + // before we draw and sometimes they aren't) + if (tile_resolution_ == HIGH_RESOLUTION) { + picture_clone->RasterToBitmap( + &canvas, content_rect_, contents_scale_, rendering_stats_); + } else { + picture_clone->RasterToBitmap( + &canvas, content_rect_, contents_scale_, NULL); + } if (rendering_stats_->record_rendering_stats()) { base::TimeDelta current_rasterize_time = - rendering_stats_->GetImplThreadRenderingStats().rasterize_time; + rendering_stats_->impl_thread_rendering_stats().rasterize_time; HISTOGRAM_CUSTOM_COUNTS( "Renderer4.PictureRasterTimeUS", (current_rasterize_time - prev_rasterize_time).InMicroseconds(), diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 2722c44..930ec05 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -17,7 +17,6 @@ #include "cc/animation/animation_registrar.h" #include "cc/animation/layer_animation_controller.h" #include "cc/base/math_util.h" -#include "cc/debug/benchmark_instrumentation.h" #include "cc/debug/devtools_instrumentation.h" #include "cc/debug/overdraw_metrics.h" #include "cc/debug/rendering_stats_instrumentation.h" @@ -777,10 +776,8 @@ bool LayerTreeHost::UsingSharedMemoryResources() { bool LayerTreeHost::UpdateLayers(Layer* root_layer, ResourceUpdateQueue* queue) { - TRACE_EVENT1(benchmark_instrumentation::kCategory, - benchmark_instrumentation::kLayerTreeHostUpdateLayers, - benchmark_instrumentation::kSourceFrameNumber, - source_frame_number()); + TRACE_EVENT1("cc", "LayerTreeHost::UpdateLayers", + "source_frame_number", source_frame_number()); RenderSurfaceLayerList update_list; { diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 8331bd5..c0c5c2a 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -17,6 +17,7 @@ #include "cc/animation/timing_function.h" #include "cc/base/math_util.h" #include "cc/base/util.h" +#include "cc/debug/benchmark_instrumentation.h" #include "cc/debug/debug_rect_history.h" #include "cc/debug/frame_rate_counter.h" #include "cc/debug/overdraw_metrics.h" @@ -1357,7 +1358,8 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame, } active_tree_->root_layer()->ResetAllChangeTrackingForSubtree(); - rendering_stats_instrumentation_->IssueTraceEventForImplThreadStats(); + BenchmarkInstrumentation::IssueImplThreadRenderingStatsEvent( + rendering_stats_instrumentation_->impl_thread_rendering_stats()); rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats(); } diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index 6b3d71c..634c3bc 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -6,6 +6,7 @@ #include "base/auto_reset.h" #include "base/debug/trace_event.h" +#include "cc/debug/benchmark_instrumentation.h" #include "cc/output/context_provider.h" #include "cc/output/output_surface.h" #include "cc/quads/draw_quad.h" @@ -225,7 +226,8 @@ void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { RenderingStatsInstrumentation* stats_instrumentation = layer_tree_host_->rendering_stats_instrumentation(); - stats_instrumentation->IssueTraceEventForMainThreadStats(); + BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent( + stats_instrumentation->main_thread_rendering_stats()); stats_instrumentation->AccumulateAndClearMainThreadStats(); } layer_tree_host_->CommitComplete(); diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index 0d7d679..d25002d 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -10,6 +10,7 @@ #include "base/bind.h" #include "base/debug/trace_event.h" #include "base/metrics/histogram.h" +#include "cc/debug/benchmark_instrumentation.h" #include "cc/input/input_handler.h" #include "cc/output/context_provider.h" #include "cc/output/output_surface.h" @@ -879,7 +880,8 @@ void ThreadProxy::BeginFrameOnMainThread( RenderingStatsInstrumentation* stats_instrumentation = layer_tree_host_->rendering_stats_instrumentation(); - stats_instrumentation->IssueTraceEventForMainThreadStats(); + BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent( + stats_instrumentation->main_thread_rendering_stats()); stats_instrumentation->AccumulateAndClearMainThreadStats(); } |