aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkabeton <kabeton@yandex-team.ru>2022-02-10 16:50:45 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:45 +0300
commit65e778b72f0bd0586ac2619c55df6e647696a2ea (patch)
tree84e540f17d3dc6ae95ed70186cac5df89db9a874
parent8af5b431af95a8b49c98bb8cae35a9f9c238df69 (diff)
downloadydb-65e778b72f0bd0586ac2619c55df6e647696a2ea.tar.gz
Restoring authorship annotation for <kabeton@yandex-team.ru>. Commit 1 of 2.
-rw-r--r--library/cpp/actors/core/mailbox.cpp44
-rw-r--r--library/cpp/actors/core/mailbox.h230
-rw-r--r--ydb/core/blobstorage/ut_blobstorage/counting_events.cpp314
-rw-r--r--ydb/core/blobstorage/ut_blobstorage/patch.cpp6
-rw-r--r--ydb/core/util/time_series_vec.h24
-rw-r--r--ydb/core/util/time_series_vec_ut.cpp186
6 files changed, 402 insertions, 402 deletions
diff --git a/library/cpp/actors/core/mailbox.cpp b/library/cpp/actors/core/mailbox.cpp
index d84b4f9e46..25242b1438 100644
--- a/library/cpp/actors/core/mailbox.cpp
+++ b/library/cpp/actors/core/mailbox.cpp
@@ -352,8 +352,8 @@ namespace NActors {
, ActorPack(TMailboxActorPack::Simple)
, Knobs(0)
{
- ActorsInfo.Simple.ActorId = 0;
- ActorsInfo.Simple.Actor = nullptr;
+ ActorsInfo.Simple.ActorId = 0;
+ ActorsInfo.Simple.Actor = nullptr;
}
TMailboxHeader::~TMailboxHeader() {
@@ -363,33 +363,33 @@ namespace NActors {
bool TMailboxHeader::CleanupActors() {
bool done = true;
switch (ActorPack) {
- case TMailboxActorPack::Simple: {
- if (ActorsInfo.Simple.ActorId != 0) {
- delete ActorsInfo.Simple.Actor;
+ case TMailboxActorPack::Simple: {
+ if (ActorsInfo.Simple.ActorId != 0) {
+ delete ActorsInfo.Simple.Actor;
done = false;
}
break;
- }
+ }
case TMailboxActorPack::Map: {
- for (auto& [actorId, actor] : *ActorsInfo.Map.ActorsMap) {
- delete actor;
- }
- delete ActorsInfo.Map.ActorsMap;
- done = false;
- break;
- }
- case TMailboxActorPack::Array: {
- for (ui64 i = 0; i < ActorsInfo.Array.ActorsCount; ++i) {
- delete ActorsInfo.Array.ActorsArray->Actors[i].Actor;
- }
- delete ActorsInfo.Array.ActorsArray;
+ for (auto& [actorId, actor] : *ActorsInfo.Map.ActorsMap) {
+ delete actor;
+ }
+ delete ActorsInfo.Map.ActorsMap;
done = false;
- break;
- }
+ break;
+ }
+ case TMailboxActorPack::Array: {
+ for (ui64 i = 0; i < ActorsInfo.Array.ActorsCount; ++i) {
+ delete ActorsInfo.Array.ActorsArray->Actors[i].Actor;
+ }
+ delete ActorsInfo.Array.ActorsArray;
+ done = false;
+ break;
+ }
}
ActorPack = TMailboxActorPack::Simple;
- ActorsInfo.Simple.ActorId = 0;
- ActorsInfo.Simple.Actor = nullptr;
+ ActorsInfo.Simple.ActorId = 0;
+ ActorsInfo.Simple.Actor = nullptr;
return done;
}
diff --git a/library/cpp/actors/core/mailbox.h b/library/cpp/actors/core/mailbox.h
index 0bd9c4d314..180bf985ff 100644
--- a/library/cpp/actors/core/mailbox.h
+++ b/library/cpp/actors/core/mailbox.h
@@ -8,7 +8,7 @@
#include <library/cpp/actors/util/unordered_cache.h>
#include <library/cpp/threading/queue/mpsc_htswap.h>
#include <library/cpp/threading/queue/mpsc_read_as_filled.h>
-#include <util/generic/hash.h>
+#include <util/generic/hash.h>
#include <util/system/hp_timer.h>
#include <util/generic/ptr.h>
// TODO: clean all broken arcadia atomic stuff and replace with intrinsics
@@ -17,8 +17,8 @@ namespace NActors {
class IActor;
class IExecutorPool;
- const ui64 ARRAY_CAPACITY = 8;
-
+ const ui64 ARRAY_CAPACITY = 8;
+
// structure of hint:
// 1 bit: is service or direct hint
// 2 bits: pool index
@@ -29,12 +29,12 @@ namespace NActors {
struct TMailboxActorPack {
enum EType {
Simple = 0,
- Array = 1,
- Map = 2
+ Array = 1,
+ Map = 2
};
};
- using TActorMap = THashMap<ui64, IActor*>;
+ using TActorMap = THashMap<ui64, IActor*>;
struct TExecutionState {
enum EState {
@@ -59,26 +59,26 @@ namespace NActors {
ui32 ActorPack : 2;
ui32 Knobs : 22;
- struct TActorPair {
- IActor *Actor;
- ui64 ActorId;
- };
-
- struct alignas(64) TActorArray {
- TActorPair Actors[ARRAY_CAPACITY];
- };
-
- union TActorsInfo {
- TActorPair Simple;
- struct {
- TActorArray* ActorsArray;
- ui64 ActorsCount;
- } Array;
- struct {
- TActorMap* ActorsMap;
- } Map;
- } ActorsInfo;
-
+ struct TActorPair {
+ IActor *Actor;
+ ui64 ActorId;
+ };
+
+ struct alignas(64) TActorArray {
+ TActorPair Actors[ARRAY_CAPACITY];
+ };
+
+ union TActorsInfo {
+ TActorPair Simple;
+ struct {
+ TActorArray* ActorsArray;
+ ui64 ActorsCount;
+ } Array;
+ struct {
+ TActorMap* ActorsMap;
+ } Map;
+ } ActorsInfo;
+
TMailboxHeader(TMailboxType::EType type);
~TMailboxHeader();
@@ -96,7 +96,7 @@ namespace NActors {
bool UnlockAsFree(bool wouldReschedule); // preceed with releasing lock, but mark as free one
bool IsEmpty() const noexcept {
- return (ActorPack == TMailboxActorPack::Simple && ActorsInfo.Simple.ActorId == 0);
+ return (ActorPack == TMailboxActorPack::Simple && ActorsInfo.Simple.ActorId == 0);
}
template<typename T>
@@ -125,25 +125,25 @@ namespace NActors {
IActor* FindActor(ui64 localActorId) noexcept {
switch (ActorPack) {
- case TMailboxActorPack::Simple: {
- if (ActorsInfo.Simple.ActorId == localActorId)
- return ActorsInfo.Simple.Actor;
+ case TMailboxActorPack::Simple: {
+ if (ActorsInfo.Simple.ActorId == localActorId)
+ return ActorsInfo.Simple.Actor;
break;
- }
+ }
case TMailboxActorPack::Map: {
- TActorMap::iterator it = ActorsInfo.Map.ActorsMap->find(localActorId);
- if (it != ActorsInfo.Map.ActorsMap->end())
+ TActorMap::iterator it = ActorsInfo.Map.ActorsMap->find(localActorId);
+ if (it != ActorsInfo.Map.ActorsMap->end())
return it->second;
- break;
- }
- case TMailboxActorPack::Array: {
- for (ui64 i = 0; i < ActorsInfo.Array.ActorsCount; ++i) {
- if (ActorsInfo.Array.ActorsArray->Actors[i].ActorId == localActorId) {
- return ActorsInfo.Array.ActorsArray->Actors[i].Actor;
- }
- }
- break;
- }
+ break;
+ }
+ case TMailboxActorPack::Array: {
+ for (ui64 i = 0; i < ActorsInfo.Array.ActorsCount; ++i) {
+ if (ActorsInfo.Array.ActorsArray->Actors[i].ActorId == localActorId) {
+ return ActorsInfo.Array.ActorsArray->Actors[i].Actor;
+ }
+ }
+ break;
+ }
default:
Y_FAIL();
}
@@ -152,41 +152,41 @@ namespace NActors {
void AttachActor(ui64 localActorId, IActor* actor) noexcept {
switch (ActorPack) {
- case TMailboxActorPack::Simple: {
- if (ActorsInfo.Simple.ActorId == 0) {
- ActorsInfo.Simple.ActorId = localActorId;
- ActorsInfo.Simple.Actor = actor;
+ case TMailboxActorPack::Simple: {
+ if (ActorsInfo.Simple.ActorId == 0) {
+ ActorsInfo.Simple.ActorId = localActorId;
+ ActorsInfo.Simple.Actor = actor;
return;
} else {
- auto ar = new TActorArray;
- ar->Actors[0] = ActorsInfo.Simple;
- ar->Actors[1] = TActorPair{actor, localActorId};
- ActorsInfo.Array.ActorsCount = 2;
- ActorPack = TMailboxActorPack::Array;
- ActorsInfo.Array.ActorsArray = ar;
- }
- break;
- }
- case TMailboxActorPack::Map: {
- ActorsInfo.Map.ActorsMap->insert(TActorMap::value_type(localActorId, actor));
- break;
- }
- case TMailboxActorPack::Array: {
- if (ActorsInfo.Array.ActorsCount == ARRAY_CAPACITY) {
- TActorMap* mp = new TActorMap();
- for (ui64 i = 0; i < ARRAY_CAPACITY; ++i) {
- mp->emplace(ActorsInfo.Array.ActorsArray->Actors[i].ActorId, ActorsInfo.Array.ActorsArray->Actors[i].Actor);
- }
- mp->emplace(localActorId, actor);
+ auto ar = new TActorArray;
+ ar->Actors[0] = ActorsInfo.Simple;
+ ar->Actors[1] = TActorPair{actor, localActorId};
+ ActorsInfo.Array.ActorsCount = 2;
+ ActorPack = TMailboxActorPack::Array;
+ ActorsInfo.Array.ActorsArray = ar;
+ }
+ break;
+ }
+ case TMailboxActorPack::Map: {
+ ActorsInfo.Map.ActorsMap->insert(TActorMap::value_type(localActorId, actor));
+ break;
+ }
+ case TMailboxActorPack::Array: {
+ if (ActorsInfo.Array.ActorsCount == ARRAY_CAPACITY) {
+ TActorMap* mp = new TActorMap();
+ for (ui64 i = 0; i < ARRAY_CAPACITY; ++i) {
+ mp->emplace(ActorsInfo.Array.ActorsArray->Actors[i].ActorId, ActorsInfo.Array.ActorsArray->Actors[i].Actor);
+ }
+ mp->emplace(localActorId, actor);
ActorPack = TMailboxActorPack::Map;
- ActorsInfo.Array.ActorsCount = 0;
- delete ActorsInfo.Array.ActorsArray;
- ActorsInfo.Map.ActorsMap = mp;
- } else {
- ActorsInfo.Array.ActorsArray->Actors[ActorsInfo.Array.ActorsCount++] = TActorPair{actor, localActorId};
+ ActorsInfo.Array.ActorsCount = 0;
+ delete ActorsInfo.Array.ActorsArray;
+ ActorsInfo.Map.ActorsMap = mp;
+ } else {
+ ActorsInfo.Array.ActorsArray->Actors[ActorsInfo.Array.ActorsCount++] = TActorPair{actor, localActorId};
}
break;
- }
+ }
default:
Y_FAIL();
}
@@ -198,55 +198,55 @@ namespace NActors {
IActor* actorToDestruct = nullptr;
switch (ActorPack) {
- case TMailboxActorPack::Simple: {
- Y_VERIFY(ActorsInfo.Simple.ActorId == localActorId);
- actorToDestruct = ActorsInfo.Simple.Actor;
+ case TMailboxActorPack::Simple: {
+ Y_VERIFY(ActorsInfo.Simple.ActorId == localActorId);
+ actorToDestruct = ActorsInfo.Simple.Actor;
- ActorsInfo.Simple.ActorId = 0;
- ActorsInfo.Simple.Actor = nullptr;
+ ActorsInfo.Simple.ActorId = 0;
+ ActorsInfo.Simple.Actor = nullptr;
break;
- }
+ }
case TMailboxActorPack::Map: {
- TActorMap::iterator it = ActorsInfo.Map.ActorsMap->find(localActorId);
- Y_VERIFY(it != ActorsInfo.Map.ActorsMap->end());
+ TActorMap::iterator it = ActorsInfo.Map.ActorsMap->find(localActorId);
+ Y_VERIFY(it != ActorsInfo.Map.ActorsMap->end());
actorToDestruct = it->second;
- ActorsInfo.Map.ActorsMap->erase(it);
-
- if (ActorsInfo.Map.ActorsMap->size() == ARRAY_CAPACITY) {
- auto ar = new TActorArray;
- ui64 i = 0;
- for (auto& [actorId, actor] : *ActorsInfo.Map.ActorsMap) {
- ar->Actors[i++] = TActorPair{actor, actorId};
- }
- delete ActorsInfo.Map.ActorsMap;
- ActorPack = TMailboxActorPack::Array;
- ActorsInfo.Array.ActorsArray = ar;
- ActorsInfo.Array.ActorsCount = ARRAY_CAPACITY;
- }
- break;
- }
- case TMailboxActorPack::Array: {
- bool found = false;
- for (ui64 i = 0; i < ActorsInfo.Array.ActorsCount; ++i) {
- if (ActorsInfo.Array.ActorsArray->Actors[i].ActorId == localActorId) {
- found = true;
- actorToDestruct = ActorsInfo.Array.ActorsArray->Actors[i].Actor;
- ActorsInfo.Array.ActorsArray->Actors[i] = ActorsInfo.Array.ActorsArray->Actors[ActorsInfo.Array.ActorsCount - 1];
- ActorsInfo.Array.ActorsCount -= 1;
- break;
- }
- }
- Y_VERIFY(found);
-
- if (ActorsInfo.Array.ActorsCount == 1) {
- const TActorPair Actor = ActorsInfo.Array.ActorsArray->Actors[0];
- delete ActorsInfo.Array.ActorsArray;
+ ActorsInfo.Map.ActorsMap->erase(it);
+
+ if (ActorsInfo.Map.ActorsMap->size() == ARRAY_CAPACITY) {
+ auto ar = new TActorArray;
+ ui64 i = 0;
+ for (auto& [actorId, actor] : *ActorsInfo.Map.ActorsMap) {
+ ar->Actors[i++] = TActorPair{actor, actorId};
+ }
+ delete ActorsInfo.Map.ActorsMap;
+ ActorPack = TMailboxActorPack::Array;
+ ActorsInfo.Array.ActorsArray = ar;
+ ActorsInfo.Array.ActorsCount = ARRAY_CAPACITY;
+ }
+ break;
+ }
+ case TMailboxActorPack::Array: {
+ bool found = false;
+ for (ui64 i = 0; i < ActorsInfo.Array.ActorsCount; ++i) {
+ if (ActorsInfo.Array.ActorsArray->Actors[i].ActorId == localActorId) {
+ found = true;
+ actorToDestruct = ActorsInfo.Array.ActorsArray->Actors[i].Actor;
+ ActorsInfo.Array.ActorsArray->Actors[i] = ActorsInfo.Array.ActorsArray->Actors[ActorsInfo.Array.ActorsCount - 1];
+ ActorsInfo.Array.ActorsCount -= 1;
+ break;
+ }
+ }
+ Y_VERIFY(found);
+
+ if (ActorsInfo.Array.ActorsCount == 1) {
+ const TActorPair Actor = ActorsInfo.Array.ActorsArray->Actors[0];
+ delete ActorsInfo.Array.ActorsArray;
ActorPack = TMailboxActorPack::Simple;
- ActorsInfo.Simple = Actor;
+ ActorsInfo.Simple = Actor;
}
- break;
- }
+ break;
+ }
}
return actorToDestruct;
diff --git a/ydb/core/blobstorage/ut_blobstorage/counting_events.cpp b/ydb/core/blobstorage/ut_blobstorage/counting_events.cpp
index 1f1b9e27be..974176b00b 100644
--- a/ydb/core/blobstorage/ut_blobstorage/counting_events.cpp
+++ b/ydb/core/blobstorage/ut_blobstorage/counting_events.cpp
@@ -1,61 +1,61 @@
#include <ydb/core/blobstorage/ut_blobstorage/lib/env.h>
-
+
#include <ydb/core/blobstorage/dsproxy/group_sessions.h>
-
-
-Y_UNIT_TEST_SUITE(CountingEvents) {
-
- struct TTestInfo {
- std::unique_ptr<TTestActorSystem> &Runtime;
- TActorId Edge;
- TIntrusivePtr<TBlobStorageGroupInfo> Info;
- };
-
- void SendPut(const TTestInfo &test, const TLogoBlobID &blobId, const TString &data,
- NKikimrProto::EReplyStatus status)
- {
+
+
+Y_UNIT_TEST_SUITE(CountingEvents) {
+
+ struct TTestInfo {
+ std::unique_ptr<TTestActorSystem> &Runtime;
+ TActorId Edge;
+ TIntrusivePtr<TBlobStorageGroupInfo> Info;
+ };
+
+ void SendPut(const TTestInfo &test, const TLogoBlobID &blobId, const TString &data,
+ NKikimrProto::EReplyStatus status)
+ {
std::unique_ptr<IEventBase> ev = std::make_unique<TEvBlobStorage::TEvPut>(blobId, data, TInstant::Max());
-
- test.Runtime->WrapInActorContext(test.Edge, [&] {
+
+ test.Runtime->WrapInActorContext(test.Edge, [&] {
SendToBSProxy(test.Edge, test.Info->GroupID, ev.release());
- });
- std::unique_ptr<IEventHandle> handle = test.Runtime->WaitForEdgeActorEvent({test.Edge});
-
- UNIT_ASSERT_EQUAL(handle->Type, TEvBlobStorage::EvPutResult);
- TEvBlobStorage::TEvPutResult *putResult = handle->Get<TEvBlobStorage::TEvPutResult>();
- UNIT_ASSERT_EQUAL(putResult->Status, status);
- };
-
- void SendGet(const TTestInfo &test, const TLogoBlobID &blobId, const TString &data,
- NKikimrProto::EReplyStatus status)
- {
+ });
+ std::unique_ptr<IEventHandle> handle = test.Runtime->WaitForEdgeActorEvent({test.Edge});
+
+ UNIT_ASSERT_EQUAL(handle->Type, TEvBlobStorage::EvPutResult);
+ TEvBlobStorage::TEvPutResult *putResult = handle->Get<TEvBlobStorage::TEvPutResult>();
+ UNIT_ASSERT_EQUAL(putResult->Status, status);
+ };
+
+ void SendGet(const TTestInfo &test, const TLogoBlobID &blobId, const TString &data,
+ NKikimrProto::EReplyStatus status)
+ {
std::unique_ptr<IEventBase> ev = std::make_unique<TEvBlobStorage::TEvGet>(blobId, 0, 0, TInstant::Max(), NKikimrBlobStorage::AsyncRead);
- test.Runtime->WrapInActorContext(test.Edge, [&] {
+ test.Runtime->WrapInActorContext(test.Edge, [&] {
SendToBSProxy(test.Edge, test.Info->GroupID, ev.release());
- });
- std::unique_ptr<IEventHandle> handle = test.Runtime->WaitForEdgeActorEvent({test.Edge});
- UNIT_ASSERT_EQUAL(handle->Type, TEvBlobStorage::EvGetResult);
- TEvBlobStorage::TEvGetResult *getResult = handle->Get<TEvBlobStorage::TEvGetResult>();
- UNIT_ASSERT(getResult);
- UNIT_ASSERT_VALUES_EQUAL(getResult->ResponseSz, 1);
- UNIT_ASSERT_VALUES_EQUAL(getResult->Responses[0].Status, status);
- UNIT_ASSERT_VALUES_EQUAL(getResult->Responses[0].Buffer, data);
- };
-
- void SendCollect(const TTestInfo &test, const TLogoBlobID &blobId,
- NKikimrProto::EReplyStatus status)
- {
+ });
+ std::unique_ptr<IEventHandle> handle = test.Runtime->WaitForEdgeActorEvent({test.Edge});
+ UNIT_ASSERT_EQUAL(handle->Type, TEvBlobStorage::EvGetResult);
+ TEvBlobStorage::TEvGetResult *getResult = handle->Get<TEvBlobStorage::TEvGetResult>();
+ UNIT_ASSERT(getResult);
+ UNIT_ASSERT_VALUES_EQUAL(getResult->ResponseSz, 1);
+ UNIT_ASSERT_VALUES_EQUAL(getResult->Responses[0].Status, status);
+ UNIT_ASSERT_VALUES_EQUAL(getResult->Responses[0].Buffer, data);
+ };
+
+ void SendCollect(const TTestInfo &test, const TLogoBlobID &blobId,
+ NKikimrProto::EReplyStatus status)
+ {
std::unique_ptr<IEventBase> ev = std::make_unique<TEvBlobStorage::TEvCollectGarbage>(blobId.TabletID(), blobId.Generation(),
- blobId.Step(), blobId.Channel(), true, blobId.Generation(), blobId.Step(), nullptr, nullptr, TInstant::Max(), false);
- test.Runtime->WrapInActorContext(test.Edge, [&] {
+ blobId.Step(), blobId.Channel(), true, blobId.Generation(), blobId.Step(), nullptr, nullptr, TInstant::Max(), false);
+ test.Runtime->WrapInActorContext(test.Edge, [&] {
SendToBSProxy(test.Edge, test.Info->GroupID, ev.release());
- });
- std::unique_ptr<IEventHandle> handle = test.Runtime->WaitForEdgeActorEvent({test.Edge});
- UNIT_ASSERT_EQUAL(handle->Type, TEvBlobStorage::EvCollectGarbageResult);
- TEvBlobStorage::TEvCollectGarbageResult *collectResult = handle->Get<TEvBlobStorage::TEvCollectGarbageResult>();
- UNIT_ASSERT_EQUAL(collectResult->Status, status);
- }
-
+ });
+ std::unique_ptr<IEventHandle> handle = test.Runtime->WaitForEdgeActorEvent({test.Edge});
+ UNIT_ASSERT_EQUAL(handle->Type, TEvBlobStorage::EvCollectGarbageResult);
+ TEvBlobStorage::TEvCollectGarbageResult *collectResult = handle->Get<TEvBlobStorage::TEvCollectGarbageResult>();
+ UNIT_ASSERT_EQUAL(collectResult->Status, status);
+ }
+
TIntrusivePtr<TGroupQueues> ReceiveGroupQueues(const TTestInfo &test) {
test.Runtime->WrapInActorContext(test.Edge, [&] {
SendToBSProxy(test.Edge, test.Info->GroupID, new TEvRequestProxySessionsState);
@@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(CountingEvents) {
TEvProxySessionsState *state = handle->Get<TEvProxySessionsState>();
return state->GroupQueues;
}
-
+
void NormalizePredictedDelays(const TIntrusivePtr<TGroupQueues> &queues) {
for (TGroupQueues::TFailDomain &domain : queues->FailDomains) {
for (TGroupQueues::TVDisk &vDisk : domain.VDisks) {
@@ -84,131 +84,131 @@ Y_UNIT_TEST_SUITE(CountingEvents) {
}
- void CountingEventsTest(TString typeOperation, ui32 eventsCount, TBlobStorageGroupType groupType)
- {
- TEnvironmentSetup env(true, groupType);
- auto& runtime = env.Runtime;
-
- env.CreateBoxAndPool();
- env.CommenceReplication();
-
- auto groups = env.GetGroups();
- auto info = env.GetGroupInfo(groups[0]);
-
- const TActorId& edge = runtime->AllocateEdgeActor(1);
- TTestInfo test{runtime, edge, info};
-
+ void CountingEventsTest(TString typeOperation, ui32 eventsCount, TBlobStorageGroupType groupType)
+ {
+ TEnvironmentSetup env(true, groupType);
+ auto& runtime = env.Runtime;
+
+ env.CreateBoxAndPool();
+ env.CommenceReplication();
+
+ auto groups = env.GetGroups();
+ auto info = env.GetGroupInfo(groups[0]);
+
+ const TActorId& edge = runtime->AllocateEdgeActor(1);
+ TTestInfo test{runtime, edge, info};
+
// set predicted a response time
TIntrusivePtr<TGroupQueues> queues = ReceiveGroupQueues(test);
- constexpr ui32 size = 100;
- TString data(size, 'a');
- ui64 tabletId = 1;
-
- ui64 startEventsCount = 0;
- ui64 finishEventsCount = 0;
-
- if (typeOperation == "put") {
- TLogoBlobID originalBlobId(tabletId, 1, 0, 0, size, 0);
+ constexpr ui32 size = 100;
+ TString data(size, 'a');
+ ui64 tabletId = 1;
+
+ ui64 startEventsCount = 0;
+ ui64 finishEventsCount = 0;
+
+ if (typeOperation == "put") {
+ TLogoBlobID originalBlobId(tabletId, 1, 0, 0, size, 0);
NormalizePredictedDelays(queues);
- SendPut(test, originalBlobId, data, NKikimrProto::OK);
-
- startEventsCount = test.Runtime->GetEventsProcessed();
- TLogoBlobID originalBlobId2(tabletId, 1, 1, 0, size, 0);
+ SendPut(test, originalBlobId, data, NKikimrProto::OK);
+
+ startEventsCount = test.Runtime->GetEventsProcessed();
+ TLogoBlobID originalBlobId2(tabletId, 1, 1, 0, size, 0);
NormalizePredictedDelays(queues);
- SendPut(test, originalBlobId2, data, NKikimrProto::OK);
- finishEventsCount = test.Runtime->GetEventsProcessed();
+ SendPut(test, originalBlobId2, data, NKikimrProto::OK);
+ finishEventsCount = test.Runtime->GetEventsProcessed();
- UNIT_ASSERT_VALUES_EQUAL(finishEventsCount - startEventsCount, eventsCount);
-
- startEventsCount = test.Runtime->GetEventsProcessed();
- TLogoBlobID originalBlobId3(tabletId, 1, 2, 0, size, 0);
+ UNIT_ASSERT_VALUES_EQUAL(finishEventsCount - startEventsCount, eventsCount);
+
+ startEventsCount = test.Runtime->GetEventsProcessed();
+ TLogoBlobID originalBlobId3(tabletId, 1, 2, 0, size, 0);
NormalizePredictedDelays(queues);
- SendPut(test, originalBlobId3, data, NKikimrProto::OK);
- finishEventsCount = test.Runtime->GetEventsProcessed();
-
- UNIT_ASSERT_VALUES_EQUAL(finishEventsCount - startEventsCount, eventsCount);
- } else if (typeOperation == "get") {
- TLogoBlobID originalBlobId(tabletId, 1, 0, 0, size, 0);
+ SendPut(test, originalBlobId3, data, NKikimrProto::OK);
+ finishEventsCount = test.Runtime->GetEventsProcessed();
+
+ UNIT_ASSERT_VALUES_EQUAL(finishEventsCount - startEventsCount, eventsCount);
+ } else if (typeOperation == "get") {
+ TLogoBlobID originalBlobId(tabletId, 1, 0, 0, size, 0);
NormalizePredictedDelays(queues);
- SendPut(test, originalBlobId, data, NKikimrProto::OK);
+ SendPut(test, originalBlobId, data, NKikimrProto::OK);
NormalizePredictedDelays(queues);
- SendGet(test, originalBlobId, data, NKikimrProto::OK);
-
- startEventsCount = test.Runtime->GetEventsProcessed();
+ SendGet(test, originalBlobId, data, NKikimrProto::OK);
+
+ startEventsCount = test.Runtime->GetEventsProcessed();
NormalizePredictedDelays(queues);
- SendGet(test, originalBlobId, data, NKikimrProto::OK);
- finishEventsCount = test.Runtime->GetEventsProcessed();
-
- UNIT_ASSERT_VALUES_EQUAL(finishEventsCount - startEventsCount, eventsCount);
-
- startEventsCount = test.Runtime->GetEventsProcessed();
+ SendGet(test, originalBlobId, data, NKikimrProto::OK);
+ finishEventsCount = test.Runtime->GetEventsProcessed();
+
+ UNIT_ASSERT_VALUES_EQUAL(finishEventsCount - startEventsCount, eventsCount);
+
+ startEventsCount = test.Runtime->GetEventsProcessed();
NormalizePredictedDelays(queues);
- SendGet(test, originalBlobId, data, NKikimrProto::OK);
- finishEventsCount = test.Runtime->GetEventsProcessed();
-
- UNIT_ASSERT_VALUES_EQUAL(finishEventsCount - startEventsCount, eventsCount);
- } else if (typeOperation == "collect") {
- TLogoBlobID originalBlobId(tabletId, 1, 0, 0, size, 0);
+ SendGet(test, originalBlobId, data, NKikimrProto::OK);
+ finishEventsCount = test.Runtime->GetEventsProcessed();
+
+ UNIT_ASSERT_VALUES_EQUAL(finishEventsCount - startEventsCount, eventsCount);
+ } else if (typeOperation == "collect") {
+ TLogoBlobID originalBlobId(tabletId, 1, 0, 0, size, 0);
NormalizePredictedDelays(queues);
- SendPut(test, originalBlobId, data, NKikimrProto::OK);
-
- startEventsCount = test.Runtime->GetEventsProcessed();
- TLogoBlobID originalBlobId2(tabletId, 1, 1, 0, size, 0);
+ SendPut(test, originalBlobId, data, NKikimrProto::OK);
+
+ startEventsCount = test.Runtime->GetEventsProcessed();
+ TLogoBlobID originalBlobId2(tabletId, 1, 1, 0, size, 0);
NormalizePredictedDelays(queues);
- SendCollect(test, originalBlobId2, NKikimrProto::OK);
- finishEventsCount = test.Runtime->GetEventsProcessed();
-
- UNIT_ASSERT_VALUES_EQUAL(finishEventsCount - startEventsCount, eventsCount);
- }
- }
-
- Y_UNIT_TEST(Put_Mirror3of4) {
+ SendCollect(test, originalBlobId2, NKikimrProto::OK);
+ finishEventsCount = test.Runtime->GetEventsProcessed();
+
+ UNIT_ASSERT_VALUES_EQUAL(finishEventsCount - startEventsCount, eventsCount);
+ }
+ }
+
+ Y_UNIT_TEST(Put_Mirror3of4) {
CountingEventsTest("put", 116, TBlobStorageGroupType::ErasureMirror3of4);
- }
-
- Y_UNIT_TEST(Put_Mirror3dc) {
+ }
+
+ Y_UNIT_TEST(Put_Mirror3dc) {
CountingEventsTest("put", 49, TBlobStorageGroupType::ErasureMirror3dc);
- }
-
- Y_UNIT_TEST(Put_Block42) {
+ }
+
+ Y_UNIT_TEST(Put_Block42) {
CountingEventsTest("put", 89, TBlobStorageGroupType::Erasure4Plus2Block);
- }
-
- Y_UNIT_TEST(Put_None) {
- CountingEventsTest("put", 19, TBlobStorageGroupType::ErasureNone);
- }
-
- Y_UNIT_TEST(Get_Mirror3of4) {
+ }
+
+ Y_UNIT_TEST(Put_None) {
+ CountingEventsTest("put", 19, TBlobStorageGroupType::ErasureNone);
+ }
+
+ Y_UNIT_TEST(Get_Mirror3of4) {
CountingEventsTest("get", 38, TBlobStorageGroupType::ErasureMirror3of4);
- }
-
- Y_UNIT_TEST(Get_Mirror3dc) {
- CountingEventsTest("get", 14, TBlobStorageGroupType::ErasureMirror3dc);
- }
-
- Y_UNIT_TEST(Get_Block42) {
+ }
+
+ Y_UNIT_TEST(Get_Mirror3dc) {
+ CountingEventsTest("get", 14, TBlobStorageGroupType::ErasureMirror3dc);
+ }
+
+ Y_UNIT_TEST(Get_Block42) {
CountingEventsTest("get", 69, TBlobStorageGroupType::Erasure4Plus2Block);
- }
-
- Y_UNIT_TEST(Get_None) {
- CountingEventsTest("get", 14, TBlobStorageGroupType::ErasureNone);
- }
-
- Y_UNIT_TEST(Collect_Mirror3of4) {
+ }
+
+ Y_UNIT_TEST(Get_None) {
+ CountingEventsTest("get", 14, TBlobStorageGroupType::ErasureNone);
+ }
+
+ Y_UNIT_TEST(Collect_Mirror3of4) {
CountingEventsTest("collect", 113, TBlobStorageGroupType::ErasureMirror3of4);
- }
+ }
- Y_UNIT_TEST(Collect_Mirror3dc) {
+ Y_UNIT_TEST(Collect_Mirror3dc) {
CountingEventsTest("collect", 124, TBlobStorageGroupType::ErasureMirror3dc);
- }
-
- Y_UNIT_TEST(Collect_Block42) {
+ }
+
+ Y_UNIT_TEST(Collect_Block42) {
CountingEventsTest("collect", 112, TBlobStorageGroupType::Erasure4Plus2Block);
- }
-
- Y_UNIT_TEST(Collect_None) {
- CountingEventsTest("collect", 16, TBlobStorageGroupType::ErasureNone);
- }
-}
-
+ }
+
+ Y_UNIT_TEST(Collect_None) {
+ CountingEventsTest("collect", 16, TBlobStorageGroupType::ErasureNone);
+ }
+}
+
diff --git a/ydb/core/blobstorage/ut_blobstorage/patch.cpp b/ydb/core/blobstorage/ut_blobstorage/patch.cpp
index b68c05b80e..21d1bf1274 100644
--- a/ydb/core/blobstorage/ut_blobstorage/patch.cpp
+++ b/ydb/core/blobstorage/ut_blobstorage/patch.cpp
@@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(BlobPatching) {
TTestInfo test = InitTest(env);
constexpr ui32 size = 100;
- TString data(size, 'a');
+ TString data(size, 'a');
TLogoBlobID originalBlobId(1, 1, 0, 0, size, 0);
std::unique_ptr<IEventHandle> handle;
@@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(BlobPatching) {
TTestInfo test = InitTest(env);
constexpr ui32 size = 100;
- TString data(size, 'a');
+ TString data(size, 'a');
TLogoBlobID originalBlobId(1, 1, 0, 0, size, 0);
std::unique_ptr<IEventHandle> handle;
@@ -202,4 +202,4 @@ Y_UNIT_TEST_SUITE(BlobPatching) {
});
}
}
-
+
diff --git a/ydb/core/util/time_series_vec.h b/ydb/core/util/time_series_vec.h
index e0753e06ee..4847649634 100644
--- a/ydb/core/util/time_series_vec.h
+++ b/ydb/core/util/time_series_vec.h
@@ -46,18 +46,18 @@ public:
template <class T, ui64 IntervalUs>
class TTimeSeriesVec {
TVector<T> Values; // circular buffer of intervals
- ui64 Id = 0; // id (instant/interval) of the last value in buffer
+ ui64 Id = 0; // id (instant/interval) of the last value in buffer
public:
// Make empty time series
explicit TTimeSeriesVec(size_t size) {
Values.resize(size, T());
- Id = size - 1;
+ Id = size - 1;
}
// Make a subseries holding values within given time range [begin; end)
TTimeSeriesVec(const TTimeSeriesVec& source, TInstant begin, TInstant end) {
- ui64 beginId = Max(source.BeginId(), begin.MicroSeconds() / IntervalUs);
- ui64 endId = Min(source.EndId(), end.MicroSeconds() / IntervalUs);
+ ui64 beginId = Max(source.BeginId(), begin.MicroSeconds() / IntervalUs);
+ ui64 endId = Min(source.EndId(), end.MicroSeconds() / IntervalUs);
if (beginId < endId) {
Values.reserve(endId - beginId);
for (ui64 id = beginId; id != endId; id++) {
@@ -106,7 +106,7 @@ public:
// Get value of interval containing instant
T Get(TInstant instant) const {
- ui64 id = instant.MicroSeconds() / IntervalUs;
+ ui64 id = instant.MicroSeconds() / IntervalUs;
return Values[id % Size()];
}
@@ -115,7 +115,7 @@ public:
size_t result = Add(o.Begin(), &o.Values[0] + idx, o.Size() - idx, beginLimit);
if (idx > 0) {
result += Add(o.Begin() + o.Interval() * (o.Size() - idx), &o.Values[0], idx, beginLimit);
- }
+ }
return result;
}
@@ -139,7 +139,7 @@ public:
// History overwrite is allowed up to `beginLimit` (excluded)
// Returns true iff addition was successful or skipped (too old)
bool Add(TInstant instant, T value, TInstant beginLimit = TInstant::Max()) {
- ui64 id = instant.MicroSeconds() / IntervalUs;
+ ui64 id = instant.MicroSeconds() / IntervalUs;
return Add(id, value, beginLimit);
}
@@ -154,11 +154,11 @@ public:
}
private:
- ui64 BeginId() const {
+ ui64 BeginId() const {
return Id + 1 - Size();
}
- ui64 EndId() const {
+ ui64 EndId() const {
return Id + 1;
}
@@ -199,11 +199,11 @@ private:
return true; // added successfully
}
- void Propagate(ui64 id) {
- if (id <= Id) {
+ void Propagate(ui64 id) {
+ if (id <= Id) {
return;
}
- if (id - Id >= Size()) {
+ if (id - Id >= Size()) {
Clear();
Id = id;
} else {
diff --git a/ydb/core/util/time_series_vec_ut.cpp b/ydb/core/util/time_series_vec_ut.cpp
index ca5aa41d88..a20c8fca6a 100644
--- a/ydb/core/util/time_series_vec_ut.cpp
+++ b/ydb/core/util/time_series_vec_ut.cpp
@@ -23,102 +23,102 @@ Y_UNIT_TEST_SUITE(TTimeSeriesVecTest) {
}
UNIT_ASSERT(total == 70);
}
-
- Y_UNIT_TEST(IndexesArePositive) {
- constexpr TDuration Interval = TDuration::MilliSeconds(1);
- constexpr size_t Size = 3;
- TTimeSeriesVec<int, Interval.MicroSeconds()> tsv(Size);
- UNIT_ASSERT(tsv.Begin().MicroSeconds() == 0);
- UNIT_ASSERT(tsv.End().MicroSeconds() == Interval.MicroSeconds() * 3);
-
- TTimeSeriesVec<int, Interval.MicroSeconds()> tsv2(tsv, tsv.Begin(), tsv.End());
- UNIT_ASSERT(tsv2.Begin().MicroSeconds() == 0);
- UNIT_ASSERT(tsv2.End().MicroSeconds() == Interval.MicroSeconds() * 3);
- }
-
- Y_UNIT_TEST(OverwritingBuffer) {
- constexpr TDuration Interval = TDuration::MilliSeconds(1);
- constexpr size_t Size = 4;
- TTimeSeriesVec<int, Interval.MicroSeconds()> tsv(Size);
- UNIT_ASSERT(tsv.Size() == Size);
- TInstant now = TInstant::Now();
- for (ui64 i = 0; i < 10; ++i) {
- tsv.Add(now + Interval * i, i);
- }
- UNIT_ASSERT(tsv.Get(now + Interval * 6) == 6);
- UNIT_ASSERT(tsv.Get(now + Interval * 9) == 9);
-
- UNIT_ASSERT(tsv.Get(now + Interval * 5) != 5);
- }
-
- Y_UNIT_TEST(MakeSubseries) {
- constexpr TDuration Interval = TDuration::MilliSeconds(1);
- constexpr size_t Size = 100;
- TTimeSeriesVec<int, Interval.MicroSeconds()> tsv(Size);
- UNIT_ASSERT(tsv.Size() == Size);
- ui64 c = 0;
- for (TInstant i = tsv.Begin(), e = tsv.End(); i != e; i = tsv.Next(i)) {
- tsv.Add(i, c++);
- }
-
- int LastValue = -1;
- for (ui64 i = 0; i < 10; ++i) {
- TTimeSeriesVec<int, Interval.MicroSeconds()> tsv2(tsv, tsv.Begin() + Interval * i * 10, tsv.Begin() + Interval * (i + 1) * 10);
- UNIT_ASSERT(tsv2.Size() == 10);
- UNIT_ASSERT(tsv2.Get(tsv2.Begin()) == LastValue + 1);
- LastValue = tsv2.Get(tsv2.End() - Interval);
- }
- }
-
- Y_UNIT_TEST(AddValuesSameInterval) {
- constexpr TDuration Interval = TDuration::MilliSeconds(1);
- constexpr size_t Size = 5;
- TTimeSeriesVec<int, Interval.MicroSeconds()> tsv(Size);
- ui64 c = 0;
- for (TInstant i = tsv.Begin(), e = tsv.End(); i != e; i = tsv.Next(i)) {
- tsv.Add(i, c++);
- }
-
- int data[3] = {5, 6, 7};
+
+ Y_UNIT_TEST(IndexesArePositive) {
+ constexpr TDuration Interval = TDuration::MilliSeconds(1);
+ constexpr size_t Size = 3;
+ TTimeSeriesVec<int, Interval.MicroSeconds()> tsv(Size);
+ UNIT_ASSERT(tsv.Begin().MicroSeconds() == 0);
+ UNIT_ASSERT(tsv.End().MicroSeconds() == Interval.MicroSeconds() * 3);
+
+ TTimeSeriesVec<int, Interval.MicroSeconds()> tsv2(tsv, tsv.Begin(), tsv.End());
+ UNIT_ASSERT(tsv2.Begin().MicroSeconds() == 0);
+ UNIT_ASSERT(tsv2.End().MicroSeconds() == Interval.MicroSeconds() * 3);
+ }
+
+ Y_UNIT_TEST(OverwritingBuffer) {
+ constexpr TDuration Interval = TDuration::MilliSeconds(1);
+ constexpr size_t Size = 4;
+ TTimeSeriesVec<int, Interval.MicroSeconds()> tsv(Size);
+ UNIT_ASSERT(tsv.Size() == Size);
+ TInstant now = TInstant::Now();
+ for (ui64 i = 0; i < 10; ++i) {
+ tsv.Add(now + Interval * i, i);
+ }
+ UNIT_ASSERT(tsv.Get(now + Interval * 6) == 6);
+ UNIT_ASSERT(tsv.Get(now + Interval * 9) == 9);
+
+ UNIT_ASSERT(tsv.Get(now + Interval * 5) != 5);
+ }
+
+ Y_UNIT_TEST(MakeSubseries) {
+ constexpr TDuration Interval = TDuration::MilliSeconds(1);
+ constexpr size_t Size = 100;
+ TTimeSeriesVec<int, Interval.MicroSeconds()> tsv(Size);
+ UNIT_ASSERT(tsv.Size() == Size);
+ ui64 c = 0;
+ for (TInstant i = tsv.Begin(), e = tsv.End(); i != e; i = tsv.Next(i)) {
+ tsv.Add(i, c++);
+ }
+
+ int LastValue = -1;
+ for (ui64 i = 0; i < 10; ++i) {
+ TTimeSeriesVec<int, Interval.MicroSeconds()> tsv2(tsv, tsv.Begin() + Interval * i * 10, tsv.Begin() + Interval * (i + 1) * 10);
+ UNIT_ASSERT(tsv2.Size() == 10);
+ UNIT_ASSERT(tsv2.Get(tsv2.Begin()) == LastValue + 1);
+ LastValue = tsv2.Get(tsv2.End() - Interval);
+ }
+ }
+
+ Y_UNIT_TEST(AddValuesSameInterval) {
+ constexpr TDuration Interval = TDuration::MilliSeconds(1);
+ constexpr size_t Size = 5;
+ TTimeSeriesVec<int, Interval.MicroSeconds()> tsv(Size);
+ ui64 c = 0;
+ for (TInstant i = tsv.Begin(), e = tsv.End(); i != e; i = tsv.Next(i)) {
+ tsv.Add(i, c++);
+ }
+
+ int data[3] = {5, 6, 7};
tsv.Add(tsv.Interval(), tsv.End(), data, 3);
-
- UNIT_ASSERT(tsv.Get(tsv.Begin()) == 3);
- UNIT_ASSERT(tsv.Get(tsv.End() - Interval) == 7);
-
+
+ UNIT_ASSERT(tsv.Get(tsv.Begin()) == 3);
+ UNIT_ASSERT(tsv.Get(tsv.End() - Interval) == 7);
+
tsv.Add(tsv.Interval(), tsv.Begin(), data, 3);
-
- UNIT_ASSERT(tsv.Get(tsv.Begin()) == 8); // 3 + 5
- UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval) == 10); // 4 + 6
- UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval * 2) == 12); // 5 + 7
- UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval * 3) == 6); // 6
- UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval * 4) == 7); // 7
-
- int data2[7] = {8, 9, 10, 11, 12, 13, 14};
-
+
+ UNIT_ASSERT(tsv.Get(tsv.Begin()) == 8); // 3 + 5
+ UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval) == 10); // 4 + 6
+ UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval * 2) == 12); // 5 + 7
+ UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval * 3) == 6); // 6
+ UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval * 4) == 7); // 7
+
+ int data2[7] = {8, 9, 10, 11, 12, 13, 14};
+
tsv.Add(tsv.Interval(), tsv.End() - Interval, data2, 7);
-
- UNIT_ASSERT(tsv.Get(tsv.Begin()) == 10);
- UNIT_ASSERT(tsv.Get(tsv.End() - Interval) == 14);
- }
-
- Y_UNIT_TEST(AddValuesCustomInterval) {
- constexpr TDuration Interval = TDuration::MilliSeconds(1);
- constexpr size_t Size = 5;
- TTimeSeriesVec<int, Interval.MicroSeconds()> tsv(Size);
- ui64 c = 0;
- for (TInstant i = tsv.Begin(), e = tsv.End(); i != e; i = tsv.Next(i)) {
- tsv.Add(i, c++);
- }
-
- int data[3] = {5, 6, 7};
- tsv.Add(Interval * 2, tsv.Begin(), data, 3);
-
- UNIT_ASSERT(tsv.Get(tsv.Begin()) == 5); // 0 + 5
- UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval) == 1); // 1
- UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval * 2) == 8); // 2 + 6
- UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval * 3) == 3); // 3
- UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval * 4) == 11); // 4 + 7
- }
+
+ UNIT_ASSERT(tsv.Get(tsv.Begin()) == 10);
+ UNIT_ASSERT(tsv.Get(tsv.End() - Interval) == 14);
+ }
+
+ Y_UNIT_TEST(AddValuesCustomInterval) {
+ constexpr TDuration Interval = TDuration::MilliSeconds(1);
+ constexpr size_t Size = 5;
+ TTimeSeriesVec<int, Interval.MicroSeconds()> tsv(Size);
+ ui64 c = 0;
+ for (TInstant i = tsv.Begin(), e = tsv.End(); i != e; i = tsv.Next(i)) {
+ tsv.Add(i, c++);
+ }
+
+ int data[3] = {5, 6, 7};
+ tsv.Add(Interval * 2, tsv.Begin(), data, 3);
+
+ UNIT_ASSERT(tsv.Get(tsv.Begin()) == 5); // 0 + 5
+ UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval) == 1); // 1
+ UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval * 2) == 8); // 2 + 6
+ UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval * 3) == 3); // 3
+ UNIT_ASSERT(tsv.Get(tsv.Begin() + Interval * 4) == 11); // 4 + 7
+ }
}
} // NKikimr