Bug 686720 - Expose PSS from smaps in about:memory. r=khuey
authorJustin Lebar <justin.lebar@gmail.com>
Thu, 15 Sep 2011 10:53:04 -0700
changeset 77042 bbf7bdb0c75f424b461f0e83566a6f0d58dc6ae1
parent 77041 c04278a6e05156418eae4164c9a1301c5753728e
child 77043 29714d1f8a9b84a7640b8dd49db6a6e47b2f2e6e
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewerskhuey
bugs686720
milestone9.0a1
Bug 686720 - Expose PSS from smaps in about:memory. r=khuey
toolkit/components/aboutmemory/content/aboutMemory.js
xpcom/base/MapsMemoryReporter.cpp
--- a/toolkit/components/aboutmemory/content/aboutMemory.js
+++ b/toolkit/components/aboutmemory/content/aboutMemory.js
@@ -77,16 +77,24 @@ const kTreeDescriptions = {
     "process's mappings is currently using (the mapping's 'resident set size', " +
     "or 'RSS'). This is a good measure of the 'cost' of the mapping, although " +
     "it does not take into account the fact that shared libraries may be mapped " +
     "by multiple processes but appear only once in physical memory. " +
     "Note that the 'resident' value here might not equal the value for " +
     "'resident' under 'Other Measurements' because the two measurements are not " +
     "taken at exactly the same time.",
 
+  'pss':
+    "This tree shows how much space in physical memory can be 'blamed' on this " +
+    "process.  For each mapping, its 'proportional set size' (PSS) is the " +
+    "mapping's resident size divided by the number of processes which use the " +
+    "mapping.  So if a mapping is private to this process, its PSS should equal " +
+    "its RSS.  But if a mapping is shared between three processes, its PSS in " +
+    "each of the processes would be 1/3 its RSS.",
+
   'vsize':
     "This tree shows how much virtual addres space each of the process's " +
     "mappings takes up (the mapping's 'vsize').  A mapping may have a large " +
     "vsize but use only a small amount of physical memory; the resident set size " +
     "of a mapping is a better measure of the mapping's 'cost'. Note that the " +
     "'vsize' value here might not equal the value for 'vsize' under 'Other " +
     "Measurements' because the two measurements are not taken at exactly the " +
     "same time.",
@@ -95,22 +103,23 @@ const kTreeDescriptions = {
     "This tree shows how much space in the swap file each of the process's " +
     "mappings is currently using. Mappings which are not in the swap file " +
     "(i.e., nodes which would have a value of 0 in this tree) are omitted."
 };
 
 const kTreeNames = {
   'explicit': 'Explicit Allocations',
   'resident': 'Resident Set Size (RSS) Breakdown',
+  'pss':      'Proportional Set Size (PSS) Breakdown',
   'vsize':    'Virtual Size Breakdown',
   'swap':     'Swap Usage Breakdown',
   'other':    'Other Measurements'
 };
 
-const kMapTreePaths = ['map/resident', 'map/vsize', 'map/swap'];
+const kMapTreePaths = ['map/resident', 'map/pss', 'map/vsize', 'map/swap'];
 
 function onLoad()
 {
   var os = Cc["@mozilla.org/observer-service;1"].
       getService(Ci.nsIObserverService);
   os.notifyObservers(null, "child-memory-reporter-request", null);
 
   os.addObserver(ChildMemoryListener, "child-memory-reporter-update", false);
--- a/xpcom/base/MapsMemoryReporter.cpp
+++ b/xpcom/base/MapsMemoryReporter.cpp
@@ -109,22 +109,24 @@ void GetBasename(const nsCString &aPath,
   }
 }
 
 // MapsReporter::CollectReports uses this stuct to keep track of whether it's
 // seen a mapping under 'map/resident', 'map/vsize', and 'map/swap'.
 struct CategoriesSeen {
   CategoriesSeen() :
     mSeenResident(false),
+    mSeenPss(false),
     mSeenVsize(false),
     mSeenSwap(false)
   {
   }
 
   bool mSeenResident;
+  bool mSeenPss;
   bool mSeenVsize;
   bool mSeenSwap;
 };
 
 } // anonymous namespace
 
 class MapsReporter : public nsIMemoryMultiReporter
 {
@@ -462,16 +464,20 @@ MapsReporter::ParseMapBody(
   if (strcmp(desc, "Size") == 0) {
     category = "vsize";
     aCategoriesSeen->mSeenVsize = PR_TRUE;
   }
   else if (strcmp(desc, "Rss") == 0) {
     category = "resident";
     aCategoriesSeen->mSeenResident = PR_TRUE;
   }
+  else if (strcmp(desc, "Pss") == 0) {
+    category = "pss";
+    aCategoriesSeen->mSeenPss = PR_TRUE;
+  }
   else if (strcmp(desc, "Swap") == 0) {
     category = "swap";
     aCategoriesSeen->mSeenSwap = PR_TRUE;
   }
   else {
     // Don't report this category.
     return NS_OK;
   }