Bug 1249174 (part 3) - Don't store the unused XPTInterfaceDirectoryEntry::name_space field in memory. r=khuey.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 23 Feb 2016 05:33:35 +1100
changeset 322327 df54281b08634341fb1a421b9753718966c45fe7
parent 322326 d8db031fc4a77c85088755f1919d9c4e11b82fed
child 322328 f4296d24c1f357f6b45acd50e76ea056afe3e2cc
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1249174
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1249174 (part 3) - Don't store the unused XPTInterfaceDirectoryEntry::name_space field in memory. r=khuey. Removing it reduces the "xpti-working-set" measurement by 16 KiB (measured on 64-bit).
xpcom/typelib/xpt/xpt_struct.cpp
xpcom/typelib/xpt/xpt_struct.h
xpcom/typelib/xpt/xpt_xdr.cpp
xpcom/typelib/xpt/xpt_xdr.h
--- a/xpcom/typelib/xpt/xpt_struct.cpp
+++ b/xpcom/typelib/xpt/xpt_struct.cpp
@@ -146,27 +146,29 @@ XPT_DoHeader(XPTArena *arena, XPTCursor 
     return PR_TRUE;
 }   
 
 /* InterfaceDirectoryEntry records go in the header */
 PRBool
 DoInterfaceDirectoryEntry(XPTArena *arena, XPTCursor *cursor,
                           XPTInterfaceDirectoryEntry *ide)
 {
+    char* dummy_name_space;
+
     /* write the IID in our cursor space */
     if (!XPT_DoIID(cursor, &(ide->iid)) ||
         
         /* write the name string in the data pool, and the offset in our
            cursor space */
         !XPT_DoCString(arena, cursor, &(ide->name)) ||
         
-        /* write the name_space string in the data pool, and the offset in our
-           cursor space */
-        !XPT_DoCString(arena, cursor, &(ide->name_space)) ||
-        
+        /* don't write the name_space string in the data pool, because we don't
+         * need it. Do write the offset in our cursor space */
+        !XPT_DoCString(arena, cursor, &dummy_name_space, /* ignore = */ true) ||
+
         /* do InterfaceDescriptors */
         !DoInterfaceDescriptor(arena, cursor, &ide->interface_descriptor)) {
         return PR_FALSE;
     }
 
     return PR_TRUE;
 }
 
--- a/xpcom/typelib/xpt/xpt_struct.h
+++ b/xpcom/typelib/xpt/xpt_struct.h
@@ -87,17 +87,21 @@ struct XPTHeader {
  * A contiguous array of fixed-size InterfaceDirectoryEntry records begins at 
  * the byte offset identified by the interface_directory field in the file 
  * header.  The array is used to quickly locate an interface description 
  * using its IID.  No interface should appear more than once in the array.
  */
 struct XPTInterfaceDirectoryEntry {
     nsID                   iid;
     char                   *name;
-    char                   *name_space;
+
+    // This field exists in the on-disk format. But it isn't used so we don't
+    // allocate space for it in memory.
+    //char                 *name_space;
+
     XPTInterfaceDescriptor *interface_descriptor;
 };
 
 /*
  * An InterfaceDescriptor is a variable-size record used to describe a 
  * single XPCOM interface, including all of its methods. 
  */
 struct XPTInterfaceDescriptor {
--- a/xpcom/typelib/xpt/xpt_xdr.cpp
+++ b/xpcom/typelib/xpt/xpt_xdr.cpp
@@ -94,17 +94,17 @@ XPT_SkipStringInline(XPTCursor *cursor)
     for (uint16_t i = 0; i < length; i++)
         if (!XPT_Do8(cursor, &byte))
             return PR_FALSE;
 
     return PR_TRUE;
 }
 
 XPT_PUBLIC_API(PRBool)
-XPT_DoCString(XPTArena *arena, XPTCursor *cursor, char **identp)
+XPT_DoCString(XPTArena *arena, XPTCursor *cursor, char **identp, bool ignore)
 {
     uint32_t offset = 0;
     if (!XPT_Do32(cursor, &offset))
         return PR_FALSE;
 
     if (!offset) {
         *identp = NULL;
         return PR_TRUE;
@@ -119,23 +119,25 @@ XPT_DoCString(XPTArena *arena, XPTCursor
     char* end = strchr(start, 0); /* find the end of the string */
     if (!end) {
         fprintf(stderr, "didn't find end of string on decode!\n");
         return PR_FALSE;
     }
     int len = end - start;
     XPT_ASSERT(len > 0);
 
-    char *ident = (char*)XPT_MALLOC(arena, len + 1u);
-    if (!ident)
-        return PR_FALSE;
+    if (!ignore) {
+        char *ident = (char*)XPT_MALLOC(arena, len + 1u);
+        if (!ident)
+            return PR_FALSE;
 
-    memcpy(ident, start, (size_t)len);
-    ident[len] = 0;
-    *identp = ident;
+        memcpy(ident, start, (size_t)len);
+        ident[len] = 0;
+        *identp = ident;
+    }
 
     return PR_TRUE;
 }
 
 /*
  * IIDs are written in struct order, in the usual big-endian way.  From the
  * typelib file spec:
  *
--- a/xpcom/typelib/xpt/xpt_xdr.h
+++ b/xpcom/typelib/xpt/xpt_xdr.h
@@ -18,17 +18,18 @@ extern "C" {
 
 typedef struct XPTState         XPTState;
 typedef struct XPTCursor        XPTCursor;
 
 extern XPT_PUBLIC_API(PRBool)
 XPT_SkipStringInline(XPTCursor *cursor);
 
 extern XPT_PUBLIC_API(PRBool)
-XPT_DoCString(XPTArena *arena, XPTCursor *cursor, char **strp);
+XPT_DoCString(XPTArena *arena, XPTCursor *cursor, char **strp,
+              bool ignore = false);
 
 extern XPT_PUBLIC_API(PRBool)
 XPT_DoIID(XPTCursor *cursor, nsID *iidp);
 
 extern XPT_PUBLIC_API(PRBool)
 XPT_Do64(XPTCursor *cursor, int64_t *u64p);
 
 extern XPT_PUBLIC_API(PRBool)