[compiler-rt] r290371 - Improve ThreadedQuarantineTest heap memory measurements.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 22 13:16:05 PST 2016


Author: eugenis
Date: Thu Dec 22 15:16:04 2016
New Revision: 290371

URL: http://llvm.org/viewvc/llvm-project?rev=290371&view=rev
Log:
Improve ThreadedQuarantineTest heap memory measurements.

Summary:
Warm up ASAN caches in ThreadedQuarantineTest to get more predictable
incremental heap memory usage measurements.

Reviewers: eugenis

Patch by Alex Shlyapnikov.

Subscribers: aemerson, kubabrecka, llvm-commits

Differential Revision: https://reviews.llvm.org/D28061

Modified:
    compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc

Modified: compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc?rev=290371&r1=290370&r2=290371&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc Thu Dec 22 15:16:04 2016
@@ -170,6 +170,12 @@ void *ThreadedQuarantineTestWorker(void
 // Check that the thread local allocators are flushed when threads are
 // destroyed.
 TEST(AddressSanitizer, ThreadedQuarantineTest) {
+  // Run the routine once to warm up ASAN internal structures to get more
+  // predictable incremental memory changes.
+  pthread_t t;
+  PTHREAD_CREATE(&t, NULL, ThreadedQuarantineTestWorker, 0);
+  PTHREAD_JOIN(t, 0);
+
   const int n_threads = 3000;
   size_t mmaped1 = __sanitizer_get_heap_size();
   for (int i = 0; i < n_threads; i++) {
@@ -178,7 +184,7 @@ TEST(AddressSanitizer, ThreadedQuarantin
     PTHREAD_JOIN(t, 0);
     size_t mmaped2 = __sanitizer_get_heap_size();
     // Figure out why this much memory is required.
-    EXPECT_LT(mmaped2 - mmaped1, 352U * (1 << 20));
+    EXPECT_LT(mmaped2 - mmaped1, 320U * (1 << 20));
   }
 }
 




More information about the llvm-commits mailing list