Skip to content

add vdisk throttling according to disk space occupancy #13098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ydb/core/blobstorage/nodewarden/node_warden_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ TNodeWarden::TNodeWarden(const TIntrusivePtr<TNodeWardenConfig> &cfg)
, ThrottlingMaxSstCount(250, 1, 1000)
, ThrottlingMinInplacedSize(20ull << 30, 1 << 20, 500ull < 30)
, ThrottlingMaxInplacedSize(60ull << 30, 1 << 20, 500ull < 30)
, ThrottlingMinOccupancyPerMille(900, 1, 1000)
, ThrottlingMaxOccupancyPerMille(950, 1, 1000)
, MaxCommonLogChunksHDD(200, 1, 1'000'000)
, MaxCommonLogChunksSSD(200, 1, 1'000'000)
, CostMetricsParametersByMedia({
Expand Down Expand Up @@ -347,6 +349,8 @@ void TNodeWarden::Bootstrap() {
icb->RegisterSharedControl(ThrottlingMaxSstCount, "VDiskControls.ThrottlingMaxSstCount");
icb->RegisterSharedControl(ThrottlingMinInplacedSize, "VDiskControls.ThrottlingMinInplacedSize");
icb->RegisterSharedControl(ThrottlingMaxInplacedSize, "VDiskControls.ThrottlingMaxInplacedSize");
icb->RegisterSharedControl(ThrottlingMinOccupancyPerMille, "VDiskControls.ThrottlingMinOccupancyPerMille");
icb->RegisterSharedControl(ThrottlingMaxOccupancyPerMille, "VDiskControls.ThrottlingMaxOccupancyPerMille");

icb->RegisterSharedControl(MaxCommonLogChunksHDD, "PDiskControls.MaxCommonLogChunksHDD");
icb->RegisterSharedControl(MaxCommonLogChunksSSD, "PDiskControls.MaxCommonLogChunksSSD");
Expand Down
2 changes: 2 additions & 0 deletions ydb/core/blobstorage/nodewarden/node_warden_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ namespace NKikimr::NStorage {
TControlWrapper ThrottlingMaxSstCount;
TControlWrapper ThrottlingMinInplacedSize;
TControlWrapper ThrottlingMaxInplacedSize;
TControlWrapper ThrottlingMinOccupancyPerMille;
TControlWrapper ThrottlingMaxOccupancyPerMille;

TControlWrapper MaxCommonLogChunksHDD;
TControlWrapper MaxCommonLogChunksSSD;
Expand Down
2 changes: 2 additions & 0 deletions ydb/core/blobstorage/nodewarden/node_warden_vdisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ namespace NKikimr::NStorage {
vdiskConfig->ThrottlingMaxSstCount = ThrottlingMaxSstCount;
vdiskConfig->ThrottlingMinInplacedSize = ThrottlingMinInplacedSize;
vdiskConfig->ThrottlingMaxInplacedSize = ThrottlingMaxInplacedSize;
vdiskConfig->ThrottlingMinOccupancyPerMille = ThrottlingMinOccupancyPerMille;
vdiskConfig->ThrottlingMaxOccupancyPerMille = ThrottlingMaxOccupancyPerMille;

vdiskConfig->CostMetricsParametersByMedia = CostMetricsParametersByMedia;

Expand Down
2 changes: 2 additions & 0 deletions ydb/core/blobstorage/vdisk/common/vdisk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ namespace NKikimr {
TControlWrapper ThrottlingMaxSstCount;
TControlWrapper ThrottlingMinInplacedSize;
TControlWrapper ThrottlingMaxInplacedSize;
TControlWrapper ThrottlingMinOccupancyPerMille;
TControlWrapper ThrottlingMaxOccupancyPerMille;

///////////// FEATURE FLAGS ////////////////////////
NKikimrConfig::TFeatureFlags FeatureFlags;
Expand Down
2 changes: 2 additions & 0 deletions ydb/core/blobstorage/vdisk/common/vdisk_mongroups.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public:
COUNTER_INIT_IF_EXTENDED(ThrottlingIsActive, false);
COUNTER_INIT_IF_EXTENDED(ThrottlingLevel0SstCount, false);
COUNTER_INIT_IF_EXTENDED(ThrottlingAllLevelsInplacedSize, false);
COUNTER_INIT_IF_EXTENDED(ThrottlingOccupancyPerMille, false);
}

COUNTER_DEF(EmergencyMovedPatchQueueItems);
Expand All @@ -163,6 +164,7 @@ public:
COUNTER_DEF(ThrottlingIsActive);
COUNTER_DEF(ThrottlingLevel0SstCount);
COUNTER_DEF(ThrottlingAllLevelsInplacedSize);
COUNTER_DEF(ThrottlingOccupancyPerMille);
};

///////////////////////////////////////////////////////////////////////////////////
Expand Down
34 changes: 26 additions & 8 deletions ydb/core/blobstorage/vdisk/skeleton/skeleton_overload_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ namespace NKikimr {

ui64 CurrentSstCount = 0;
ui64 CurrentInplacedSize = 0;
ui64 CurrentOccupancy = 0;

TInstant CurrentTime;
ui64 CurrentSpeedLimit = 0;
Expand Down Expand Up @@ -219,10 +220,20 @@ namespace NKikimr {
return LinearInterpolation(CurrentInplacedSize, minInplacedSize, maxInplacedSize, deviceSpeed);
}

ui64 CalcOccupancySpeedLimit() const {
ui64 deviceSpeed = (ui64)VCfg->ThrottlingDeviceSpeed;
ui64 minOccupancy = (ui64)VCfg->ThrottlingMinOccupancyPerMille * 1000;
ui64 maxOccupancy = (ui64)VCfg->ThrottlingMaxOccupancyPerMille * 1000;

return LinearInterpolation(CurrentOccupancy, minOccupancy, maxOccupancy, deviceSpeed);
}

ui64 CalcCurrentSpeedLimit() const {
ui64 sstCountSpeedLimit = CalcSstCountSpeedLimit();
ui64 inplacedSizeSpeedLimit = CalcInplacedSizeSpeedLimit();
return std::min(sstCountSpeedLimit, inplacedSizeSpeedLimit);
ui64 occupancySpeedLimit = CalcOccupancySpeedLimit();

return std::min(occupancySpeedLimit, std::min(sstCountSpeedLimit, inplacedSizeSpeedLimit));
}

public:
Expand All @@ -236,9 +247,11 @@ namespace NKikimr {
bool IsActive() const {
ui64 minSstCount = (ui64)VCfg->ThrottlingMinSstCount;
ui64 minInplacedSize = (ui64)VCfg->ThrottlingMinInplacedSize;
ui64 minOccupancy = (ui64)VCfg->ThrottlingMinOccupancyPerMille * 1000;

return CurrentSstCount > minSstCount ||
CurrentInplacedSize > minInplacedSize;
CurrentInplacedSize > minInplacedSize ||
CurrentOccupancy > minOccupancy;
}

TDuration BytesToDuration(ui64 bytes) const {
Expand All @@ -258,7 +271,7 @@ namespace NKikimr {
return AvailableBytes;
}

void UpdateState(TInstant now, ui64 sstCount, ui64 inplacedSize) {
void UpdateState(TInstant now, ui64 sstCount, ui64 inplacedSize, float occupancy) {
bool prevActive = IsActive();

CurrentSstCount = sstCount;
Expand All @@ -267,6 +280,9 @@ namespace NKikimr {
CurrentInplacedSize = inplacedSize;
Mon.ThrottlingAllLevelsInplacedSize() = inplacedSize;

CurrentOccupancy = occupancy * 1'000'000;
Mon.ThrottlingOccupancyPerMille() = occupancy * 1000;

Mon.ThrottlingIsActive() = (ui64)IsActive();

if (!IsActive()) {
Expand All @@ -291,7 +307,7 @@ namespace NKikimr {
auto us = (now - CurrentTime).MicroSeconds();
AvailableBytes += CurrentSpeedLimit * us / 1000000;
ui64 deviceSpeed = (ui64)VCfg->ThrottlingDeviceSpeed;
AvailableBytes = Min(AvailableBytes, deviceSpeed);
AvailableBytes = std::min(AvailableBytes, deviceSpeed);
CurrentTime = now;
}
};
Expand All @@ -311,7 +327,8 @@ namespace NKikimr {
TVMultiPutHandler &&vMultiPut,
TLocalSyncDataHandler &&loc,
TAnubisOsirisPutHandler &&aoput)
: Hull(std::move(hull))
: VCtx(vctx)
, Hull(std::move(hull))
, Mon(std::move(mon))
, EmergencyQueue(new TEmergencyQueue(Mon, std::move(vMovedPatch), std::move(vPatchStart), std::move(vput),
std::move(vMultiPut), std::move(loc), std::move(aoput)))
Expand Down Expand Up @@ -358,11 +375,12 @@ namespace NKikimr {
auto& logoBlobsSnap = snapshot.LogoBlobsSnap; // TLogoBlobsSnapshot
auto& sliceSnap = logoBlobsSnap.SliceSnap; // TLevelSliceSnapshot

auto sstCount = sliceSnap.GetLevel0SstsNum();
auto dataInplacedSize = logoBlobsSnap.AllLevelsDataInplaced;
ui64 sstCount = sliceSnap.GetLevel0SstsNum();
ui64 dataInplacedSize = logoBlobsSnap.AllLevelsDataInplaced;
float occupancy = 1.f - VCtx->GetOutOfSpaceState().GetFreeSpaceShare();

auto now = ctx.Now();
ThrottlingController->UpdateState(now, sstCount, dataInplacedSize);
ThrottlingController->UpdateState(now, sstCount, dataInplacedSize, occupancy);

if (ThrottlingController->IsActive()) {
ThrottlingController->UpdateTime(now);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ namespace NKikimr {
void OnKickEmergencyPutQueue();

private:
TIntrusivePtr<TVDiskContext> VCtx;
std::shared_ptr<THull> Hull;
NMonGroup::TSkeletonOverloadGroup Mon;
std::unique_ptr<TEmergencyQueue> EmergencyQueue;
Expand Down
10 changes: 10 additions & 0 deletions ydb/core/protos/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,16 @@ message TImmediateControlsConfig {
MinValue: 1048576,
MaxValue: 536870912000,
DefaultValue: 64424509440 }];
optional uint64 ThrottlingMinOccupancyPerMille = 19 [(ControlOptions) = {
Description: "Minimum occupancy of disk per mille - throttling is turned on",
MinValue: 1,
MaxValue: 1000,
DefaultValue: 900 }];
optional uint64 ThrottlingMaxOccupancyPerMille = 20 [(ControlOptions) = {
Description: "Maximum occupancy of disk per mille - throttling speed is zero",
MinValue: 1,
MaxValue: 1000,
DefaultValue: 950 }];
}

message TTabletControls {
Expand Down
Loading