Commit 73d91f13 authored by Jonathan Ross's avatar Jonathan Ross Committed by Commit Bot

Peak GPU Memory Ablation Improved Size Controls

Update GpuMemoryAblationExperiment to have more fine grained controls
for setting the size of each ablation. Rather than there being 3 hard
coded sizes, the multiplier for the size is read in.

With setup to parse Finch parameters, and additional command line flag
for use with running experiments outside of Finch trials.

Bug: 908462
Change-Id: Ie6e03809f788334d15d20ba1756f94640d84bd81
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2360572Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Jonathan Ross <jonross@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803352}
parent cd08d726
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
#include <algorithm> #include <algorithm>
#include "base/bind.h" #include "base/bind.h"
#include "base/metrics/field_trial_params.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/trace_event/common/trace_event_common.h" #include "base/trace_event/common/trace_event_common.h"
#include "components/viz/common/features.h" #include "components/viz/common/features.h"
...@@ -21,6 +23,7 @@ ...@@ -21,6 +23,7 @@
#include "gpu/ipc/service/gpu_memory_buffer_factory.h" #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h" #include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
...@@ -32,21 +35,8 @@ namespace gpu { ...@@ -32,21 +35,8 @@ namespace gpu {
const base::Feature kGPUMemoryAblationFeature{ const base::Feature kGPUMemoryAblationFeature{
"GPUMemoryAblation", base::FEATURE_DISABLED_BY_DEFAULT}; "GPUMemoryAblation", base::FEATURE_DISABLED_BY_DEFAULT};
// TODO(jonross): Replace these feature flags with Field Trial Param lookup. // Field Trial Parameter that defines the size of memory allocations.
const base::Feature kGPUMemoryAblationGPUSmall{ const char kGPUMemoryAblationFeatureSizeParam[] = "Size";
"GPUMemoryAblationGPUSmall", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kGPUMemoryAblationGPUMedium{
"GPUMemoryAblationGPUMedium", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kGPUMemoryAblationGPULarge{
"GPUMemoryAblationGPULarge", base::FEATURE_DISABLED_BY_DEFAULT};
// The size to use when allocating images. The sizes vary based on the chosen
// experiment.
constexpr gfx::Size kSmallSize(256, 256);
constexpr gfx::Size kMediumSize(256 * 4, 256 * 4);
constexpr gfx::Size kLargeSize(256 * 8, 256 * 8);
// Image allocation parameters. // Image allocation parameters.
constexpr viz::ResourceFormat kFormat = viz::ResourceFormat::RGBA_8888; constexpr viz::ResourceFormat kFormat = viz::ResourceFormat::RGBA_8888;
...@@ -75,13 +65,6 @@ GpuMemoryAblationExperiment::GpuMemoryAblationExperiment( ...@@ -75,13 +65,6 @@ GpuMemoryAblationExperiment::GpuMemoryAblationExperiment(
: channel_manager_(channel_manager), task_runner_(task_runner) { : channel_manager_(channel_manager), task_runner_(task_runner) {
if (!GpuMemoryAblationExperiment::ExperimentSupported()) if (!GpuMemoryAblationExperiment::ExperimentSupported())
init_status_ = Status::DISABLED; init_status_ = Status::DISABLED;
if (base::FeatureList::IsEnabled(kGPUMemoryAblationGPUSmall)) {
size_ = kSmallSize;
} else if (base::FeatureList::IsEnabled(kGPUMemoryAblationGPUMedium)) {
size_ = kMediumSize;
} else if (base::FeatureList::IsEnabled(kGPUMemoryAblationGPULarge)) {
size_ = kLargeSize;
}
} }
GpuMemoryAblationExperiment::~GpuMemoryAblationExperiment() { GpuMemoryAblationExperiment::~GpuMemoryAblationExperiment() {
...@@ -219,6 +202,16 @@ bool GpuMemoryAblationExperiment::InitGpu(GpuChannelManager* channel_manager) { ...@@ -219,6 +202,16 @@ bool GpuMemoryAblationExperiment::InitGpu(GpuChannelManager* channel_manager) {
if (result != ContextResult::kSuccess) if (result != ContextResult::kSuccess)
return false; return false;
const int default_value = 0;
int arg_value = base::GetFieldTrialParamByFeatureAsInt(
kGPUMemoryAblationFeature, kGPUMemoryAblationFeatureSizeParam,
default_value);
if (arg_value == default_value)
return false;
int texture_size =
std::min(256 * arg_value, context_state_->gr_context()->maxTextureSize());
size_ = gfx::Size(texture_size, texture_size);
std::unique_ptr<ui::ScopedMakeCurrent> scoped_current = std::unique_ptr<ui::ScopedMakeCurrent> scoped_current =
ScopedMakeContextCurrent(); ScopedMakeContextCurrent();
if (!scoped_current) if (!scoped_current)
......
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