ResourceUsageOverlay should show GC-owned malloc memory.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Nov 2015 23:30:25 +0000 (23:30 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Nov 2015 23:30:25 +0000 (23:30 +0000)
<https://webkit.org/b/150846>

Reviewed by Anders Carlsson.

Add a memory category for GC-owned malloc memory. This carves a significant chunk off of
the gigantic "bmalloc" mystery slice.

* page/ResourceUsageOverlay.h:
* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::drawMemoryPie):
(WebCore::ResourceUsageOverlay::draw):
(WebCore::runSamplerThread):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191985 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/ResourceUsageOverlay.h
Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm

index 7b6d6f8..9ae2d92 100644 (file)
@@ -1,3 +1,19 @@
+2015-11-03  Andreas Kling  <akling@apple.com>
+
+        ResourceUsageOverlay should show GC-owned malloc memory.
+        <https://webkit.org/b/150846>
+
+        Reviewed by Anders Carlsson.
+
+        Add a memory category for GC-owned malloc memory. This carves a significant chunk off of
+        the gigantic "bmalloc" mystery slice.
+
+        * page/ResourceUsageOverlay.h:
+        * page/cocoa/ResourceUsageOverlayCocoa.mm:
+        (WebCore::drawMemoryPie):
+        (WebCore::ResourceUsageOverlay::draw):
+        (WebCore::runSamplerThread):
+
 2015-11-03  Saam barati  <sbarati@apple.com>
 
         Rewrite "const" as "var" for iTunes/iBooks on the Mac
index 7538fae..c84a9a2 100644 (file)
@@ -80,7 +80,7 @@ private:
 #endif
 
     static const int normalWidth = 500;
-    static const int normalHeight = 120;
+    static const int normalHeight = 130;
 };
 
 }
index 290d66e..f08ae0a 100644 (file)
@@ -77,6 +77,7 @@ static const RGBA32 colorForGCHeap     = 0xFFA0A0FF;
 static const RGBA32 colorForLibcMalloc = 0xFF00FF00;
 static const RGBA32 colorForFastMalloc = 0xFFFF6060;
 static const RGBA32 colorForOther      = 0xFFC0FF00;
+static const RGBA32 colorForGCOwned    = 0xFFFFC060;
 static const RGBA32 colorForLabels     = 0xFFE0E0E0;
 
 template<typename T, size_t size = 50>
@@ -136,6 +137,7 @@ struct ResourceUsageData {
     size_t layers { 0 };
     size_t images { 0 };
     size_t jitCode { 0 };
+    size_t gcOwned { 0 };
     size_t libcMalloc { 0 };
     size_t bmalloc { 0 };
     size_t sumDirty { 0 };
@@ -284,12 +286,13 @@ static void drawMemoryPie(GraphicsContext& context, float x, float y, ResourceUs
 
     FloatPoint center(x - 15, y + 60);
 
-    size_t bmallocWithDeductions = data.bmalloc - data.gcHeapCapacityHistory.last();
+    size_t bmallocWithDeductions = data.bmalloc - data.gcHeapCapacityHistory.last() - data.gcOwned;
 
     float angle = 0;
     drawSlice(context, center, angle, bmallocWithDeductions, data.sumDirty, colorForFastMalloc);
     drawSlice(context, center, angle, data.libcMalloc, data.sumDirty, colorForLibcMalloc);
     drawSlice(context, center, angle, data.gcHeapCapacityHistory.last(), data.sumDirty, colorForGCHeap);
+    drawSlice(context, center, angle, data.gcOwned, data.sumDirty, colorForGCOwned);
     drawSlice(context, center, angle, data.layers, data.sumDirty, colorForLayers);
     drawSlice(context, center, angle, data.images, data.sumDirty, colorForImages);
     drawSlice(context, center, angle, data.jitCode, data.sumDirty, colorForJITCode);
@@ -344,7 +347,7 @@ void ResourceUsageOverlay::draw(GraphicsContext& context)
     context.clearRect(m_overlay->bounds());
     CGRect viewBounds = m_overlay->bounds();
 
-    size_t bmallocWithDeductions = data.bmalloc - gcHeapCapacity;
+    size_t bmallocWithDeductions = data.bmalloc - gcHeapCapacity - data.gcOwned;
     size_t footprintWithDeductions = data.sumDirty - data.bmalloc - data.layers - data.images - data.libcMalloc - data.jitCode;
 
     showText(context, 10,  20, colorForLabels, String::format("        CPU: %g", data.cpuHistory.last()));
@@ -356,7 +359,8 @@ void ResourceUsageOverlay::draw(GraphicsContext& context)
     showText(context, 10,  80, colorForLayers,     "     Layers: " + formatByteNumber(data.layers));
     showText(context, 10,  90, colorForJITCode,    "     JS JIT: " + formatByteNumber(data.jitCode));
     showText(context, 10, 100, colorForGCHeap,     "    GC heap: " + formatByteNumber(gcHeapSize) + " (" + formatByteNumber(gcHeapCapacity) + ")");
-    showText(context, 10, 110, colorForOther,      "      Other: " + formatByteNumber(footprintWithDeductions));
+    showText(context, 10, 110, colorForGCOwned,    "   GC owned: " + formatByteNumber(data.gcOwned));
+    showText(context, 10, 120, colorForOther,      "      Other: " + formatByteNumber(footprintWithDeductions));
 
     drawCpuHistory(context, m_overlay->frame().width() - 50, 0, viewBounds.size.height, data.cpuHistory);
     drawGCHistory(context, m_overlay->frame().width() - 100, 0, viewBounds.size.height, data.gcHeapSizeHistory, data.gcHeapCapacityHistory);
@@ -444,6 +448,7 @@ NO_RETURN void runSamplerThread(void*)
             copyToVector(data.overlayLayers, layers);
 
             data.gcHeapCapacityHistory.append(data.vm->heap.blockBytesAllocated());
+            data.gcOwned = data.vm->heap.extraMemorySize();
         }
 
         [CATransaction begin];