197 lines
5.5 KiB
Diff
197 lines
5.5 KiB
Diff
|
|
From 630c9ce77822212a4ce3ee92afabbec0eea0f94b Mon Sep 17 00:00:00 2001
|
||
|
|
From: Aliaksey Kandratsenka <alkondratenko@gmail.com>
|
||
|
|
Date: Sun, 7 Oct 2018 08:17:04 -0700
|
||
|
|
Subject: [PATCH] Drop not very portable and not very useful unwind benchmark.
|
||
|
|
|
||
|
|
---
|
||
|
|
Makefile.am | 8 ----
|
||
|
|
benchmark/getcontext_light.cc | 60 -----------------------------
|
||
|
|
benchmark/unwind_bench.cc | 89 -------------------------------------------
|
||
|
|
3 files changed, 157 deletions(-)
|
||
|
|
delete mode 100644 benchmark/getcontext_light.cc
|
||
|
|
delete mode 100644 benchmark/unwind_bench.cc
|
||
|
|
|
||
|
|
diff --git a/Makefile.am b/Makefile.am
|
||
|
|
index c79227a..1f52d3d 100755
|
||
|
|
--- a/Makefile.am
|
||
|
|
+++ b/Makefile.am
|
||
|
|
@@ -881,14 +881,6 @@ malloc_bench_shared_full_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTI
|
||
|
|
malloc_bench_shared_full_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
|
||
|
|
malloc_bench_shared_full_LDADD = librun_benchmark.la libtcmalloc.la $(PTHREAD_LIBS)
|
||
|
|
|
||
|
|
-if !OSX
|
||
|
|
-noinst_PROGRAMS += unwind_bench
|
||
|
|
-unwind_bench_SOURCES = benchmark/unwind_bench.cc benchmark/getcontext_light.cc
|
||
|
|
-unwind_bench_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
|
||
|
|
-unwind_bench_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
|
||
|
|
-unwind_bench_LDADD = librun_benchmark.la libtcmalloc.la $(PTHREAD_LIBS)
|
||
|
|
-endif !OSX
|
||
|
|
-
|
||
|
|
endif WITH_HEAP_PROFILER_OR_CHECKER
|
||
|
|
|
||
|
|
binary_trees_SOURCES = benchmark/binary_trees.cc
|
||
|
|
diff --git a/benchmark/getcontext_light.cc b/benchmark/getcontext_light.cc
|
||
|
|
deleted file mode 100644
|
||
|
|
index e8ff8b3..0000000
|
||
|
|
--- a/benchmark/getcontext_light.cc
|
||
|
|
+++ /dev/null
|
||
|
|
@@ -1,60 +0,0 @@
|
||
|
|
-#include <ucontext.h>
|
||
|
|
-#include <stddef.h>
|
||
|
|
-
|
||
|
|
-extern "C" void getcontext_light(ucontext_t *ctx);
|
||
|
|
-
|
||
|
|
-// clang's built-in asm cannot handle .set directives
|
||
|
|
-#if defined(__GNUC__) && !defined(__llvm__) && defined(__x86_64) && defined(_LP64)
|
||
|
|
-
|
||
|
|
-#define R(r) offsetof(ucontext_t, uc_mcontext.gregs[r])
|
||
|
|
-
|
||
|
|
-static __attribute__((used))
|
||
|
|
-void getcontext_tramp(ucontext_t *ctx) {
|
||
|
|
- __asm__ __volatile__(".set oRBX, %c0\n"
|
||
|
|
- ".set oRBP, %c1\n"
|
||
|
|
- ".set oR12, %c2\n"
|
||
|
|
- ".set oR13, %c3\n"
|
||
|
|
- ".set oR14, %c4\n"
|
||
|
|
- ".set oR15, %c5\n"
|
||
|
|
- ".set oRIP, %c6\n"
|
||
|
|
- ".set oRSP, %c7\n"
|
||
|
|
- : :
|
||
|
|
- "p" (R(REG_RBX)),
|
||
|
|
- "p" (R(REG_RBP)),
|
||
|
|
- "p" (R(REG_R12)),
|
||
|
|
- "p" (R(REG_R13)),
|
||
|
|
- "p" (R(REG_R14)),
|
||
|
|
- "p" (R(REG_R15)),
|
||
|
|
- "p" (R(REG_RIP)),
|
||
|
|
- "p" (R(REG_RSP)));
|
||
|
|
- getcontext_light(ctx);
|
||
|
|
-}
|
||
|
|
-
|
||
|
|
-__asm__(".pushsection .text; .globl getcontext_light\n"
|
||
|
|
- ".type getcontext_light, @function\n"
|
||
|
|
-"getcontext_light:\n"
|
||
|
|
- "\t.cfi_startproc\n"
|
||
|
|
- "\tmovq %rbx, oRBX(%rdi)\n"
|
||
|
|
- "\tmovq %rbp, oRBP(%rdi)\n"
|
||
|
|
- "\tmovq %r12, oR12(%rdi)\n"
|
||
|
|
- "\tmovq %r13, oR13(%rdi)\n"
|
||
|
|
- "\tmovq %r14, oR14(%rdi)\n"
|
||
|
|
- "\tmovq %r15, oR14(%rdi)\n"
|
||
|
|
-
|
||
|
|
- "\tmovq (%rsp), %rcx\n"
|
||
|
|
- "\tmovq %rcx, oRIP(%rdi)\n"
|
||
|
|
- "\tleaq 8(%rsp), %rcx\n" /* Exclude the return address. */
|
||
|
|
- "\tmovq %rcx, oRSP(%rdi)\n"
|
||
|
|
- "\tret\n"
|
||
|
|
- ".cfi_endproc\n"
|
||
|
|
- ".size getcontext_light, .-getcontext_light\n"
|
||
|
|
- ".popsection\n"
|
||
|
|
- );
|
||
|
|
-
|
||
|
|
-#else
|
||
|
|
-
|
||
|
|
-extern "C" void getcontext_light(ucontext_t *ctx) {
|
||
|
|
- getcontext(ctx);
|
||
|
|
-}
|
||
|
|
-
|
||
|
|
-#endif
|
||
|
|
diff --git a/benchmark/unwind_bench.cc b/benchmark/unwind_bench.cc
|
||
|
|
deleted file mode 100644
|
||
|
|
index 9c4e2f8..0000000
|
||
|
|
--- a/benchmark/unwind_bench.cc
|
||
|
|
+++ /dev/null
|
||
|
|
@@ -1,89 +0,0 @@
|
||
|
|
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
|
||
|
|
-#include "config.h"
|
||
|
|
-
|
||
|
|
-#include "base/basictypes.h"
|
||
|
|
-#include "gperftools/stacktrace.h"
|
||
|
|
-
|
||
|
|
-#include <stdlib.h>
|
||
|
|
-#include <stdio.h>
|
||
|
|
-#include <stdint.h>
|
||
|
|
-#include <sys/ucontext.h>
|
||
|
|
-#if HAVE_LIBUNWIND_H
|
||
|
|
-#include <libunwind.h>
|
||
|
|
-#endif
|
||
|
|
-
|
||
|
|
-#include "run_benchmark.h"
|
||
|
|
-
|
||
|
|
-extern "C" void getcontext_light(ucontext_t *ctx);
|
||
|
|
-
|
||
|
|
-#define MAX_FRAMES 1024
|
||
|
|
-static void *frames[MAX_FRAMES];
|
||
|
|
-
|
||
|
|
-enum measure_mode {
|
||
|
|
- MODE_NOOP,
|
||
|
|
- MODE_WITH_CONTEXT,
|
||
|
|
- MODE_WITHOUT_CONTEXT
|
||
|
|
-};
|
||
|
|
-
|
||
|
|
-static int ATTRIBUTE_NOINLINE measure_unwind(int maxlevel, int mode) {
|
||
|
|
- int n;
|
||
|
|
-
|
||
|
|
- if (mode == MODE_NOOP)
|
||
|
|
- return 0;
|
||
|
|
-
|
||
|
|
- if (mode == MODE_WITH_CONTEXT) {
|
||
|
|
- ucontext_t uc;
|
||
|
|
- getcontext_light(&uc);
|
||
|
|
- n = GetStackTraceWithContext(frames, MAX_FRAMES, 0, &uc);
|
||
|
|
- } else {
|
||
|
|
- n = GetStackTrace(frames, MAX_FRAMES, 0);
|
||
|
|
- }
|
||
|
|
- if (n < maxlevel) {
|
||
|
|
- fprintf(stderr, "Expected at least %d frames, got %d\n", maxlevel, n);
|
||
|
|
- abort();
|
||
|
|
- }
|
||
|
|
- return 0;
|
||
|
|
-}
|
||
|
|
-
|
||
|
|
-static int ATTRIBUTE_NOINLINE frame_forcer(int rv) {
|
||
|
|
- return rv;
|
||
|
|
-}
|
||
|
|
-
|
||
|
|
-static int ATTRIBUTE_NOINLINE f1(int level, int maxlevel, int mode) {
|
||
|
|
- if (level == maxlevel)
|
||
|
|
- return frame_forcer(measure_unwind(maxlevel, mode));
|
||
|
|
- return frame_forcer(f1(level + 1, maxlevel, mode));
|
||
|
|
-}
|
||
|
|
-
|
||
|
|
-static void bench_unwind_no_op(long iterations, uintptr_t param) {
|
||
|
|
- do {
|
||
|
|
- f1(0, param, MODE_NOOP);
|
||
|
|
- iterations -= param;
|
||
|
|
- } while (iterations > 0);
|
||
|
|
-}
|
||
|
|
-
|
||
|
|
-static void bench_unwind_context(long iterations, uintptr_t param) {
|
||
|
|
- do {
|
||
|
|
- f1(0, param, MODE_WITH_CONTEXT);
|
||
|
|
- iterations -= param;
|
||
|
|
- } while (iterations > 0);
|
||
|
|
-}
|
||
|
|
-
|
||
|
|
-static void bench_unwind_no_context(long iterations, uintptr_t param) {
|
||
|
|
- do {
|
||
|
|
- f1(0, param, MODE_WITHOUT_CONTEXT);
|
||
|
|
- iterations -= param;
|
||
|
|
- } while (iterations > 0);
|
||
|
|
-}
|
||
|
|
-
|
||
|
|
-int main(void) {
|
||
|
|
- report_benchmark("unwind_no_op", bench_unwind_no_op, 100);
|
||
|
|
- report_benchmark("unwind_context", bench_unwind_context, 100);
|
||
|
|
- report_benchmark("unwind_no_context", bench_unwind_no_context, 100);
|
||
|
|
-
|
||
|
|
-//// TODO: somehow this fails at linking step. Figure out why this is missing
|
||
|
|
-// #if HAVE_LIBUNWIND_H
|
||
|
|
-// unw_set_caching_policy(unw_local_addr_space, UNW_CACHE_PER_THREAD);
|
||
|
|
-// #endif
|
||
|
|
- return 0;
|
||
|
|
-}
|
||
|
|
--
|
||
|
|
1.8.3.1
|
||
|
|
|