Commit d700f112 authored by Weiliang Chen's avatar Weiliang Chen Committed by Commit Bot

gpu: Remove Unused GPU Memory Tracking Histograms

These GPU Memory Tracking UMA is no longer used. The sum of these
memory tracking can be found Memory.Gpu.PrivateMemoryFootprint. The
latest memory tracking uses the peak memory observer.

Bug: 928615, 1112389
Change-Id: Ia4ced34d8e1b7c7135b95d69219e1f5f4fe6e054
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2469076Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarJonathan Ross <jonross@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Commit-Queue: weiliangc <weiliangc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818032}
parent f616ef8b
...@@ -11,58 +11,19 @@ ...@@ -11,58 +11,19 @@
#include "gpu/ipc/common/command_buffer_id.h" #include "gpu/ipc/common/command_buffer_id.h"
#include "gpu/ipc/common/gpu_peak_memory.h" #include "gpu/ipc/common/gpu_peak_memory.h"
// Macro to reduce code duplication when logging memory in
// GpuCommandBufferMemoryTracker. This is needed as the UMA_HISTOGRAM_* macros
// require a unique call-site per histogram (you can't funnel multiple strings
// into the same call-site).
#define GPU_COMMAND_BUFFER_MEMORY_BLOCK(category) \
do { \
uint64_t mb_used = size_ / (1024 * 1024); \
switch (context_type_) { \
case CONTEXT_TYPE_WEBGL1: \
case CONTEXT_TYPE_WEBGL2: \
case CONTEXT_TYPE_WEBGL2_COMPUTE: \
UMA_HISTOGRAM_MEMORY_LARGE_MB("GPU.ContextMemory.WebGL." category, \
mb_used); \
break; \
case CONTEXT_TYPE_OPENGLES2: \
case CONTEXT_TYPE_OPENGLES3: \
UMA_HISTOGRAM_MEMORY_LARGE_MB("GPU.ContextMemory.GLES." category, \
mb_used); \
break; \
case CONTEXT_TYPE_WEBGPU: \
break; \
} \
} while (false)
namespace gpu { namespace gpu {
GpuCommandBufferMemoryTracker::GpuCommandBufferMemoryTracker( GpuCommandBufferMemoryTracker::GpuCommandBufferMemoryTracker(
CommandBufferId command_buffer_id, CommandBufferId command_buffer_id,
uint64_t client_tracing_id, uint64_t client_tracing_id,
ContextType context_type,
scoped_refptr<base::SingleThreadTaskRunner> task_runner, scoped_refptr<base::SingleThreadTaskRunner> task_runner,
Observer* observer) Observer* observer)
: command_buffer_id_(command_buffer_id), : command_buffer_id_(command_buffer_id),
client_tracing_id_(client_tracing_id), client_tracing_id_(client_tracing_id),
context_type_(context_type),
memory_pressure_listener_(
FROM_HERE,
base::BindRepeating(
&GpuCommandBufferMemoryTracker::LogMemoryStatsPressure,
base::Unretained(this))),
observer_(observer) { observer_(observer) {
// Set up |memory_stats_timer_| to call LogMemoryPeriodic periodically
// via the provided |task_runner|.
memory_stats_timer_.SetTaskRunner(std::move(task_runner));
memory_stats_timer_.Start(
FROM_HERE, base::TimeDelta::FromSeconds(30), this,
&GpuCommandBufferMemoryTracker::LogMemoryStatsPeriodic);
} }
GpuCommandBufferMemoryTracker::~GpuCommandBufferMemoryTracker() { GpuCommandBufferMemoryTracker::~GpuCommandBufferMemoryTracker() = default;
LogMemoryStatsShutdown();
}
void GpuCommandBufferMemoryTracker::TrackMemoryAllocatedChange(int64_t delta) { void GpuCommandBufferMemoryTracker::TrackMemoryAllocatedChange(int64_t delta) {
DCHECK(delta >= 0 || size_ >= static_cast<uint64_t>(-delta)); DCHECK(delta >= 0 || size_ >= static_cast<uint64_t>(-delta));
...@@ -90,21 +51,4 @@ uint64_t GpuCommandBufferMemoryTracker::ContextGroupTracingId() const { ...@@ -90,21 +51,4 @@ uint64_t GpuCommandBufferMemoryTracker::ContextGroupTracingId() const {
return command_buffer_id_.GetUnsafeValue(); return command_buffer_id_.GetUnsafeValue();
} }
void GpuCommandBufferMemoryTracker::LogMemoryStatsPeriodic() {
GPU_COMMAND_BUFFER_MEMORY_BLOCK("Periodic");
}
void GpuCommandBufferMemoryTracker::LogMemoryStatsShutdown() {
GPU_COMMAND_BUFFER_MEMORY_BLOCK("Shutdown");
}
void GpuCommandBufferMemoryTracker::LogMemoryStatsPressure(
base::MemoryPressureListener::MemoryPressureLevel pressure_level) {
// Only log on CRITICAL memory pressure.
if (pressure_level ==
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
GPU_COMMAND_BUFFER_MEMORY_BLOCK("Pressure");
}
}
} // namespace gpu } // namespace gpu
...@@ -24,7 +24,6 @@ class GPU_GLES2_EXPORT GpuCommandBufferMemoryTracker : public MemoryTracker { ...@@ -24,7 +24,6 @@ class GPU_GLES2_EXPORT GpuCommandBufferMemoryTracker : public MemoryTracker {
GpuCommandBufferMemoryTracker( GpuCommandBufferMemoryTracker(
CommandBufferId command_buffer_id, CommandBufferId command_buffer_id,
uint64_t client_tracing_id, uint64_t client_tracing_id,
ContextType context_type,
scoped_refptr<base::SingleThreadTaskRunner> task_runner, scoped_refptr<base::SingleThreadTaskRunner> task_runner,
Observer* observer); Observer* observer);
~GpuCommandBufferMemoryTracker() override; ~GpuCommandBufferMemoryTracker() override;
...@@ -37,20 +36,10 @@ class GPU_GLES2_EXPORT GpuCommandBufferMemoryTracker : public MemoryTracker { ...@@ -37,20 +36,10 @@ class GPU_GLES2_EXPORT GpuCommandBufferMemoryTracker : public MemoryTracker {
uint64_t ContextGroupTracingId() const override; uint64_t ContextGroupTracingId() const override;
private: private:
void LogMemoryStatsPeriodic();
void LogMemoryStatsShutdown();
void LogMemoryStatsPressure(
base::MemoryPressureListener::MemoryPressureLevel pressure_level);
uint64_t size_ = 0; uint64_t size_ = 0;
const CommandBufferId command_buffer_id_; const CommandBufferId command_buffer_id_;
const uint64_t client_tracing_id_; const uint64_t client_tracing_id_;
// Variables used in memory stat histogram logging.
const ContextType context_type_;
base::RepeatingTimer memory_stats_timer_;
base::MemoryPressureListener memory_pressure_listener_;
MemoryTracker::Observer* const observer_; MemoryTracker::Observer* const observer_;
DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferMemoryTracker); DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferMemoryTracker);
......
...@@ -358,7 +358,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread( ...@@ -358,7 +358,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
base::trace_event::MemoryDumpManager::GetInstance() base::trace_event::MemoryDumpManager::GetInstance()
->GetTracingProcessId(); ->GetTracingProcessId();
memory_tracker = std::make_unique<GpuCommandBufferMemoryTracker>( memory_tracker = std::make_unique<GpuCommandBufferMemoryTracker>(
command_buffer_id_, client_tracing_id, params.attribs.context_type, command_buffer_id_, client_tracing_id,
base::ThreadTaskRunnerHandle::Get(), /* obserer=*/nullptr); base::ThreadTaskRunnerHandle::Get(), /* obserer=*/nullptr);
} }
......
...@@ -649,15 +649,14 @@ void CommandBufferStub::RemoveDestructionObserver( ...@@ -649,15 +649,14 @@ void CommandBufferStub::RemoveDestructionObserver(
destruction_observers_.RemoveObserver(observer); destruction_observers_.RemoveObserver(observer);
} }
std::unique_ptr<MemoryTracker> CommandBufferStub::CreateMemoryTracker( std::unique_ptr<MemoryTracker> CommandBufferStub::CreateMemoryTracker() const {
const GPUCreateCommandBufferConfig& init_params) const {
MemoryTrackerFactory current_factory = GetMemoryTrackerFactory(); MemoryTrackerFactory current_factory = GetMemoryTrackerFactory();
if (current_factory) if (current_factory)
return current_factory.Run(init_params); return current_factory.Run();
return std::make_unique<GpuCommandBufferMemoryTracker>( return std::make_unique<GpuCommandBufferMemoryTracker>(
command_buffer_id_, channel_->client_tracing_id(), command_buffer_id_, channel_->client_tracing_id(),
init_params.attribs.context_type, channel_->task_runner(), channel_->task_runner(),
channel_->gpu_channel_manager()->peak_memory_monitor()); channel_->gpu_channel_manager()->peak_memory_monitor());
} }
......
...@@ -106,8 +106,7 @@ class GPU_IPC_SERVICE_EXPORT CommandBufferStub ...@@ -106,8 +106,7 @@ class GPU_IPC_SERVICE_EXPORT CommandBufferStub
void HandleReturnData(base::span<const uint8_t> data) override; void HandleReturnData(base::span<const uint8_t> data) override;
using MemoryTrackerFactory = using MemoryTrackerFactory =
base::RepeatingCallback<std::unique_ptr<MemoryTracker>( base::RepeatingCallback<std::unique_ptr<MemoryTracker>()>;
const GPUCreateCommandBufferConfig&)>;
// Overrides the way CreateMemoryTracker() uses to create a MemoryTracker. // Overrides the way CreateMemoryTracker() uses to create a MemoryTracker.
// This is intended for mocking the MemoryTracker in tests. // This is intended for mocking the MemoryTracker in tests.
...@@ -146,8 +145,7 @@ class GPU_IPC_SERVICE_EXPORT CommandBufferStub ...@@ -146,8 +145,7 @@ class GPU_IPC_SERVICE_EXPORT CommandBufferStub
protected: protected:
virtual bool HandleMessage(const IPC::Message& message) = 0; virtual bool HandleMessage(const IPC::Message& message) = 0;
std::unique_ptr<MemoryTracker> CreateMemoryTracker( std::unique_ptr<MemoryTracker> CreateMemoryTracker() const;
const GPUCreateCommandBufferConfig& init_params) const;
// Must be called during Initialize(). Takes ownership to co-ordinate // Must be called during Initialize(). Takes ownership to co-ordinate
// teardown in Destroy(). // teardown in Destroy().
......
...@@ -107,7 +107,7 @@ gpu::ContextResult GLES2CommandBufferStub::Initialize( ...@@ -107,7 +107,7 @@ gpu::ContextResult GLES2CommandBufferStub::Initialize(
manager->gpu_memory_buffer_factory(); manager->gpu_memory_buffer_factory();
context_group_ = new gles2::ContextGroup( context_group_ = new gles2::ContextGroup(
manager->gpu_preferences(), gles2::PassthroughCommandDecoderSupported(), manager->gpu_preferences(), gles2::PassthroughCommandDecoderSupported(),
manager->mailbox_manager(), CreateMemoryTracker(init_params), manager->mailbox_manager(), CreateMemoryTracker(),
manager->shader_translator_cache(), manager->shader_translator_cache(),
manager->framebuffer_completeness_cache(), feature_info, manager->framebuffer_completeness_cache(), feature_info,
init_params.attribs.bind_generates_resource, channel_->image_manager(), init_params.attribs.bind_generates_resource, channel_->image_manager(),
......
...@@ -100,8 +100,7 @@ struct ExpectedCacheEntry { ...@@ -100,8 +100,7 @@ struct ExpectedCacheEntry {
SkISize dimensions; SkISize dimensions;
}; };
std::unique_ptr<MemoryTracker> CreateMockMemoryTracker( std::unique_ptr<MemoryTracker> CreateMockMemoryTracker() {
const GPUCreateCommandBufferConfig& init_params) {
return std::make_unique<NiceMock<gles2::MockMemoryTracker>>(); return std::make_unique<NiceMock<gles2::MockMemoryTracker>>();
} }
......
...@@ -119,7 +119,7 @@ gpu::ContextResult RasterCommandBufferStub::Initialize( ...@@ -119,7 +119,7 @@ gpu::ContextResult RasterCommandBufferStub::Initialize(
use_virtualized_gl_context_ = use_virtualized_gl_context_ =
shared_context_state->use_virtualized_gl_contexts(); shared_context_state->use_virtualized_gl_contexts();
memory_tracker_ = CreateMemoryTracker(init_params); memory_tracker_ = CreateMemoryTracker();
command_buffer_ = command_buffer_ =
std::make_unique<CommandBufferService>(this, memory_tracker_.get()); std::make_unique<CommandBufferService>(this, memory_tracker_.get());
......
...@@ -106,7 +106,7 @@ gpu::ContextResult WebGPUCommandBufferStub::Initialize( ...@@ -106,7 +106,7 @@ gpu::ContextResult WebGPUCommandBufferStub::Initialize(
share_group_ = manager->share_group(); share_group_ = manager->share_group();
use_virtualized_gl_context_ = false; use_virtualized_gl_context_ = false;
memory_tracker_ = CreateMemoryTracker(init_params); memory_tracker_ = CreateMemoryTracker();
command_buffer_ = command_buffer_ =
std::make_unique<CommandBufferService>(this, memory_tracker_.get()); std::make_unique<CommandBufferService>(this, memory_tracker_.get());
......
...@@ -273,6 +273,11 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -273,6 +273,11 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</histogram> </histogram>
<histogram name="GPU.ContextMemory" units="MB" expires_after="2020-09-13"> <histogram name="GPU.ContextMemory" units="MB" expires_after="2020-09-13">
<obsolete>
Obsoleted since 2020/10/15. Unused and expired. Replaced by
Memory.Gpu.PrivateMemoryFootprint, Memory.GPU.PeakMemoryUsage, and
Memory.GPU.PeakMemoryAllocationSource.
</obsolete>
<owner>ericrk@chromium.org</owner> <owner>ericrk@chromium.org</owner>
<summary>The amount of memory used by a GL Context.</summary> <summary>The amount of memory used by a GL Context.</summary>
</histogram> </histogram>
......
...@@ -6820,6 +6820,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -6820,6 +6820,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</histogram_suffixes> </histogram_suffixes>
<histogram_suffixes name="GPU_ContextType" separator="."> <histogram_suffixes name="GPU_ContextType" separator=".">
<obsolete>
Expired in 2020/10/15.
</obsolete>
<suffix name="GLES" label="GLES Context."/> <suffix name="GLES" label="GLES Context."/>
<suffix name="WebGL" label="WebGL Context."/> <suffix name="WebGL" label="WebGL Context."/>
<affected-histogram name="GPU.ContextMemory"/> <affected-histogram name="GPU.ContextMemory"/>
...@@ -6835,6 +6838,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -6835,6 +6838,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</histogram_suffixes> </histogram_suffixes>
<histogram_suffixes name="GPU_MemorySamplingTime" separator="."> <histogram_suffixes name="GPU_MemorySamplingTime" separator=".">
<obsolete>
Expired in 2020/10/15.
</obsolete>
<suffix name="Periodic" label="Sampled periodically."/> <suffix name="Periodic" label="Sampled periodically."/>
<suffix name="Pressure" label="Sampled on CRITICAL memory pressure signal."/> <suffix name="Pressure" label="Sampled on CRITICAL memory pressure signal."/>
<suffix name="Shutdown" label="Sampled at shutdown."/> <suffix name="Shutdown" label="Sampled at shutdown."/>
......
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