Commit 66d91ac7 authored by Eugene Zemtsov's avatar Eugene Zemtsov Committed by Commit Bot

Exposing memory metrics for WebMediaPlayer via metrics emitter

Previous CL removed hand made memory related UMAs for WMP.
This CL uses the standard way to expose similar memory metrics.

The only interesting part is where we change memory dump naming
format from:
  media/webmediaplayer/player_%d/{video|audio}
to
  media/webmediaplayer/{video|audio}/player_%d

This is done in order to have readily available aggregating top
level nodes where total video or audio memory consumption can
be found.

Bug: 1056839
Change-Id: Ibf8d57da47f54b90ff4e3fe207d351ee043aa41c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2109461
Commit-Queue: Eugene Zemtsov <eugene@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarTakashi Sakamoto <tasak@google.com>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751923}
parent b0883f90
......@@ -179,6 +179,14 @@ const Metric kAllocatorDumpNamesForMetrics[] = {
{"mojo", "NumberOfMojoHandles", MetricSize::kSmall,
MemoryAllocatorDump::kNameObjectCount, EmitTo::kCountsInUkmOnly,
&Memory_Experimental::SetNumberOfMojoHandles},
{"media/webmediaplayer/audio", "WebMediaPlayer.Audio", MetricSize::kSmall,
kSize, EmitTo::kSizeInUmaOnly, nullptr},
{"media/webmediaplayer/video", "WebMediaPlayer.Video", MetricSize::kLarge,
kSize, EmitTo::kSizeInUmaOnly, nullptr},
{"media/webmediaplayer/data_source", "WebMediaPlayer.DataSource",
MetricSize::kLarge, kSize, EmitTo::kSizeInUmaOnly, nullptr},
{"media/webmediaplayer/demuxer", "WebMediaPlayer.Demuxer",
MetricSize::kLarge, kSize, EmitTo::kSizeInUmaOnly, nullptr},
{"net", "Net", MetricSize::kSmall, kEffectiveSize, EmitTo::kSizeInUkmAndUma,
&Memory_Experimental::SetNet},
{"net/url_request_context", "Net.UrlRequestContext", MetricSize::kSmall,
......
......@@ -272,7 +272,7 @@ void CreateAllocation(base::trace_event::ProcessMemoryDump* pmd,
if (bytes <= 0)
return;
auto full_name =
base::StringPrintf("media/webmediaplayer/player_%d/%s", id, name);
base::StringPrintf("media/webmediaplayer/%s/player_%d", name, id);
auto* dump = pmd->CreateAllocatorDump(full_name);
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
......@@ -3220,13 +3220,13 @@ void WebMediaPlayerImpl::OnMainThreadMemoryDump(
const PipelineStatistics stats = GetPipelineStatistics();
bool suspended = pipeline_controller_->IsPipelineSuspended();
auto parent_dump_name =
auto state_node_name =
base::StringPrintf("media/webmediaplayer/player_%d", id);
auto player_state =
base::StringPrintf("Paused: %d Ended: %d ReadyState: %d Suspended: %d",
paused_, ended_, GetReadyState(), suspended);
auto* parent_dump = pmd->CreateAllocatorDump(parent_dump_name);
parent_dump->AddString("player_state", "", player_state);
auto* state_node = pmd->CreateAllocatorDump(state_node_name);
state_node->AddString("player_state", "", player_state);
CreateAllocation(pmd, id, "audio", stats.audio_memory_usage);
CreateAllocation(pmd, id, "video", stats.video_memory_usage);
......
......@@ -2092,7 +2092,7 @@ TEST_F(WebMediaPlayerImplTest, MemDumpReporting) {
for (const char* name : allocations) {
auto it = dumps.find(base::StringPrintf(
"media/webmediaplayer/player_%d/%s", ctx->id, name));
"media/webmediaplayer/%s/player_%d", name, ctx->id));
ASSERT_NE(dumps.end(), it) << name;
ASSERT_GT(it->second->GetSizeInternal(), 0u) << name;
}
......
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