Chromium Code Reviews| Index: content/renderer/render_thread_impl.cc |
| diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc |
| index 5f63dba0b6b204fb236b97e2e8e27d081355c1a7..bafe835fd6fceaae2c8fb4bfda882981404b6a99 100644 |
| --- a/content/renderer/render_thread_impl.cc |
| +++ b/content/renderer/render_thread_impl.cc |
| @@ -938,6 +938,34 @@ RenderThreadImpl::~RenderThreadImpl() { |
| } |
| void RenderThreadImpl::Shutdown() { |
|
Ilya Sherman
2017/01/10 20:29:56
Are you sure that this code is routinely reached?
keishi
2017/01/11 02:40:46
You're right this wasn't called so I've removed th
|
| + { |
| + RendererMemoryMetrics memory_metrics; |
| + GetRendererMemoryMetrics(&memory_metrics); |
| + UMA_HISTOGRAM_MEMORY_MB( |
| + "Memory.Experimental.Renderer.Shutdown.PartitionAllocMB", |
| + memory_metrics.partition_alloc_kb / 1024); |
| + UMA_HISTOGRAM_MEMORY_MB( |
| + "Memory.Experimental.Renderer.Shutdown.BlinkGCMB", |
| + memory_metrics.blink_gc_kb / 1024); |
| + UMA_HISTOGRAM_MEMORY_MB("Memory.Experimental.Renderer.Shutdown.MallocMB", |
| + memory_metrics.malloc_mb); |
| + UMA_HISTOGRAM_MEMORY_MB( |
| + "Memory.Experimental.Renderer.Shutdown.DiscardableMB", |
| + memory_metrics.discardable_kb / 1024); |
| + UMA_HISTOGRAM_MEMORY_MB( |
| + "Memory.Experimental.Renderer.Shutdown.V8MainThreadIsolateMB", |
| + memory_metrics.v8_main_thread_isolate_mb); |
| + UMA_HISTOGRAM_MEMORY_MB( |
| + "Memory.Experimental.Renderer.Shutdown.TotalAllocatedMB", |
| + memory_metrics.total_allocated_mb); |
| + UMA_HISTOGRAM_MEMORY_MB( |
| + "Memory.Experimental.Renderer.Shutdown.NonDiscardableTotalAllocatedMB", |
| + memory_metrics.non_discardable_total_allocated_mb); |
| + UMA_HISTOGRAM_MEMORY_MB( |
| + "Memory.Experimental.Renderer.Shutdown.TotalAllocatedPerRenderViewMB", |
| + memory_metrics.total_allocated_per_render_view_mb); |
| + } |
| + |
| for (auto& observer : observers_) |
| observer.OnRenderProcessShutdown(); |
| @@ -1835,22 +1863,14 @@ static size_t GetMallocUsage() { |
| } // namespace |
| #endif |
| -// TODO(tasak): Once it is possible to use memory-infra without tracing, |
| -// we should collect the metrics using memory-infra. |
| -// TODO(tasak): We should also report a difference between the memory usages |
| -// before and after purging by using memory-infra. |
| -void RenderThreadImpl::RecordPurgeAndSuspendMetrics() const { |
| - // If this renderer is resumed, we should not update UMA. |
| - if (!RendererIsHidden()) |
| - return; |
| +void RenderThreadImpl::GetRendererMemoryMetrics( |
| + RendererMemoryMetrics* memory_metrics) const { |
| + DCHECK(memory_metrics); |
| - // TODO(tasak): Compare memory metrics between purge-enabled renderers and |
| - // purge-disabled renderers (A/B testing). |
| blink::WebMemoryStatistics blink_stats = blink::WebMemoryStatistics::Get(); |
| - UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.PartitionAllocKB", |
| - blink_stats.partitionAllocTotalAllocatedBytes / 1024); |
| - UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.BlinkGCKB", |
| - blink_stats.blinkGCTotalAllocatedBytes / 1024); |
| + memory_metrics->partition_alloc_kb = |
| + blink_stats.partitionAllocTotalAllocatedBytes / 1024; |
| + memory_metrics->blink_gc_kb = blink_stats.blinkGCTotalAllocatedBytes / 1024; |
| #if defined(OS_LINUX) || defined(OS_ANDROID) |
| struct mallinfo minfo = mallinfo(); |
| #if defined(USE_TCMALLOC) |
| @@ -1861,15 +1881,13 @@ void RenderThreadImpl::RecordPurgeAndSuspendMetrics() const { |
| #else |
| size_t malloc_usage = GetMallocUsage(); |
| #endif |
| - UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.MallocMB", |
| - malloc_usage / 1024 / 1024); |
| + memory_metrics->malloc_mb = malloc_usage / 1024 / 1024; |
| discardable_memory::ClientDiscardableSharedMemoryManager::Statistics |
| discardable_stats = discardable_shared_memory_manager_->GetStatistics(); |
| size_t discardable_usage = |
| discardable_stats.total_size - discardable_stats.freelist_size; |
| - UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.DiscardableKB", |
| - discardable_usage / 1024); |
| + memory_metrics->discardable_kb = discardable_usage / 1024; |
| size_t v8_usage = 0; |
| if (v8::Isolate* isolate = blink::mainThreadIsolate()) { |
| @@ -1880,13 +1898,42 @@ void RenderThreadImpl::RecordPurgeAndSuspendMetrics() const { |
| // TODO(tasak): Currently only memory usage of mainThreadIsolate() is |
| // reported. We should collect memory usages of all isolates using |
| // memory-infra. |
| + memory_metrics->v8_main_thread_isolate_mb = v8_usage / 1024 / 1024; |
| + size_t total_allocated = blink_stats.partitionAllocTotalAllocatedBytes + |
| + blink_stats.blinkGCTotalAllocatedBytes + |
| + malloc_usage + v8_usage + discardable_usage; |
| + memory_metrics->total_allocated_mb = total_allocated / 1024 / 1024; |
| + memory_metrics->non_discardable_total_allocated_mb = |
| + (total_allocated - discardable_usage) / 1024 / 1024; |
| + memory_metrics->total_allocated_per_render_view_mb = |
| + total_allocated / RenderView::GetRenderViewCount() / 1024 / 1024; |
| +} |
| + |
| +// TODO(tasak): Once it is possible to use memory-infra without tracing, |
| +// we should collect the metrics using memory-infra. |
| +// TODO(tasak): We should also report a difference between the memory usages |
| +// before and after purging by using memory-infra. |
| +void RenderThreadImpl::RecordPurgeAndSuspendMetrics() const { |
| + // If this renderer is resumed, we should not update UMA. |
| + if (!RendererIsHidden()) |
| + return; |
| + |
| + // TODO(tasak): Compare memory metrics between purge-enabled renderers and |
| + // purge-disabled renderers (A/B testing). |
| + RendererMemoryMetrics memory_metrics; |
| + GetRendererMemoryMetrics(&memory_metrics); |
| + UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.PartitionAllocKB", |
| + memory_metrics.partition_alloc_kb); |
| + UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.BlinkGCKB", |
| + memory_metrics.blink_gc_kb); |
| + UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.MallocMB", |
| + memory_metrics.malloc_mb); |
| + UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.DiscardableKB", |
| + memory_metrics.discardable_kb); |
| UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.V8MainThreadIsolateMB", |
| - v8_usage / 1024 / 1024); |
| + memory_metrics.v8_main_thread_isolate_mb); |
| UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.TotalAllocatedMB", |
| - (blink_stats.partitionAllocTotalAllocatedBytes + |
| - blink_stats.blinkGCTotalAllocatedBytes + |
| - malloc_usage + v8_usage + discardable_usage) / |
| - 1024 / 1024); |
| + memory_metrics.total_allocated_mb); |
| } |
| void RenderThreadImpl::OnProcessResume() { |