diff options
author | xenoxeno <xeno@ydb.tech> | 2023-02-09 15:48:54 +0300 |
---|---|---|
committer | xenoxeno <xeno@ydb.tech> | 2023-02-09 15:48:54 +0300 |
commit | 6fd9f51d875c14bcdb0c1ce226aba07a22e40123 (patch) | |
tree | 53b18a6dfc9fab9d9ef2fefbb0d00e1b43298932 /library/cpp | |
parent | cff1891d7ee81680cfe4c46035c8e7daca1aa3dd (diff) | |
download | ydb-6fd9f51d875c14bcdb0c1ce226aba07a22e40123.tar.gz |
attempt to stabilize perf test in different environments
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/actors/helpers/selfping_actor.cpp | 94 | ||||
-rw-r--r-- | library/cpp/actors/helpers/selfping_actor.h | 1 |
2 files changed, 48 insertions, 47 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, |