aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxenoxeno <xeno@ydb.tech>2023-02-09 15:48:54 +0300
committerxenoxeno <xeno@ydb.tech>2023-02-09 15:48:54 +0300
commit6fd9f51d875c14bcdb0c1ce226aba07a22e40123 (patch)
tree53b18a6dfc9fab9d9ef2fefbb0d00e1b43298932
parentcff1891d7ee81680cfe4c46035c8e7daca1aa3dd (diff)
downloadydb-6fd9f51d875c14bcdb0c1ce226aba07a22e40123.tar.gz
attempt to stabilize perf test in different environments
-rw-r--r--library/cpp/actors/helpers/selfping_actor.cpp94
-rw-r--r--library/cpp/actors/helpers/selfping_actor.h1
-rw-r--r--ydb/core/mind/hive/hive_impl_ut.cpp30
-rw-r--r--ydb/core/mind/hive/ut/CMakeLists.darwin.txt1
-rw-r--r--ydb/core/mind/hive/ut/CMakeLists.linux-aarch64.txt1
-rw-r--r--ydb/core/mind/hive/ut/CMakeLists.linux.txt1
6 files changed, 73 insertions, 55 deletions
diff --git a/library/cpp/actors/helpers/selfping_actor.cpp b/library/cpp/actors/helpers/selfping_actor.cpp
index dc383f8c4ca..dcad5931c97 100644
--- a/library/cpp/actors/helpers/selfping_actor.cpp
+++ b/library/cpp/actors/helpers/selfping_actor.cpp
@@ -8,6 +8,53 @@
namespace NActors {
+ui64 MeasureTaskDurationNs() {
+ // Prepare worm test data
+ // 11 * 11 * 3 * 8 = 2904 bytes, fits in L1 cache
+ constexpr ui64 Size = 11;
+ // Align the data to reduce random alignment effects
+ alignas(64) TStackVec<ui64, Size * Size * 3> data;
+ ui64 s = 0;
+ NHPTimer::STime beginTime;
+ NHPTimer::STime endTime;
+ // Prepare the data
+ data.resize(Size * Size * 3);
+ for (ui64 matrixIdx = 0; matrixIdx < 3; ++matrixIdx) {
+ for (ui64 y = 0; y < Size; ++y) {
+ for (ui64 x = 0; x < Size; ++x) {
+ data[matrixIdx * (Size * Size) + y * Size + x] = y * Size + x;
+ }
+ }
+ }
+ // Warm-up the cache
+ NHPTimer::GetTime(&beginTime);
+ for (ui64 idx = 0; idx < data.size(); ++idx) {
+ s += data[idx];
+ }
+ NHPTimer::GetTime(&endTime);
+ s += (ui64)(1000000.0 * NHPTimer::GetSeconds(endTime - beginTime));
+
+ // Measure the CPU performance
+ // C = A * B with injected dependency to s
+ NHPTimer::GetTime(&beginTime);
+ for (ui64 y = 0; y < Size; ++y) {
+ for (ui64 x = 0; x < Size; ++x) {
+ for (ui64 i = 0; i < Size; ++i) {
+ s += data[y * Size + i] * data[Size * Size + i * Size + x];
+ }
+ data[2 * Size * Size + y * Size + x] = s;
+ s = 0;
+ }
+ }
+ for (ui64 idx = 0; idx < data.size(); ++idx) {
+ s += data[idx];
+ }
+ NHPTimer::GetTime(&endTime);
+ // Prepare the result
+ double d = 1000000000.0 * (NHPTimer::GetSeconds(endTime - beginTime) + 0.000000001 * (s & 1));
+ return (ui64)d;
+}
+
namespace {
struct TEvPing: public TEventLocal<TEvPing, TEvents::THelloWorld::Ping> {
@@ -110,53 +157,6 @@ public:
}
}
- ui64 MeasureTaskDurationNs() {
- // Prepare worm test data
- // 11 * 11 * 3 * 8 = 2904 bytes, fits in L1 cache
- constexpr ui64 Size = 11;
- // Align the data to reduce random alignment effects
- alignas(64) TStackVec<ui64, Size * Size * 3> data;
- ui64 s = 0;
- NHPTimer::STime beginTime;
- NHPTimer::STime endTime;
- // Prepare the data
- data.resize(Size * Size * 3);
- for (ui64 matrixIdx = 0; matrixIdx < 3; ++matrixIdx) {
- for (ui64 y = 0; y < Size; ++y) {
- for (ui64 x = 0; x < Size; ++x) {
- data[matrixIdx * (Size * Size) + y * Size + x] = y * Size + x;
- }
- }
- }
- // Warm-up the cache
- NHPTimer::GetTime(&beginTime);
- for (ui64 idx = 0; idx < data.size(); ++idx) {
- s += data[idx];
- }
- NHPTimer::GetTime(&endTime);
- s += (ui64)(1000000.0 * NHPTimer::GetSeconds(endTime - beginTime));
-
- // Measure the CPU performance
- // C = A * B with injected dependency to s
- NHPTimer::GetTime(&beginTime);
- for (ui64 y = 0; y < Size; ++y) {
- for (ui64 x = 0; x < Size; ++x) {
- for (ui64 i = 0; i < Size; ++i) {
- s += data[y * Size + i] * data[Size * Size + i * Size + x];
- }
- data[2 * Size * Size + y * Size + x] = s;
- s = 0;
- }
- }
- for (ui64 idx = 0; idx < data.size(); ++idx) {
- s += data[idx];
- }
- NHPTimer::GetTime(&endTime);
- // Prepare the result
- double d = 1000000000.0 * (NHPTimer::GetSeconds(endTime - beginTime) + 0.000000001 * (s & 1));
- return (ui64)d;
- }
-
void HandlePing(TEvPing::TPtr &ev, const TActorContext &ctx)
{
const auto now = ctx.Now();
diff --git a/library/cpp/actors/helpers/selfping_actor.h b/library/cpp/actors/helpers/selfping_actor.h
index a976a4f4259..a06bfe8292c 100644
--- a/library/cpp/actors/helpers/selfping_actor.h
+++ b/library/cpp/actors/helpers/selfping_actor.h
@@ -5,6 +5,7 @@
namespace NActors {
+ui64 MeasureTaskDurationNs();
NActors::IActor* CreateSelfPingActor(
TDuration sendInterval,
const NMonitoring::TDynamicCounters::TCounterPtr& maxPingCounter,
diff --git a/ydb/core/mind/hive/hive_impl_ut.cpp b/ydb/core/mind/hive/hive_impl_ut.cpp
index a664f4bdcee..c9b3d0b18fc 100644
--- a/ydb/core/mind/hive/hive_impl_ut.cpp
+++ b/ydb/core/mind/hive/hive_impl_ut.cpp
@@ -1,5 +1,6 @@
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/testing/unittest/tests_data.h>
+#include <library/cpp/actors/helpers/selfping_actor.h>
#include <util/stream/null.h>
#include <util/datetime/cputimer.h>
#include "hive_impl.h"
@@ -24,6 +25,19 @@
using namespace NKikimr;
using namespace NHive;
+using duration_nano_t = std::chrono::duration<ui64, std::nano>;
+using duration_t = std::chrono::duration<double>;
+
+duration_t GetBasePerformance() {
+ duration_nano_t accm;
+ for (int i = 0; i < 1000000; ++i) {
+ accm += duration_nano_t(NActors::MeasureTaskDurationNs());
+ }
+ return std::chrono::duration_cast<duration_t>(accm);
+}
+
+static double BASE_PERF = GetBasePerformance().count();
+
Y_UNIT_TEST_SUITE(THiveImplTest) {
Y_UNIT_TEST(BootQueueSpeed) {
TBootQueue bootQueue;
@@ -45,9 +59,9 @@ Y_UNIT_TEST_SUITE(THiveImplTest) {
Ctest << "Create = " << passed << Endl;
#ifndef SANITIZER_TYPE
#ifndef NDEBUG
- UNIT_ASSERT(passed < 3);
+ UNIT_ASSERT(passed < 3 * BASE_PERF);
#else
- UNIT_ASSERT(passed < 1);
+ UNIT_ASSERT(passed < 1 * BASE_PERF);
#endif
#endif
timer.Reset();
@@ -68,9 +82,9 @@ Y_UNIT_TEST_SUITE(THiveImplTest) {
Ctest << "Process = " << passed << Endl;
#ifndef SANITIZER_TYPE
#ifndef NDEBUG
- UNIT_ASSERT(passed < 10);
+ UNIT_ASSERT(passed < 10 * BASE_PERF);
#else
- UNIT_ASSERT(passed < 1);
+ UNIT_ASSERT(passed < 1 * BASE_PERF);
#endif
#endif
@@ -82,9 +96,9 @@ Y_UNIT_TEST_SUITE(THiveImplTest) {
Ctest << "Move = " << passed << Endl;
#ifndef SANITIZER_TYPE
#ifndef NDEBUG
- UNIT_ASSERT(passed < 2);
+ UNIT_ASSERT(passed < 2 * BASE_PERF);
#else
- UNIT_ASSERT(passed < 0.1);
+ UNIT_ASSERT(passed < 0.1 * BASE_PERF);
#endif
#endif
}
@@ -111,9 +125,9 @@ Y_UNIT_TEST_SUITE(THiveImplTest) {
Ctest << "Time=" << passed << Endl;
#ifndef SANITIZER_TYPE
#ifndef NDEBUG
- UNIT_ASSERT(passed < 1);
+ UNIT_ASSERT(passed < 1 * BASE_PERF);
#else
- UNIT_ASSERT(passed < 0.4);
+ UNIT_ASSERT(passed < 0.7 * BASE_PERF);
#endif
#endif
std::vector<double> buckets(NUM_BUCKETS, 0);
diff --git a/ydb/core/mind/hive/ut/CMakeLists.darwin.txt b/ydb/core/mind/hive/ut/CMakeLists.darwin.txt
index 4e77d9ab690..f282d81c912 100644
--- a/ydb/core/mind/hive/ut/CMakeLists.darwin.txt
+++ b/ydb/core/mind/hive/ut/CMakeLists.darwin.txt
@@ -22,6 +22,7 @@ target_link_libraries(ydb-core-mind-hive-ut PUBLIC
core-mind-hive
library-cpp-getopt
library-cpp-svnversion
+ cpp-actors-helpers
ydb-core-base
ydb-core-mind
core-testlib-default
diff --git a/ydb/core/mind/hive/ut/CMakeLists.linux-aarch64.txt b/ydb/core/mind/hive/ut/CMakeLists.linux-aarch64.txt
index 1b0d3b4e30b..13bb30e20f8 100644
--- a/ydb/core/mind/hive/ut/CMakeLists.linux-aarch64.txt
+++ b/ydb/core/mind/hive/ut/CMakeLists.linux-aarch64.txt
@@ -23,6 +23,7 @@ target_link_libraries(ydb-core-mind-hive-ut PUBLIC
core-mind-hive
library-cpp-getopt
library-cpp-svnversion
+ cpp-actors-helpers
ydb-core-base
ydb-core-mind
core-testlib-default
diff --git a/ydb/core/mind/hive/ut/CMakeLists.linux.txt b/ydb/core/mind/hive/ut/CMakeLists.linux.txt
index 787a11a3fcf..6e1fe78e22c 100644
--- a/ydb/core/mind/hive/ut/CMakeLists.linux.txt
+++ b/ydb/core/mind/hive/ut/CMakeLists.linux.txt
@@ -25,6 +25,7 @@ target_link_libraries(ydb-core-mind-hive-ut PUBLIC
core-mind-hive
library-cpp-getopt
library-cpp-svnversion
+ cpp-actors-helpers
ydb-core-base
ydb-core-mind
core-testlib-default