aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/benchmark
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/system/benchmark
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/system/benchmark')
-rw-r--r--util/system/benchmark/cpu_id/main.cpp51
-rw-r--r--util/system/benchmark/cpu_id/metrics/main.py5
-rw-r--r--util/system/benchmark/cpu_id/metrics/ya.make21
-rw-r--r--util/system/benchmark/cpu_id/ya.make13
-rw-r--r--util/system/benchmark/create_destroy_thread/main.cpp26
-rw-r--r--util/system/benchmark/create_destroy_thread/metrics/main.py7
-rw-r--r--util/system/benchmark/create_destroy_thread/metrics/ya.make21
-rw-r--r--util/system/benchmark/create_destroy_thread/ya.make9
-rw-r--r--util/system/benchmark/rdtsc/main.cpp61
-rw-r--r--util/system/benchmark/rdtsc/ya.make10
-rw-r--r--util/system/benchmark/ya.make18
11 files changed, 242 insertions, 0 deletions
diff --git a/util/system/benchmark/cpu_id/main.cpp b/util/system/benchmark/cpu_id/main.cpp
new file mode 100644
index 0000000000..8efe539983
--- /dev/null
+++ b/util/system/benchmark/cpu_id/main.cpp
@@ -0,0 +1,51 @@
+#include <library/cpp/testing/benchmark/bench.h>
+
+#include <util/system/cpu_id.h>
+
+#include <util/generic/xrange.h>
+
+#define DEFINE_BENCHMARK_PAIR(name) \
+ Y_CPU_BENCHMARK(Have##name, iface) { \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ Y_DO_NOT_OPTIMIZE_AWAY(NX86::Have##name()); \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(CachedHave##name, iface) { \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ Y_DO_NOT_OPTIMIZE_AWAY(NX86::CachedHave##name()); \
+ } \
+ }
+
+DEFINE_BENCHMARK_PAIR(SSE)
+DEFINE_BENCHMARK_PAIR(SSE2)
+DEFINE_BENCHMARK_PAIR(SSE3)
+DEFINE_BENCHMARK_PAIR(SSSE3)
+DEFINE_BENCHMARK_PAIR(SSE41)
+DEFINE_BENCHMARK_PAIR(SSE42)
+DEFINE_BENCHMARK_PAIR(POPCNT)
+DEFINE_BENCHMARK_PAIR(BMI1)
+DEFINE_BENCHMARK_PAIR(AES)
+DEFINE_BENCHMARK_PAIR(AVX)
+DEFINE_BENCHMARK_PAIR(AVX2)
+DEFINE_BENCHMARK_PAIR(AVX512F)
+DEFINE_BENCHMARK_PAIR(AVX512DQ)
+DEFINE_BENCHMARK_PAIR(AVX512IFMA)
+DEFINE_BENCHMARK_PAIR(AVX512PF)
+DEFINE_BENCHMARK_PAIR(AVX512ER)
+DEFINE_BENCHMARK_PAIR(AVX512CD)
+DEFINE_BENCHMARK_PAIR(AVX512BW)
+DEFINE_BENCHMARK_PAIR(AVX512VL)
+DEFINE_BENCHMARK_PAIR(AVX512VBMI)
+DEFINE_BENCHMARK_PAIR(PREFETCHWT1)
+DEFINE_BENCHMARK_PAIR(SHA)
+DEFINE_BENCHMARK_PAIR(ADX)
+DEFINE_BENCHMARK_PAIR(RDRAND)
+DEFINE_BENCHMARK_PAIR(RDSEED)
+DEFINE_BENCHMARK_PAIR(PCOMMIT)
+DEFINE_BENCHMARK_PAIR(CLFLUSHOPT)
+DEFINE_BENCHMARK_PAIR(CLWB)
+
+#undef DEFINE_BENCHMARK_PAIR
diff --git a/util/system/benchmark/cpu_id/metrics/main.py b/util/system/benchmark/cpu_id/metrics/main.py
new file mode 100644
index 0000000000..d9a86e825c
--- /dev/null
+++ b/util/system/benchmark/cpu_id/metrics/main.py
@@ -0,0 +1,5 @@
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
+ metrics.set_benchmark(yc.execute_benchmark('util/system/benchmark/cpu_id/cpu_id', threads=8))
diff --git a/util/system/benchmark/cpu_id/metrics/ya.make b/util/system/benchmark/cpu_id/metrics/ya.make
new file mode 100644
index 0000000000..8c55def99b
--- /dev/null
+++ b/util/system/benchmark/cpu_id/metrics/ya.make
@@ -0,0 +1,21 @@
+OWNER(
+ yazevnul
+ g:util
+)
+SUBSCRIBER(g:util-subscribers)
+
+PY2TEST()
+
+SIZE(LARGE)
+
+TAG(
+ ya:force_sandbox
+ sb:intel_e5_2660v1
+ ya:fat
+)
+
+TEST_SRCS(main.py)
+
+DEPENDS(util/system/benchmark/cpu_id)
+
+END()
diff --git a/util/system/benchmark/cpu_id/ya.make b/util/system/benchmark/cpu_id/ya.make
new file mode 100644
index 0000000000..976977014f
--- /dev/null
+++ b/util/system/benchmark/cpu_id/ya.make
@@ -0,0 +1,13 @@
+OWNER(
+ yazevnul
+ g:util
+)
+SUBSCRIBER(g:util-subscribers)
+
+Y_BENCHMARK()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/system/benchmark/create_destroy_thread/main.cpp b/util/system/benchmark/create_destroy_thread/main.cpp
new file mode 100644
index 0000000000..0ca2a9d96f
--- /dev/null
+++ b/util/system/benchmark/create_destroy_thread/main.cpp
@@ -0,0 +1,26 @@
+#include <library/cpp/testing/benchmark/bench.h>
+
+#include <util/system/thread.h>
+
+static void* DoNothing(void*) noexcept {
+ return nullptr;
+}
+
+Y_CPU_BENCHMARK(CreateDestroyThread, iface) {
+ for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) {
+ NBench::Clobber();
+ TThread t(&DoNothing, nullptr);
+ Y_DO_NOT_OPTIMIZE_AWAY(t);
+ NBench::Clobber();
+ }
+}
+
+Y_CPU_BENCHMARK(CreateRunDestroyThread, iface) {
+ for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) {
+ NBench::Clobber();
+ TThread t(&DoNothing, nullptr);
+ t.Start();
+ NBench::Escape(t.Join());
+ NBench::Clobber();
+ }
+}
diff --git a/util/system/benchmark/create_destroy_thread/metrics/main.py b/util/system/benchmark/create_destroy_thread/metrics/main.py
new file mode 100644
index 0000000000..45564cda7f
--- /dev/null
+++ b/util/system/benchmark/create_destroy_thread/metrics/main.py
@@ -0,0 +1,7 @@
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
+ metrics.set_benchmark(
+ yc.execute_benchmark('util/system/benchmark/create_destroy_thread/create_destroy_thread', threads=8)
+ )
diff --git a/util/system/benchmark/create_destroy_thread/metrics/ya.make b/util/system/benchmark/create_destroy_thread/metrics/ya.make
new file mode 100644
index 0000000000..d526487e1a
--- /dev/null
+++ b/util/system/benchmark/create_destroy_thread/metrics/ya.make
@@ -0,0 +1,21 @@
+OWNER(
+ yazevnul
+ g:util
+)
+SUBSCRIBER(g:util-subscribers)
+
+PY2TEST()
+
+SIZE(LARGE)
+
+TAG(
+ ya:force_sandbox
+ sb:intel_e5_2660v1
+ ya:fat
+)
+
+TEST_SRCS(main.py)
+
+DEPENDS(util/system/benchmark/create_destroy_thread)
+
+END()
diff --git a/util/system/benchmark/create_destroy_thread/ya.make b/util/system/benchmark/create_destroy_thread/ya.make
new file mode 100644
index 0000000000..03eb0ec8e0
--- /dev/null
+++ b/util/system/benchmark/create_destroy_thread/ya.make
@@ -0,0 +1,9 @@
+OWNER(yazevnul)
+
+Y_BENCHMARK()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/system/benchmark/rdtsc/main.cpp b/util/system/benchmark/rdtsc/main.cpp
new file mode 100644
index 0000000000..8189d10f06
--- /dev/null
+++ b/util/system/benchmark/rdtsc/main.cpp
@@ -0,0 +1,61 @@
+#include <library/cpp/testing/benchmark/bench.h>
+
+#include <util/system/datetime.h>
+#include <util/generic/xrange.h>
+
+Y_FORCE_INLINE ui64 GetCycleCountLinux() {
+ unsigned hi, lo;
+ __asm__ __volatile__("lfence\n"
+ "rdtsc"
+ : "=a"(lo), "=d"(hi));
+ return ((unsigned long long)lo) | (((unsigned long long)hi) << 32);
+}
+
+Y_FORCE_INLINE ui64 GetCycleCountAgri1() {
+ unsigned hi, lo;
+
+ __asm__ __volatile__("rdtscp\n"
+ : "=a"(lo), "=d"(hi)::"%rbx", "%rcx");
+
+ return ((unsigned long long)lo) | (((unsigned long long)hi) << 32);
+}
+
+Y_FORCE_INLINE ui64 GetCycleCountAgri2() {
+ unsigned hi, lo;
+ __asm__ __volatile__("rdtscp\n"
+ : "=a"(lo), "=d"(hi)::"%rbx", "%rcx");
+ /* call cpuid to prevent out of order execution */
+ __asm__ __volatile__("mov $0, %%eax\n"
+ "cpuid\n" ::
+ : "%eax");
+
+ return ((unsigned long long)lo) | (((unsigned long long)hi) << 32);
+}
+
+Y_CPU_BENCHMARK(RdtscUtil, iface) {
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Y_DO_NOT_OPTIMIZE_AWAY(GetCycleCount());
+ }
+}
+
+Y_CPU_BENCHMARK(RdtscLinux, iface) {
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Y_DO_NOT_OPTIMIZE_AWAY(GetCycleCountLinux());
+ }
+}
+
+Y_CPU_BENCHMARK(RdtscAgri1, iface) {
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Y_DO_NOT_OPTIMIZE_AWAY(GetCycleCountAgri1());
+ }
+}
+
+Y_CPU_BENCHMARK(RdtscAgri2, iface) {
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Y_DO_NOT_OPTIMIZE_AWAY(GetCycleCountAgri2());
+ }
+}
diff --git a/util/system/benchmark/rdtsc/ya.make b/util/system/benchmark/rdtsc/ya.make
new file mode 100644
index 0000000000..7059abc3a4
--- /dev/null
+++ b/util/system/benchmark/rdtsc/ya.make
@@ -0,0 +1,10 @@
+Y_BENCHMARK()
+
+OWNER(g:util)
+SUBSCRIBER(g:util-subscribers)
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/system/benchmark/ya.make b/util/system/benchmark/ya.make
new file mode 100644
index 0000000000..12fa9af9d6
--- /dev/null
+++ b/util/system/benchmark/ya.make
@@ -0,0 +1,18 @@
+OWNER(
+ yazevnul
+ g:util
+)
+SUBSCRIBER(g:util-subscribers)
+
+RECURSE(
+ cpu_id
+ cpu_id/metrics
+ create_destroy_thread
+ create_destroy_thread/metrics
+)
+
+IF (NOT OS_WINDOWS)
+ RECURSE(
+ rdtsc
+ )
+ENDIF()