From 61ceca63626ea6bb220b7a9775ba5855a3345f38 Mon Sep 17 00:00:00 2001 From: Sergey Belyakov Date: Fri, 7 Jun 2024 18:31:02 +0000 Subject: [PATCH] Don't mark disk as slowest if there is only one disk --- .../blobstorage/dsproxy/dsproxy_get_impl.cpp | 1 + .../dsproxy/dsproxy_strategy_base.cpp | 4 ++ .../dsproxy/dsproxy_strategy_get_m3dc_basic.h | 48 ++++++++++--------- .../dsproxy/dsproxy_strategy_restore.h | 20 ++++---- 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp index dba55f7d112c..18c63e66de73 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp @@ -170,6 +170,7 @@ ui64 TGetImpl::GetTimeToAccelerateNs(TLogContext &logCtx, NKikimrBlobStorage::EV Blackboard.GetWorstPredictedDelaysNs( *Info, *Blackboard.GroupQueues, queueId, nthWorst, &worstDisks); } + nthWorst = std::min(nthWorst, (ui32)worstDisks.size() - 1); return worstDisks[nthWorst].PredictedNs; } diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_strategy_base.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_strategy_base.cpp index 1d4bf102da19..9243f693990c 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_strategy_base.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_strategy_base.cpp @@ -390,6 +390,10 @@ void TStrategyBase::Prepare3dcPartPlacement(const TBlobState &state, ui32 TStrategyBase::MakeSlowSubgroupDiskMask(TBlobState &state, const TBlobStorageGroupInfo &info, TBlackboard &blackboard, bool isPut) { + if (info.GetTotalVDisksNum() == 1) { + // when there is only one disk, we consider it not slow + return 0; + } // Find the slowest disk switch (blackboard.AccelerationMode) { case TBlackboard::AccelerationModeSkipOneSlowest: { diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_strategy_get_m3dc_basic.h b/ydb/core/blobstorage/dsproxy/dsproxy_strategy_get_m3dc_basic.h index b6b8798107b2..1e4c9acfb584 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_strategy_get_m3dc_basic.h +++ b/ydb/core/blobstorage/dsproxy/dsproxy_strategy_get_m3dc_basic.h @@ -70,32 +70,34 @@ namespace NKikimr { // issue request for a specific disk; returns true if the request was issued and not yet completed, otherwise // false - // find the slowest disk and mark it - switch (blackboard.AccelerationMode) { - case TBlackboard::AccelerationModeSkipOneSlowest: { - TDiskDelayPredictions worstDisks; - state.GetWorstPredictedDelaysNs(info, *blackboard.GroupQueues, - HandleClassToQueueId(blackboard.GetHandleClass), 1, - &worstDisks); - - // Check if the slowest disk exceptionally slow, or just not very fast - i32 slowDiskSubgroupIdx = -1; - if (worstDisks[1].PredictedNs > 0 && worstDisks[0].PredictedNs > worstDisks[1].PredictedNs * 2) { - slowDiskSubgroupIdx = worstDisks[1].DiskIdx; - } + if (info.GetTotalVDisksNum() > 1) { + // find the slowest disk and mark it + switch (blackboard.AccelerationMode) { + case TBlackboard::AccelerationModeSkipOneSlowest: { + TDiskDelayPredictions worstDisks; + state.GetWorstPredictedDelaysNs(info, *blackboard.GroupQueues, + HandleClassToQueueId(blackboard.GetHandleClass), 1, + &worstDisks); + + // Check if the slowest disk exceptionally slow, or just not very fast + i32 slowDiskSubgroupIdx = -1; + if (worstDisks[1].PredictedNs > 0 && worstDisks[0].PredictedNs > worstDisks[1].PredictedNs * 2) { + slowDiskSubgroupIdx = worstDisks[1].DiskIdx; + } - // Mark single slow disk - for (size_t diskIdx = 0; diskIdx < state.Disks.size(); ++diskIdx) { - state.Disks[diskIdx].IsSlow = false; - } - if (slowDiskSubgroupIdx >= 0) { - state.Disks[slowDiskSubgroupIdx].IsSlow = true; + // Mark single slow disk + for (size_t diskIdx = 0; diskIdx < state.Disks.size(); ++diskIdx) { + state.Disks[diskIdx].IsSlow = false; + } + if (slowDiskSubgroupIdx >= 0) { + state.Disks[slowDiskSubgroupIdx].IsSlow = true; + } + break; } - break; + case TBlackboard::AccelerationModeSkipMarked: + // The slowest disk is already marked! + break; } - case TBlackboard::AccelerationModeSkipMarked: - // The slowest disk is already marked! - break; } // create an array defining order in which we traverse the disks diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_strategy_restore.h b/ydb/core/blobstorage/dsproxy/dsproxy_strategy_restore.h index d46cee639fd1..5be8e482a663 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_strategy_restore.h +++ b/ydb/core/blobstorage/dsproxy/dsproxy_strategy_restore.h @@ -125,16 +125,18 @@ class TRestoreStrategy : public TStrategyBase { return *res; } - // Find the slowest disk - TDiskDelayPredictions worstDisks; - state.GetWorstPredictedDelaysNs(info, *blackboard.GroupQueues, - HandleClassToQueueId(blackboard.PutHandleClass), 1, - &worstDisks); - - // Check if the slowest disk exceptionally slow, or just not very fast TStackVec slowDiskSubgroupIdxs; - if (worstDisks[1].PredictedNs > 0 && worstDisks[0].PredictedNs > worstDisks[1].PredictedNs * 2) { - slowDiskSubgroupIdxs.push_back(worstDisks[0].DiskIdx); + if (info.GetTotalVDisksNum() > 1) { + // Find the slowest disk, if there are more than 1 + TDiskDelayPredictions worstDisks; + state.GetWorstPredictedDelaysNs(info, *blackboard.GroupQueues, + HandleClassToQueueId(blackboard.PutHandleClass), 1, + &worstDisks); + + // Check if the slowest disk exceptionally slow, or just not very fast + if (worstDisks[1].PredictedNs > 0 && worstDisks[0].PredictedNs > worstDisks[1].PredictedNs * 2) { + slowDiskSubgroupIdxs.push_back(worstDisks[0].DiskIdx); + } } bool isDone = false;