Bug 521227 - Remove the no longer needed zliballoc chunk optimizations. r=tglek
authorAlfred Kayser <alfredkayser@gmail.com>
Fri, 09 Oct 2009 14:30:45 +0200
changeset 33711 162daefc8007ef4a7971def1a3c7e4fc12aae3d5
parent 33710 7a931f8811fa709bb6e2eba48e5393b46e9b3c9f
child 33712 acc4587eeee8dafbb2c0a3d1bab3bcd754316955
push id9642
push useralfredkayser@gmail.com
push dateFri, 09 Oct 2009 14:26:26 +0000
treeherdermozilla-central@162daefc8007 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstglek
bugs521227
milestone1.9.3a1pre
Bug 521227 - Remove the no longer needed zliballoc chunk optimizations. r=tglek
modules/libjar/nsZipArchive.cpp
--- a/modules/libjar/nsZipArchive.cpp
+++ b/modules/libjar/nsZipArchive.cpp
@@ -58,22 +58,19 @@
 #include "plstr.h"
 #include "prlog.h"
 #include "stdlib.h"
 #include "nsWildCard.h"
 #include "zipstruct.h"
 #include "nsZipArchive.h"
 
 /**
- * Globals
- *
  * Global allocator used with zlib. Destroyed in module shutdown.
  */
 #define NBUCKETS 6
-#define BY4ALLOC_ITEMS 320
 nsRecyclingAllocator *gZlibAllocator = NULL;
 
 // For placement new used for arena allocations of zip file list
 #include NEW_H
 #define ZIP_ARENABLOCKSIZE (1*1024)
 
 #ifdef XP_UNIX
     #include <sys/types.h>
@@ -110,83 +107,40 @@ static PRUint32 HashName(const char* aNa
 #if defined(XP_UNIX) || defined(XP_BEOS)
 static PRBool IsSymlink(unsigned char *ll);
 static nsresult ResolveSymlink(const char *path);
 #endif
 
 //***********************************************************
 // Allocators for use with zlib
 //
-// These are allocators that are performance tuned for
-// use with zlib. Our use of zlib for every file we read from
-// the jar file when running navigator, we do these allocation.
-// alloc 24
-// alloc 64
-// alloc 11520
-// alloc 32768
-// alloc 1216 [304x4] max
-// alloc 76   [19x4]
-// free  76   [19x4]
-// alloc 1152 [288x4]
-// free  1152 [288x4]
-// free  1216 [304x4]
-// alloc 28
-// free  28
-// free  32768
-// free  11520
-// free  64
-// free  24
-//
-// The pool will allocate these as:
-//
-//          32,768
-//          11,520
-//           1,280 [320x4] - shared by first x4 alloc, 28
-//           1,280 [320x4] - shared by second and third x4 alloc
-//              64
-//              24
-//          ------
-//          46,936
-//
-// And almost all of the file reads happen serially. Hence this
-// allocator tries to keep one set of memory needed for one file around
-// and reused the same blocks for other file reads.
-//
-// The interesting question is when should be free this ?
-// - memory pressure should be one.
-// - after startup of navigator
-// - after startup of mail
-// In general, this allocator should be enabled before
-// we startup and disabled after we startup if memory is a concern.
+// Use a recycling allocator, for re-use of of the zlib buffers.
+// For every inflation the following allocations are done:
+// zlibAlloc(1, 9520)
+// zlibAlloc(32768, 1)
 //***********************************************************
 
 static void *
 zlibAlloc(void *opaque, uInt items, uInt size)
 {
   nsRecyclingAllocator *zallocator = (nsRecyclingAllocator *)opaque;
-  if (zallocator) {
-    // Bump up x4 allocations
-    PRUint32 realitems = items;
-    if (size == 4 && items < BY4ALLOC_ITEMS)
-      realitems = BY4ALLOC_ITEMS;
-    return zallocator->Calloc(realitems, size);
+  if (gZlibAllocator) {
+    return gZlibAllocator->Calloc(items, size);
   }
-  else
-    return calloc(items, size);
+  return calloc(items, size);
 }
 
 static void
 zlibFree(void *opaque, void *ptr)
 {
   nsRecyclingAllocator *zallocator = (nsRecyclingAllocator *)opaque;
   if (zallocator)
     zallocator->Free(ptr);
   else
     free(ptr);
-  return;
 }
 
 nsresult gZlibInit(z_stream *zs)
 {
   memset(zs, 0, sizeof(z_stream));
   //-- ensure we have our zlib allocator for better performance
   if (!gZlibAllocator) {
     gZlibAllocator = new nsRecyclingAllocator(NBUCKETS, NS_DEFAULT_RECYCLE_TIMEOUT, "libjar");