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 da073cb259b6df21e665df76ab06b0951da9b183..257abe2097bcb0ffeb44f01cbb956219b2d2a14b 100644 |
| --- a/content/renderer/render_thread_impl.cc |
| +++ b/content/renderer/render_thread_impl.cc |
| @@ -1695,6 +1695,24 @@ void RenderThreadImpl::OnProcessPurgeAndSuspend() { |
| return; |
| purge_and_suspend_memory_metrics_ = memory_metrics; |
| + GetRendererScheduler()->DefaultTaskRunner()->PostDelayedTask( |
| + FROM_HERE, |
| + base::Bind(&RenderThreadImpl::RecordPurgeAndSuspendMemoryGrowthMetrics, |
| + base::Unretained(this), process_foregrounded_count_, |
| + RECORD_30MIN_AFTER_PURGE), |
| + base::TimeDelta::FromMinutes(30)); |
| + GetRendererScheduler()->DefaultTaskRunner()->PostDelayedTask( |
| + FROM_HERE, |
| + base::Bind(&RenderThreadImpl::RecordPurgeAndSuspendMemoryGrowthMetrics, |
| + base::Unretained(this), process_foregrounded_count_, |
| + RECORD_60MIN_AFTER_PURGE), |
| + base::TimeDelta::FromMinutes(60)); |
| + GetRendererScheduler()->DefaultTaskRunner()->PostDelayedTask( |
| + FROM_HERE, |
| + base::Bind(&RenderThreadImpl::RecordPurgeAndSuspendMemoryGrowthMetrics, |
| + base::Unretained(this), process_foregrounded_count_, |
| + RECORD_90MIN_AFTER_PURGE), |
| + base::TimeDelta::FromMinutes(90)); |
| } |
| // TODO(tasak): Replace the following GetMallocUsage() with memory-infra |
| @@ -1796,16 +1814,39 @@ bool RenderThreadImpl::GetRendererMemoryMetrics( |
| ? current.allocator - previous.allocator \ |
| : 0) |
| -#define UMA_HISTOGRAM_MEMORY_GROWTH_KB(basename, suffix, memory_usage) \ |
| - { \ |
| - std::string histogram_name = \ |
| - base::StringPrintf("%s.%s", basename, suffix); \ |
| - UMA_HISTOGRAM_MEMORY_KB(histogram_name, memory_usage); \ |
| - } |
| +#define UMA_PURGE_AND_SUSPEND_MEMORY_GROWTH(suffix, memory_metrics) \ |
| + UMA_HISTOGRAM_MEMORY_KB( \ |
| + "PurgeAndSuspend.Experimental.MemoryGrowth.PartitionAllocKB" suffix, \ |
| + GET_MEMORY_GROWTH(memory_metrics, purge_and_suspend_memory_metrics_, \ |
| + partition_alloc_kb)); \ |
| + UMA_HISTOGRAM_MEMORY_KB( \ |
| + "PurgeAndSuspend.Experimental.MemoryGrowth.BlinkGCKB" suffix, \ |
| + GET_MEMORY_GROWTH(memory_metrics, purge_and_suspend_memory_metrics_, \ |
| + blink_gc_kb)); \ |
| + UMA_HISTOGRAM_MEMORY_KB( \ |
| + "PurgeAndSuspend.Experimental.MemoryGrowth.MallocKB" suffix, \ |
| + GET_MEMORY_GROWTH(memory_metrics, purge_and_suspend_memory_metrics_, \ |
| + malloc_mb) * \ |
| + 1024); \ |
| + UMA_HISTOGRAM_MEMORY_KB( \ |
| + "PurgeAndSuspend.Experimental.MemoryGrowth.DiscardableKB" suffix, \ |
| + GET_MEMORY_GROWTH(memory_metrics, purge_and_suspend_memory_metrics_, \ |
| + discardable_kb)); \ |
| + UMA_HISTOGRAM_MEMORY_KB( \ |
| + "PurgeAndSuspend.Experimental.MemoryGrowth." \ |
| + "V8MainThreadIsolateKB" suffix, \ |
| + GET_MEMORY_GROWTH(memory_metrics, purge_and_suspend_memory_metrics_, \ |
| + v8_main_thread_isolate_mb) * \ |
| + 1024); \ |
| + UMA_HISTOGRAM_MEMORY_KB( \ |
|
Ilya Sherman
2017/05/22 20:28:01
Could you use base::UmaHistogramMemoryKB() and avo
tasak
2017/05/23 05:15:16
Done.
|
| + "PurgeAndSuspend.Experimental.MemoryGrowth.TotalAllocatedKB" suffix, \ |
| + GET_MEMORY_GROWTH(memory_metrics, purge_and_suspend_memory_metrics_, \ |
| + total_allocated_mb) * \ |
| + 1024); |
| void RenderThreadImpl::RecordPurgeAndSuspendMemoryGrowthMetrics( |
| - const char* suffix, |
| - int foregrounded_count_when_purged) { |
| + int foregrounded_count_when_purged, |
| + RenderThreadImpl::RecordMemoryGrowthTiming record_timing) { |
| // If this renderer is resumed, we should not update UMA. |
| if (!RendererIsHidden()) |
| return; |
| @@ -1816,33 +1857,19 @@ void RenderThreadImpl::RecordPurgeAndSuspendMemoryGrowthMetrics( |
| if (!GetRendererMemoryMetrics(&memory_metrics)) |
| return; |
| - UMA_HISTOGRAM_MEMORY_GROWTH_KB( |
| - "PurgeAndSuspend.Experimental.MemoryGrowth.PartitionAllocKB", suffix, |
| - GET_MEMORY_GROWTH(memory_metrics, purge_and_suspend_memory_metrics_, |
| - partition_alloc_kb)); |
| - UMA_HISTOGRAM_MEMORY_GROWTH_KB( |
| - "PurgeAndSuspend.Experimental.MemoryGrowth.BlinkGCKB", suffix, |
| - GET_MEMORY_GROWTH(memory_metrics, purge_and_suspend_memory_metrics_, |
| - blink_gc_kb)); |
| - UMA_HISTOGRAM_MEMORY_GROWTH_KB( |
| - "PurgeAndSuspend.Experimental.MemoryGrowth.MallocKB", suffix, |
| - GET_MEMORY_GROWTH(memory_metrics, purge_and_suspend_memory_metrics_, |
| - malloc_mb) * |
| - 1024); |
| - UMA_HISTOGRAM_MEMORY_GROWTH_KB( |
| - "PurgeAndSuspend.Experimental.MemoryGrowth.DiscardableKB", suffix, |
| - GET_MEMORY_GROWTH(memory_metrics, purge_and_suspend_memory_metrics_, |
| - discardable_kb)); |
| - UMA_HISTOGRAM_MEMORY_GROWTH_KB( |
| - "PurgeAndSuspend.Experimental.MemoryGrowth.V8MainThreadIsolateKB", suffix, |
| - GET_MEMORY_GROWTH(memory_metrics, purge_and_suspend_memory_metrics_, |
| - v8_main_thread_isolate_mb) * |
| - 1024); |
| - UMA_HISTOGRAM_MEMORY_GROWTH_KB( |
| - "PurgeAndSuspend.Experimental.MemoryGrowth.TotalAllocatedKB", suffix, |
| - GET_MEMORY_GROWTH(memory_metrics, purge_and_suspend_memory_metrics_, |
| - total_allocated_mb) * |
| - 1024); |
| + switch (record_timing) { |
| + case RECORD_30MIN_AFTER_PURGE: |
| + UMA_PURGE_AND_SUSPEND_MEMORY_GROWTH("30min", memory_metrics); |
| + break; |
| + case RECORD_60MIN_AFTER_PURGE: |
| + UMA_PURGE_AND_SUSPEND_MEMORY_GROWTH("60min", memory_metrics); |
| + break; |
| + case RECORD_90MIN_AFTER_PURGE: |
| + UMA_PURGE_AND_SUSPEND_MEMORY_GROWTH("90min", memory_metrics); |
| + break; |
| + default: |
| + NOTREACHED(); |
|
Ilya Sherman
2017/05/22 20:28:01
nit: In general, it's discouraged to have default
tasak
2017/05/23 05:15:16
Done.
|
| + } |
| } |
| scoped_refptr<gpu::GpuChannelHost> RenderThreadImpl::EstablishGpuChannelSync() { |