[PATCH] D51173: Fix the configuration of the Primary allocator for Darwin ARM64

Dan Liew via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 23 10:13:12 PDT 2018


delcypher created this revision.
delcypher added reviewers: kubamracek, george.karpenkov, kcc, cryptoad, eugenis.
Herald added a reviewer: javed.absar.
Herald added subscribers: Sanitizers, chrib, kristof.beyls.

Fix the configuration of the Primary allocator for Darwin ARM64 by
changing the value of `SANITIZER_MMAP_RANGE_SIZE` to something more
sensible. The available VMA is at most 64GiB and not 256TiB that
was previously being used.

This change gives us several wins:

- Drastically improves LeakSanitizer performance on Darwin ARM64 devices. On a simple synthentic benchmark this took leak detection time from ~30 seconds to 0.5 seconds due to the `ForEachChunk(...)` method enumerating a much smaller number of regions. Previously we would pointlessly iterate over a large portion of the SizeClassAllocator32's ByteMap that would could never be set due it being configured for a much larger VM space than is actually availble.

- Decreases the memory required for the Primary allocator. Previously the ByteMap inside the the allocator used an array of pointers that took 512KiB of space. Now the required space for the array is 128 bytes.

rdar://problem/43509428


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D51173

Files:
  lib/sanitizer_common/sanitizer_platform.h


Index: lib/sanitizer_common/sanitizer_platform.h
===================================================================
--- lib/sanitizer_common/sanitizer_platform.h
+++ lib/sanitizer_common/sanitizer_platform.h
@@ -235,7 +235,12 @@
 #if defined(__mips__)
 # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 40)
 #elif defined(__aarch64__)
-# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 48)
+#  if SANITIZER_MAC
+// Darwin iOS/ARM64 has a 36-bit VMA, 64GiB VM
+#    define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 36)
+#  else
+#    define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 48)
+#  endif
 #else
 # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47)
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51173.162216.patch
Type: text/x-patch
Size: 785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180823/bb529bc5/attachment.bin>


More information about the llvm-commits mailing list