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

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: Nits. 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..aeb66846c387ff16cb9647a9db01965288176472 100644
--- a/skia/ext/skia_memory_dump_provider.cc
+++ b/skia/ext/skia_memory_dump_provider.cc
@@ -4,6 +4,8 @@
#include "skia_memory_dump_provider.h"
+#include "base/memory/discardable_shared_memory.h"
+#include "base/trace_event/malloc_dump_provider.h"
#include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/process_memory_dump.h"
@@ -26,16 +28,24 @@ 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());
-
+ 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());
+
+ const size_t skia_resource_cache_size = SkResourceCache::GetTotalBytesUsed();
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.
-
+ resource_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ skia_resource_cache_size);
+ const char* source_name =
+ SkResourceCache::GetDiscardableFactory()
+ ? base::DiscardableSharedMemory::kAllocatedObjectsDumpName
petrcermak 2015/07/29 16:39:00 Maybe rename the constant to "kAllocatedObjects" t
ssid 2015/07/29 16:57:37 Added dumpName since This is not really a dumpProv
+ : base::trace_event::MallocDumpProvider::kAllocatedObjects;
+ process_memory_dump->AddSuballocation(resource_mad->guid(), source_name);
return true;
petrcermak 2015/07/29 16:38:59 nit: I'd keep a blank line in front of the return
ssid 2015/07/29 16:57:37 Done.
}

Powered by Google App Engine
This is Rietveld 408576698