Commit 3c3873a6 authored by Khushal's avatar Khushal Committed by Commit Bot

cc: Use uniform distribution for sampling raster metric.

We currently keep a counter on the raster buffer provider for sampling
this metric, which can result in bias in some cases.

R=vmiura@chromium.org

Bug: 894200
Change-Id: I943afeaf5653ca30baee611f7d1f8ebb50a3030c
Reviewed-on: https://chromium-review.googlesource.com/c/1319029Reviewed-by: default avatarVictor Miura <vmiura@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605739}
parent 2a6256f9
......@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "base/metrics/histogram_macros.h"
#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_event.h"
......@@ -348,7 +349,9 @@ GpuRasterBufferProvider::GpuRasterBufferProvider(
unpremultiply_and_dither_low_bit_depth_tiles_(
unpremultiply_and_dither_low_bit_depth_tiles),
enable_oop_rasterization_(enable_oop_rasterization),
raster_metric_frequency_(raster_metric_frequency) {
raster_metric_frequency_(raster_metric_frequency),
random_generator_(base::RandUint64()),
uniform_distribution_(1, raster_metric_frequency) {
DCHECK(compositor_context_provider);
DCHECK(worker_context_provider);
}
......@@ -500,12 +503,8 @@ gpu::SyncToken GpuRasterBufferProvider::PlaybackOnWorkerThreadInternal(
gpu::raster::RasterInterface* ri = scoped_context.RasterInterface();
DCHECK(ri);
raster_tasks_count_++;
bool measure_raster_metric = false;
if (raster_tasks_count_ == raster_metric_frequency_) {
measure_raster_metric = true;
raster_tasks_count_ = 0;
}
const bool measure_raster_metric =
uniform_distribution_(random_generator_) == raster_metric_frequency_;
gfx::Rect playback_rect = raster_full_rect;
if (resource_has_previous_content) {
......
......@@ -6,6 +6,7 @@
#define CC_RASTER_GPU_RASTER_BUFFER_PROVIDER_H_
#include <stdint.h>
#include <random>
#include "base/macros.h"
#include "cc/raster/raster_buffer_provider.h"
......@@ -160,7 +161,8 @@ class CC_EXPORT GpuRasterBufferProvider : public RasterBufferProvider {
GUARDED_BY(pending_raster_queries_lock_);
// Accessed with the worker context lock acquired.
int raster_tasks_count_ = 0;
std::mt19937 random_generator_;
std::uniform_int_distribution<int> uniform_distribution_;
DISALLOW_COPY_AND_ASSIGN(GpuRasterBufferProvider);
};
......
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