Skip to content

Commit

Permalink
Fix burst tests, adjust cost bucket inflow dynamically (ydb-platform#…
Browse files Browse the repository at this point in the history
  • Loading branch information
serbel324 committed Jun 5, 2024
1 parent da66c07 commit 9fe9ac6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ydb/core/blobstorage/ut_blobstorage/monitoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ Y_UNIT_TEST(Test##requestType##distribution) {
}

Y_UNIT_TEST_SUITE(BurstDetection) {
MAKE_BURST_TEST(Put, 50, 1, TDuration::MilliSeconds(100), Evenly);
MAKE_BURST_TEST(Put, 50, 100, TDuration::Zero(), Burst);
MAKE_BURST_TEST(Put, 10, 1, TDuration::Seconds(1), Evenly);
MAKE_BURST_TEST(Put, 10, 100, TDuration::MilliSeconds(1), Burst);
}

#undef MAKE_BURST_TEST
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ TBsCostTracker::TBsCostTracker(const TBlobStorageGroupType& groupType, NPDisk::E
, ScrubDiskCost(CostCounters->GetCounter("ScrubDiskCost", true))
, DefragDiskCost(CostCounters->GetCounter("DefragDiskCost", true))
, InternalDiskCost(CostCounters->GetCounter("InternalDiskCost", true))
, Bucket(&BucketInflow, &BucketCapacity, nullptr, nullptr, nullptr, nullptr, true)
, Bucket(&DiskTimeAvailableNs, &BucketCapacity, nullptr, nullptr, nullptr, nullptr, true)
{
BurstDetector.Initialize(CostCounters, "BurstDetector");
switch (GroupType.GetErasure()) {
Expand Down
31 changes: 29 additions & 2 deletions ydb/core/blobstorage/vdisk/common/blobstorage_cost_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,29 @@ class TBsCostModelBase {
}
};

struct TFailTimer {
using TTime = TInstant;
static TTime Now() {
Y_FAIL();
}
};

template<class TBackupTimer = TFailTimer>
struct TAppDataTimerMs {
using TTime = TInstant;
static constexpr ui64 Resolution = 1000ull; // milliseconds
static TTime Now() {
if (NKikimr::TAppData::TimeProvider) {
return NKikimr::TAppData::TimeProvider->Now();
} else {
return TBackupTimer::Now();
}
}
static ui64 Duration(TTime from, TTime to) {
return (to - from).MilliSeconds();
}
};

using TBsCostModelErasureNone = TBsCostModelBase;
class TBsCostModelMirror3dc;
class TBsCostModel4Plus2Block;
Expand All @@ -296,8 +319,8 @@ class TBsCostTracker {
::NMonitoring::TDynamicCounters::TCounterPtr InternalDiskCost;

TAtomic BucketCapacity = 1'000'000'000; // 10^9 nsec
TAtomic BucketInflow = 1'000'000'000; // 10^9 nsec
TBucketQuoter<i64, TSpinLock, THPTimerUs> Bucket;
TAtomic DiskTimeAvailableNs = 1'000'000'000;
TBucketQuoter<i64, TSpinLock, TAppDataTimerMs<TInstantTimerMs>> Bucket;
TLight BurstDetector;
std::atomic<ui64> SeqnoBurstDetector = 0;
static constexpr ui32 ConcurrentHugeRequestsAllowed = 3;
Expand Down Expand Up @@ -349,6 +372,10 @@ class TBsCostTracker {
BurstDetector.Set(!Bucket.IsAvail(), SeqnoBurstDetector.fetch_add(1));
}

void SetTimeAvailable(ui32 diskTimeAvailableNSec) {
AtomicSet(DiskTimeAvailableNs, diskTimeAvailableNSec);
}

public:
template<class TEvent>
void CountUserRequest(const TEvent& ev) {
Expand Down
4 changes: 3 additions & 1 deletion ydb/core/blobstorage/vdisk/skeleton/skeleton_oos_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ namespace NKikimr {
MonGroup.DskTotalBytes() = msg->TotalChunks * PDiskCtx->Dsk->ChunkSize;
MonGroup.DskFreeBytes() = msg->FreeChunks * PDiskCtx->Dsk->ChunkSize;
if (msg->NumSlots > 0) {
CostGroup.DiskTimeAvailableNs() = 1'000'000'000ull / msg->NumSlots;
ui32 timeAvailable = 1'000'000'000 / msg->NumSlots;
CostGroup.DiskTimeAvailableNs() = timeAvailable;
VCtx->CostTracker->SetTimeAvailable(timeAvailable);
}

Become(&TThis::WaitFunc);
Expand Down

0 comments on commit 9fe9ac6

Please sign in to comment.