From a305b1d31e7d8b4a254cb148a1126efd9bbb75c9 Mon Sep 17 00:00:00 2001 From: Maxim Ostapenko Date: Thu, 17 Nov 2016 15:58:25 +0300 Subject: [PATCH] Make {A, L}San allocator more compact. 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 --- libsanitizer/asan/asan_allocator.h | 2 +- libsanitizer/lsan/lsan_allocator.cc | 2 +- libsanitizer/sanitizer_common/sanitizer_allocator.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libsanitizer/asan/asan_allocator.h b/libsanitizer/asan/asan_allocator.h index 921131a..6d9b7e4 100644 --- a/libsanitizer/asan/asan_allocator.h +++ b/libsanitizer/asan/asan_allocator.h @@ -125,7 +125,7 @@ typedef DefaultSizeClassMap SizeClassMap; typedef SizeClassAllocator64 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 ByteMap; diff --git a/libsanitizer/lsan/lsan_allocator.cc b/libsanitizer/lsan/lsan_allocator.cc index c3fd6ae..f0c6b0d 100644 --- a/libsanitizer/lsan/lsan_allocator.cc +++ b/libsanitizer/lsan/lsan_allocator.cc @@ -56,7 +56,7 @@ typedef SizeClassAllocator64> kRegionSizeLog; typedef FlatByteMap ByteMap; typedef SizeClassAllocator32<0, SANITIZER_MMAP_RANGE_SIZE, diff --git a/libsanitizer/sanitizer_common/sanitizer_allocator.h b/libsanitizer/sanitizer_common/sanitizer_allocator.h index 0490a3c..45e3244 100644 --- a/libsanitizer/sanitizer_common/sanitizer_allocator.h +++ b/libsanitizer/sanitizer_common/sanitizer_allocator.h @@ -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 struct SizeClassAllocatorLocalCache; // Memory allocator statistics -- 2.7.4