[PATCH] D27873: Reduce the size of quarantine cache in ASAN_LOW_MEMORY configuration.

Aleksey Shlyapnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 17:27:22 PST 2016


alekseyshl created this revision.
alekseyshl added reviewers: eugenis, kcc.
alekseyshl added a subscriber: llvm-commits.
Herald added subscribers: kubabrecka, srhines, danalbert.

Experiments show that on Android the current values result in too much
of the memory consumption for all quarantined chunks.


https://reviews.llvm.org/D27873

Files:
  lib/asan/asan_allocator.cc
  lib/asan/asan_flags.cc
  lib/asan/asan_internal.h


Index: lib/asan/asan_internal.h
===================================================================
--- lib/asan/asan_internal.h
+++ lib/asan/asan_internal.h
@@ -36,7 +36,7 @@
 // If set, values like allocator chunk size, as well as defaults for some flags
 // will be changed towards less memory overhead.
 #ifndef ASAN_LOW_MEMORY
-# if SANITIZER_IOS || (SANITIZER_WORDSIZE == 32)
+# if SANITIZER_IOS || SANITIZER_ANDROID || (SANITIZER_WORDSIZE == 32)
 #  define ASAN_LOW_MEMORY 1
 # else
 #  define ASAN_LOW_MEMORY 0
Index: lib/asan/asan_flags.cc
===================================================================
--- lib/asan/asan_flags.cc
+++ lib/asan/asan_flags.cc
@@ -156,7 +156,7 @@
     f->quarantine_size_mb = f->quarantine_size >> 20;
   if (f->quarantine_size_mb < 0) {
     const int kDefaultQuarantineSizeMb =
-        (ASAN_LOW_MEMORY) ? 1UL << 6 : 1UL << 8;
+        (ASAN_LOW_MEMORY) ? 1UL << 4 : 1UL << 8;
     f->quarantine_size_mb = kDefaultQuarantineSizeMb;
   }
   if (!f->replace_str && common_flags()->intercept_strlen) {
Index: lib/asan/asan_allocator.cc
===================================================================
--- lib/asan/asan_allocator.cc
+++ lib/asan/asan_allocator.cc
@@ -227,7 +227,12 @@
   static const uptr kMaxAllowedMallocSize =
       FIRST_32_SECOND_64(3UL << 30, 1ULL << 40);
   static const uptr kMaxThreadLocalQuarantine =
-      FIRST_32_SECOND_64(1 << 18, 1 << 20);
+      // It is not advised to go lower than 64Kb, otherwise quarantine batches
+      // pushed from thread local quarantine to global one will create too much
+      // overhead. One quarantine batch size is 8Kb and it  holds up to 1021
+      // chunk, which amounts to 1/8 memory overhead per batch when thread local
+      // quarantine is set to 64Kb.
+      (ASAN_LOW_MEMORY) ? 64 << 10 : FIRST_32_SECOND_64(1 << 18, 1 << 20);
 
   AsanAllocator allocator;
   AsanQuarantine quarantine;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27873.81829.patch
Type: text/x-patch
Size: 1914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161217/24849193/attachment.bin>


More information about the llvm-commits mailing list