[compiler-rt] 47cda0c - scudo: Use more size classes in the malloc_free_loop benchmarks.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 3 13:18:56 PST 2020


Author: Peter Collingbourne
Date: 2020-02-03T13:18:25-08:00
New Revision: 47cda0cb36bfee8b99061eec59d17152608bf3cc

URL: https://github.com/llvm/llvm-project/commit/47cda0cb36bfee8b99061eec59d17152608bf3cc
DIFF: https://github.com/llvm/llvm-project/commit/47cda0cb36bfee8b99061eec59d17152608bf3cc.diff

LOG: scudo: Use more size classes in the malloc_free_loop benchmarks.

As a result of recent changes to the Android size classes, the malloc_free_loop
benchmark started exhausting the 8192 size class at 32768 iterations. To avoid
this problem (and to make the test more realistic), change the benchmark to
use a variety of size classes.

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

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/benchmarks/malloc_benchmark.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/benchmarks/malloc_benchmark.cpp b/compiler-rt/lib/scudo/standalone/benchmarks/malloc_benchmark.cpp
index 713820437b0f..ce48dc02f7ab 100644
--- a/compiler-rt/lib/scudo/standalone/benchmarks/malloc_benchmark.cpp
+++ b/compiler-rt/lib/scudo/standalone/benchmarks/malloc_benchmark.cpp
@@ -69,12 +69,14 @@ static void BM_malloc_free_loop(benchmark::State &State) {
   void *Ptrs[NumIters];
 
   for (auto _ : State) {
+    size_t SizeLog2 = 0;
     for (void *&Ptr : Ptrs) {
-      Ptr = Allocator->allocate(8192, scudo::Chunk::Origin::Malloc);
+      Ptr = Allocator->allocate(1 << SizeLog2, scudo::Chunk::Origin::Malloc);
       auto *Data = reinterpret_cast<uint8_t *>(Ptr);
-      for (size_t I = 0; I < 8192; I += PageSize)
+      for (size_t I = 0; I < 1 << SizeLog2; I += PageSize)
         Data[I] = 1;
       benchmark::DoNotOptimize(Ptr);
+      SizeLog2 = (SizeLog2 + 1) % 16;
     }
     for (void *&Ptr : Ptrs)
       Allocator->deallocate(Ptr, scudo::Chunk::Origin::Malloc);


        


More information about the llvm-commits mailing list