[PATCH] D73918: scudo: Use more size classes in the malloc_free_loop benchmarks.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 3 12:46:21 PST 2020


pcc created this revision.
pcc added a reviewer: cryptoad.
Herald added projects: Sanitizers, LLVM.
Herald added a subscriber: Sanitizers.

As a result of recent changes to the Android size classes, the malloc_free_loop
benchmark started exhausing 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73918

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


Index: compiler-rt/lib/scudo/standalone/benchmarks/malloc_benchmark.cpp
===================================================================
--- compiler-rt/lib/scudo/standalone/benchmarks/malloc_benchmark.cpp
+++ compiler-rt/lib/scudo/standalone/benchmarks/malloc_benchmark.cpp
@@ -69,12 +69,14 @@
   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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73918.242162.patch
Type: text/x-patch
Size: 922 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200203/4ef7b0c5/attachment.bin>


More information about the llvm-commits mailing list