[compiler-rt] [scudo] Remove benchmarks file. (PR #102077)

Christopher Ferris via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 5 15:51:18 PDT 2024


https://github.com/cferris1000 created https://github.com/llvm/llvm-project/pull/102077

The benchmarks have never been used, and don't really provide much useful information. So remove them completely.

>From b29d11bdde772d3af596920a514053830d120ad1 Mon Sep 17 00:00:00 2001
From: Christopher Ferris <cferris at google.com>
Date: Mon, 5 Aug 2024 15:48:13 -0700
Subject: [PATCH] [scudo] Remove benchmarks file.

The benchmarks have never been used, and don't really provide
much useful information. So remove them completely.
---
 .../lib/scudo/standalone/CMakeLists.txt       |   1 -
 .../standalone/benchmarks/CMakeLists.txt      |  33 ------
 .../benchmarks/malloc_benchmark.cpp           | 105 ------------------
 3 files changed, 139 deletions(-)
 delete mode 100644 compiler-rt/lib/scudo/standalone/benchmarks/CMakeLists.txt
 delete mode 100644 compiler-rt/lib/scudo/standalone/benchmarks/malloc_benchmark.cpp

diff --git a/compiler-rt/lib/scudo/standalone/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/CMakeLists.txt
index 8fc245eb2cf38..dc700cec9becb 100644
--- a/compiler-rt/lib/scudo/standalone/CMakeLists.txt
+++ b/compiler-rt/lib/scudo/standalone/CMakeLists.txt
@@ -246,7 +246,6 @@ if(COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED)
     PARENT_TARGET scudo_standalone)
 endif()
 
-add_subdirectory(benchmarks)
 if(COMPILER_RT_INCLUDE_TESTS)
   add_subdirectory(tests)
 endif()
diff --git a/compiler-rt/lib/scudo/standalone/benchmarks/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/benchmarks/CMakeLists.txt
deleted file mode 100644
index 26d023c795859..0000000000000
--- a/compiler-rt/lib/scudo/standalone/benchmarks/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-# To build these benchmarks, build the target "ScudoBenchmarks.$ARCH", where
-# $ARCH is the name of the target architecture. For example,
-# ScudoBenchmarks.x86_64 for 64-bit x86. The benchmark executable is then
-# available under projects/compiler-rt/lib/scudo/standalone/benchmarks/ in the
-# build directory.
-
-include(AddLLVM)
-
-set(SCUDO_BENCHMARK_CFLAGS -I${COMPILER_RT_SOURCE_DIR}/lib/scudo/standalone)
-if(ANDROID)
-  list(APPEND SCUDO_BENCHMARK_CFLAGS -fno-emulated-tls)
-endif()
-string(REPLACE ";" " " SCUDO_BENCHMARK_CFLAGS " ${SCUDO_BENCHMARK_CFLAGS}")
-
-foreach(arch ${SCUDO_STANDALONE_SUPPORTED_ARCH})
-  add_benchmark(ScudoBenchmarks.${arch}
-                malloc_benchmark.cpp
-                $<TARGET_OBJECTS:RTScudoStandalone.${arch}>)
-  set_property(TARGET ScudoBenchmarks.${arch} APPEND_STRING PROPERTY
-               COMPILE_FLAGS "${SCUDO_BENCHMARK_CFLAGS}")
-
-  if (COMPILER_RT_HAS_GWP_ASAN)
-    add_benchmark(
-      ScudoBenchmarksWithGwpAsan.${arch} malloc_benchmark.cpp
-      $<TARGET_OBJECTS:RTScudoStandalone.${arch}>
-      $<TARGET_OBJECTS:RTGwpAsan.${arch}>
-      $<TARGET_OBJECTS:RTGwpAsanBacktraceLibc.${arch}>
-      $<TARGET_OBJECTS:RTGwpAsanSegvHandler.${arch}>)
-    set_property(
-      TARGET ScudoBenchmarksWithGwpAsan.${arch} APPEND_STRING PROPERTY
-      COMPILE_FLAGS "${SCUDO_BENCHMARK_CFLAGS} -DGWP_ASAN_HOOKS")
-  endif()
-endforeach()
diff --git a/compiler-rt/lib/scudo/standalone/benchmarks/malloc_benchmark.cpp b/compiler-rt/lib/scudo/standalone/benchmarks/malloc_benchmark.cpp
deleted file mode 100644
index 4fb05b7614c42..0000000000000
--- a/compiler-rt/lib/scudo/standalone/benchmarks/malloc_benchmark.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-//===-- malloc_benchmark.cpp ------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "allocator_config.h"
-#include "combined.h"
-#include "common.h"
-
-#include "benchmark/benchmark.h"
-
-#include <memory>
-#include <vector>
-
-void *CurrentAllocator;
-template <typename Config> void PostInitCallback() {
-  reinterpret_cast<scudo::Allocator<Config> *>(CurrentAllocator)->initGwpAsan();
-}
-
-template <typename Config> static void BM_malloc_free(benchmark::State &State) {
-  using AllocatorT = scudo::Allocator<Config, PostInitCallback<Config>>;
-  auto Deleter = [](AllocatorT *A) {
-    A->unmapTestOnly();
-    delete A;
-  };
-  std::unique_ptr<AllocatorT, decltype(Deleter)> Allocator(new AllocatorT,
-                                                           Deleter);
-  CurrentAllocator = Allocator.get();
-
-  const size_t NBytes = State.range(0);
-  size_t PageSize = scudo::getPageSizeCached();
-
-  for (auto _ : State) {
-    void *Ptr = Allocator->allocate(NBytes, scudo::Chunk::Origin::Malloc);
-    auto *Data = reinterpret_cast<uint8_t *>(Ptr);
-    for (size_t I = 0; I < NBytes; I += PageSize)
-      Data[I] = 1;
-    benchmark::DoNotOptimize(Ptr);
-    Allocator->deallocate(Ptr, scudo::Chunk::Origin::Malloc);
-  }
-
-  State.SetBytesProcessed(uint64_t(State.iterations()) * uint64_t(NBytes));
-}
-
-static const size_t MinSize = 8;
-static const size_t MaxSize = 128 * 1024;
-
-// FIXME: Add DefaultConfig here once we can tear down the exclusive TSD
-// cleanly.
-BENCHMARK_TEMPLATE(BM_malloc_free, scudo::AndroidConfig)
-    ->Range(MinSize, MaxSize);
-#if SCUDO_CAN_USE_PRIMARY64
-BENCHMARK_TEMPLATE(BM_malloc_free, scudo::FuchsiaConfig)
-    ->Range(MinSize, MaxSize);
-#endif
-
-template <typename Config>
-static void BM_malloc_free_loop(benchmark::State &State) {
-  using AllocatorT = scudo::Allocator<Config, PostInitCallback<Config>>;
-  auto Deleter = [](AllocatorT *A) {
-    A->unmapTestOnly();
-    delete A;
-  };
-  std::unique_ptr<AllocatorT, decltype(Deleter)> Allocator(new AllocatorT,
-                                                           Deleter);
-  CurrentAllocator = Allocator.get();
-
-  const size_t NumIters = State.range(0);
-  size_t PageSize = scudo::getPageSizeCached();
-  std::vector<void *> Ptrs(NumIters);
-
-  for (auto _ : State) {
-    size_t SizeLog2 = 0;
-    for (void *&Ptr : Ptrs) {
-      Ptr = Allocator->allocate(1 << SizeLog2, scudo::Chunk::Origin::Malloc);
-      auto *Data = reinterpret_cast<uint8_t *>(Ptr);
-      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);
-  }
-
-  State.SetBytesProcessed(uint64_t(State.iterations()) * uint64_t(NumIters) *
-                          8192);
-}
-
-static const size_t MinIters = 8;
-static const size_t MaxIters = 32 * 1024;
-
-// FIXME: Add DefaultConfig here once we can tear down the exclusive TSD
-// cleanly.
-BENCHMARK_TEMPLATE(BM_malloc_free_loop, scudo::AndroidConfig)
-    ->Range(MinIters, MaxIters);
-#if SCUDO_CAN_USE_PRIMARY64
-BENCHMARK_TEMPLATE(BM_malloc_free_loop, scudo::FuchsiaConfig)
-    ->Range(MinIters, MaxIters);
-#endif
-
-BENCHMARK_MAIN();



More information about the llvm-commits mailing list