Make {A, L}San allocator more compact. 60/98760/1
authorMaxim Ostapenko <m.ostapenko@samsung.com>
Thu, 17 Nov 2016 12:58:25 +0000 (15:58 +0300)
committerMaxim Ostapenko <m.ostapenko@samsung.com>
Fri, 18 Nov 2016 13:11:46 +0000 (16:11 +0300)
This change tries to reduce memory consumption of {A, L}Saned image by hacking
primary allocator internals:

* Reduce region size 2^20 -> 2^17.
* Make largest chunk size in primary allocator 2^17 -> 2^16.

The change appears to be quite useful for LSan'ed image:

Stock version:
           total      used      free     shared    buffers     cached
Mem:        964        828       136        3         4         92

Patched version:
           total      used      free     shared    buffers     cached
Mem:        964        688       275        5         13        185

Change-Id: I80b95f7dfb5a7be0e7208567a31606a3d027256c
Signed-off-by: Maxim Ostapenko <m.ostapenko@samsung.com>
libsanitizer/asan/asan_allocator.h
libsanitizer/lsan/lsan_allocator.cc
libsanitizer/sanitizer_common/sanitizer_allocator.h

index 921131a..6d9b7e4 100644 (file)
@@ -125,7 +125,7 @@ typedef DefaultSizeClassMap SizeClassMap;
 typedef SizeClassAllocator64<kAllocatorSpace, kAllocatorSize, 0 /*metadata*/,
     SizeClassMap, AsanMapUnmapCallback> PrimaryAllocator;
 #else  // Fallback to SizeClassAllocator32.
-static const uptr kRegionSizeLog = 20;
+static const uptr kRegionSizeLog = 17;
 static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog;
 # if SANITIZER_WORDSIZE == 32
 typedef FlatByteMap<kNumRegions> ByteMap;
index c3fd6ae..f0c6b0d 100644 (file)
@@ -56,7 +56,7 @@ typedef SizeClassAllocator64<kAllocatorSpace, kAllocatorSize,
 #endif
 #else // SANITIZER_WORDSIZE == 32
 typedef CompactSizeClassMap SizeClassMap;
-static const uptr kRegionSizeLog = 20;
+static const uptr kRegionSizeLog = 17;
 static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog;
 typedef FlatByteMap<kNumRegions> ByteMap;
 typedef SizeClassAllocator32<0, SANITIZER_MMAP_RANGE_SIZE,
index 0490a3c..45e3244 100644 (file)
@@ -191,7 +191,7 @@ class SizeClassMap {
 };
 
 typedef SizeClassMap<17, 128, 16> DefaultSizeClassMap;
-typedef SizeClassMap<17, 64,  14> CompactSizeClassMap;
+typedef SizeClassMap<16, 64,  14> CompactSizeClassMap;
 template<class SizeClassAllocator> struct SizeClassAllocatorLocalCache;
 
 // Memory allocator statistics