Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Unified Diff: skia/ext/skia_memory_dump_provider.cc

Issue 1259333003: [tracing] Add SkResourceCache as suballocation to avoid double counting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@skia_v1
Patch Set: Clean up. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: skia/ext/skia_memory_dump_provider.cc
diff --git a/skia/ext/skia_memory_dump_provider.cc b/skia/ext/skia_memory_dump_provider.cc
index a7c445fd5d4f1f9b34865ac3162a3b7bf0a1688e..3ade476e2934d04380a2d8d68bc304eebc8ab100 100644
--- a/skia/ext/skia_memory_dump_provider.cc
+++ b/skia/ext/skia_memory_dump_provider.cc
@@ -26,16 +26,28 @@ bool SkiaMemoryDumpProvider::OnMemoryDump(
base::trace_event::ProcessMemoryDump* process_memory_dump) {
auto font_mad =
process_memory_dump->CreateAllocatorDump("skia/sk_font_cache");
- font_mad->AddScalar("size", "bytes", SkGraphics::GetFontCacheUsed());
- font_mad->AddScalar("count", "objects", SkGraphics::GetFontCacheCountUsed());
-
- auto resource_mad =
- process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache");
- resource_mad->AddScalar("size", "bytes",
- SkResourceCache::GetTotalBytesUsed());
- // TODO(ssid): crbug.com/503168. Add sub-allocation edges from discardable or
- // malloc memory dumps to avoid double counting.
-
+ font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ SkGraphics::GetFontCacheUsed());
+ font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectsCount,
+ base::trace_event::MemoryAllocatorDump::kUnitsObjects,
+ SkGraphics::GetFontCacheCountUsed());
+
+ size_t skia_resource_cache_size = SkResourceCache::GetTotalBytesUsed();
+ if (skia_resource_cache_size > 0) {
petrcermak 2015/07/29 11:53:34 Shouldn't we report zero explicitly as well?
ssid 2015/07/29 16:20:51 Yea i think it makes more sense to dump 0
+ auto resource_mad =
+ process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache");
+ resource_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ skia_resource_cache_size);
+ if (SkResourceCache::GetDiscardableFactory()) {
+ process_memory_dump->AddSuballocation(resource_mad->guid(),
petrcermak 2015/07/29 11:53:34 You could use a ternary operator or factor out the
+ "discardable/allocated_objects");
+ } else {
+ process_memory_dump->AddSuballocation(resource_mad->guid(),
+ "malloc/allocated_objects");
petrcermak 2015/07/29 11:53:34 Please use the base::trace_event::MallocDumpProvid
ssid 2015/07/29 16:20:51 Done.
+ }
+ }
return true;
}

Powered by Google App Engine
This is Rietveld 408576698