summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Shlyapnikov <alekseys@google.com>2017-10-26 17:59:24 +0000
committerAlex Shlyapnikov <alekseys@google.com>2017-10-26 17:59:24 +0000
commit9b4e32785ab10c28240634aa0a2a2f5100704d6f (patch)
treeb242dfb7f0a4fb1f48fcd7789e56a6342a376213
parent593ec59c7eb1ea97e59aa0871d267d51f6c62133 (diff)
downloadbcm5719-llvm-9b4e32785ab10c28240634aa0a2a2f5100704d6f.tar.gz
bcm5719-llvm-9b4e32785ab10c28240634aa0a2a2f5100704d6f.zip
[Sanitizers] Set default allocator_release_to_os_interval_ms to 5 seconds
Summary: With new release to OS approach (see D38245) it's reasonable to enable it by default. Setting allocator_release_to_os_interval_ms to 5000 seems to be a reasonable default (might be tuned later, based on the feedback). Also delaying the first release to OS in each bucket for at least allocator_release_to_os_interval_ms after the first allocation to prevent just allocated memory to be madvised back to OS and let short lived processes to avoid release to OS overhead altogether. Reviewers: cryptoad Subscribers: kubamracek, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D39318 llvm-svn: 316683
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h10
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_flags.inc10
2 files changed, 13 insertions, 7 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
index 8b7610b2cc2..b22f3aba9ca 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
@@ -669,10 +669,16 @@ class SizeClassAllocator64 {
// Map more space for chunks, if necessary.
if (new_space_end > region->mapped_user) {
- if (!kUsingConstantSpaceBeg && kRandomShuffleChunks)
- if (UNLIKELY(region->mapped_user == 0))
+ if (UNLIKELY(region->mapped_user == 0)) {
+ if (!kUsingConstantSpaceBeg && kRandomShuffleChunks)
// The random state is initialized from ASLR.
region->rand_state = static_cast<u32>(region_beg >> 12);
+ // Postpone the first release to OS attempt for ReleaseToOSIntervalMs,
+ // preventing just allocated memory from being released sooner than
+ // necessary and also preventing extraneous ReleaseMemoryPagesToOS calls
+ // for short lived processes.
+ region->rtoi.last_release_at_ns = NanoTime();
+ }
// Do the mmap for the user memory.
uptr map_size = kUserMapSize;
while (new_space_end > region->mapped_user + map_size)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
index eab33ab4562..21876e08f4a 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
@@ -129,11 +129,11 @@ COMMON_FLAG(uptr, soft_rss_limit_mb, 0,
" This limit does not affect memory allocations other than"
" malloc/new.")
COMMON_FLAG(bool, heap_profile, false, "Experimental heap profiler, asan-only")
-COMMON_FLAG(s32, allocator_release_to_os_interval_ms, kReleaseToOSIntervalNever,
- "Experimental. Only affects a 64-bit allocator. If set, tries to "
- "release unused memory to the OS, but not more often than this "
- "interval (in milliseconds). Negative values mean do not attempt "
- "to release memory to the OS.\n")
+COMMON_FLAG(s32, allocator_release_to_os_interval_ms, 5000,
+ "Only affects a 64-bit allocator. If set, tries to release unused "
+ "memory to the OS, but not more often than this interval (in "
+ "milliseconds). Negative values mean do not attempt to release "
+ "memory to the OS.\n")
COMMON_FLAG(bool, can_use_proc_maps_statm, true,
"If false, do not attempt to read /proc/maps/statm."
" Mostly useful for testing sanitizers.")
OpenPOWER on IntegriCloud