Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0db49f9f authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes Icdaf1cf1,I80ba5adb,I8de912c1

* changes:
  libbacktrace: remove exit time destructors.
  libbacktrace: add benchmarks for Backtrace::Create, CreateNew.
  libbacktrace: let the benchmark library decide iteration count.
parents b88aa023 e22701ee
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -73,6 +73,10 @@ cc_library {
    defaults: ["libbacktrace_common"],
    host_supported: true,

    cflags: [
        "-Wexit-time-destructors",
    ],

    srcs: [
        "BacktraceMap.cpp",
    ],
@@ -230,5 +234,6 @@ cc_benchmark {
    shared_libs: [
        "libbacktrace",
        "libbase",
        "libunwindstack",
    ],
}
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@

bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
                       std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames) {
  static std::vector<std::string> skip_names{"libunwindstack.so", "libbacktrace.so"};
  std::vector<std::string> skip_names{"libunwindstack.so", "libbacktrace.so"};
  UnwindStackMap* stack_map = reinterpret_cast<UnwindStackMap*>(back_map);
  auto process_memory = stack_map->process_memory();
  unwindstack::Unwinder unwinder(MAX_BACKTRACE_FRAMES + num_ignore_frames, stack_map->stack_maps(),
+30 −10
Original line number Diff line number Diff line
@@ -32,13 +32,13 @@

#include <backtrace/Backtrace.h>
#include <backtrace/BacktraceMap.h>
#include <unwindstack/Memory.h>

// Definitions of prctl arguments to set a vma name in Android kernels.
#define ANDROID_PR_SET_VMA 0x53564d41
#define ANDROID_PR_SET_VMA_ANON_NAME 0

constexpr size_t kNumMaps = 2000;
constexpr size_t kNumIterations = 1000;

static bool CountMaps(pid_t pid, size_t* num_maps) {
  // Minimize the calls that might allocate memory. If too much memory
@@ -132,7 +132,6 @@ static void CreateMap(benchmark::State& state, BacktraceMap* (*map_func)(pid_t,
  }

  while (state.KeepRunning()) {
    for (size_t i = 0; i < static_cast<size_t>(state.range(0)); i++) {
    BacktraceMap* map = map_func(pid, false);
    if (map == nullptr) {
      fprintf(stderr, "Failed to create map\n");
@@ -140,7 +139,6 @@ static void CreateMap(benchmark::State& state, BacktraceMap* (*map_func)(pid_t,
    }
    delete map;
  }
  }

  kill(pid, SIGKILL);
  waitpid(pid, nullptr, 0);
@@ -149,11 +147,33 @@ static void CreateMap(benchmark::State& state, BacktraceMap* (*map_func)(pid_t,
static void BM_create_map(benchmark::State& state) {
  CreateMap(state, BacktraceMap::Create);
}
BENCHMARK(BM_create_map)->Arg(kNumIterations);
BENCHMARK(BM_create_map);

static void BM_create_map_new(benchmark::State& state) {
  CreateMap(state, BacktraceMap::CreateNew);
}
BENCHMARK(BM_create_map_new)->Arg(kNumIterations);
BENCHMARK(BM_create_map_new);


using BacktraceCreateFn = decltype(Backtrace::Create);

static void CreateBacktrace(benchmark::State& state, BacktraceMap* map, BacktraceCreateFn fn) {
  while (state.KeepRunning()) {
    std::unique_ptr<Backtrace> backtrace(fn(getpid(), gettid(), map));
    backtrace->Unwind(0);
  }
}

static void BM_create_backtrace(benchmark::State& state) {
  std::unique_ptr<BacktraceMap> backtrace_map(BacktraceMap::Create(getpid()));
  CreateBacktrace(state, backtrace_map.get(), Backtrace::Create);
}
BENCHMARK(BM_create_backtrace);

static void BM_create_backtrace_new(benchmark::State& state) {
  std::unique_ptr<BacktraceMap> backtrace_map(BacktraceMap::CreateNew(getpid()));
  CreateBacktrace(state, backtrace_map.get(), Backtrace::CreateNew);
}
BENCHMARK(BM_create_backtrace_new);

BENCHMARK_MAIN();
+4 −0
Original line number Diff line number Diff line
@@ -65,6 +65,10 @@ cc_library {
        "Symbols.cpp",
    ],

    cflags: [
        "-Wexit-time-destructors",
    ],

    target: {
        // Always disable optimizations for host to make it easier to debug.
        host: {