Skip to content
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

YDB-7262 Add default permille ICB configuration for vdisk garbage compaction threshold #7319

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
1 change: 1 addition & 0 deletions ydb/core/blobstorage/nodewarden/node_warden_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ void TNodeWarden::Bootstrap() {
icb->RegisterSharedControl(EnableSyncLogChunkCompressionSSD, "VDiskControls.EnableSyncLogChunkCompressionSSD");
icb->RegisterSharedControl(MaxSyncLogChunksInFlightHDD, "VDiskControls.MaxSyncLogChunksInFlightHDD");
icb->RegisterSharedControl(MaxSyncLogChunksInFlightSSD, "VDiskControls.MaxSyncLogChunksInFlightSSD");
icb->RegisterSharedControl(DefaultHugeGarbagePerMille, "VDiskControls.DefaultHugeGarbagePerMille");

icb->RegisterSharedControl(CostMetricsParametersByMedia[NPDisk::DEVICE_TYPE_ROT].BurstThresholdNs,
"VDiskControls.BurstThresholdNsHDD");
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 @@ -139,6 +139,7 @@ namespace NKikimr::NStorage {
TControlWrapper EnableSyncLogChunkCompressionSSD;
TControlWrapper MaxSyncLogChunksInFlightHDD;
TControlWrapper MaxSyncLogChunksInFlightSSD;
TControlWrapper DefaultHugeGarbagePerMille;

TReplQuoter::TPtr ReplNodeRequestQuoter;
TReplQuoter::TPtr ReplNodeResponseQuoter;
Expand All @@ -162,6 +163,7 @@ namespace NKikimr::NStorage {
, EnableSyncLogChunkCompressionSSD(0, 0, 1)
, MaxSyncLogChunksInFlightHDD(10, 1, 1024)
, MaxSyncLogChunksInFlightSSD(10, 1, 1024)
, DefaultHugeGarbagePerMille(300, 1, 1000)
, CostMetricsParametersByMedia({
TCostMetricsParameters{200},
TCostMetricsParameters{50},
Expand Down
1 change: 1 addition & 0 deletions ydb/core/blobstorage/nodewarden/node_warden_vdisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ namespace NKikimr::NStorage {
vdiskConfig->EnableVDiskCooldownTimeout = Cfg->EnableVDiskCooldownTimeout;
vdiskConfig->ReplPausedAtStart = Cfg->VDiskReplPausedAtStart;
vdiskConfig->EnableVPatch = EnableVPatch;
vdiskConfig->DefaultHugeGarbagePerMille = DefaultHugeGarbagePerMille;

vdiskConfig->EnableLocalSyncLogDataCutting = EnableLocalSyncLogDataCutting;
if (deviceType == NPDisk::EDeviceType::DEVICE_TYPE_ROT) {
Expand Down
1 change: 1 addition & 0 deletions ydb/core/blobstorage/vdisk/common/vdisk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ namespace NKikimr {
TDuration WhiteboardUpdateInterval;
bool EnableVDiskCooldownTimeout;
TControlWrapper EnableVPatch = true;
TControlWrapper DefaultHugeGarbagePerMille;

///////////// COST METRICS SETTINGS ////////////////
bool UseCostTracker = true;
Expand Down
17 changes: 12 additions & 5 deletions ydb/core/blobstorage/vdisk/defrag/defrag_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ namespace NKikimr {
////////////////////////////////////////////////////////////////////////////
TDefragCtx::TDefragCtx(
const TIntrusivePtr<TVDiskContext> &vctx,
const TIntrusivePtr<TVDiskConfig> &vconfig,
const std::shared_ptr<THugeBlobCtx> &hugeBlobCtx,
const TPDiskCtxPtr &pdiskCtx,
const TActorId &skeletonId,
const TActorId &hugeKeeperId,
bool runDefrageBySchedule)
: VCtx(vctx)
, VCfg(vconfig)
, HugeBlobCtx(hugeBlobCtx)
, PDiskCtx(pdiskCtx)
, SkeletonId(skeletonId)
Expand All @@ -48,19 +50,23 @@ namespace NKikimr {
bool HugeHeapDefragmentationRequired(
const TOutOfSpaceState& oos,
ui32 hugeCanBeFreedChunks,
ui32 hugeTotalChunks) {
ui32 hugeTotalChunks,
double defaultPercent) {

if (hugeCanBeFreedChunks < 10)
return false;

double percentOfGarbage = static_cast<double>(hugeCanBeFreedChunks) / hugeTotalChunks;

if (oos.GetLocalColor() > TSpaceColor::CYAN) {
return percentOfGarbage >= 0.02;
// For anything worse than CYAN
return percentOfGarbage >= Min(0.02, defaultPercent);
} else if (oos.GetLocalColor() > TSpaceColor::GREEN) {
return percentOfGarbage >= 0.15;
// For CYAN
return percentOfGarbage >= Min(0.15, defaultPercent);
} else {
return percentOfGarbage >= 0.30;
// For GREEN
return percentOfGarbage >= Min(0.30, defaultPercent);
}
}

Expand Down Expand Up @@ -113,7 +119,8 @@ namespace NKikimr {
const auto& oos = DCtx->VCtx->GetOutOfSpaceState();
Y_ABORT_UNLESS(usefulChunks <= totalChunks);
const ui32 canBeFreedChunks = totalChunks - usefulChunks;
if (HugeHeapDefragmentationRequired(oos, canBeFreedChunks, totalChunks)) {
double defaultPercent = DCtx->VCfg->DefaultHugeGarbagePerMille / 1000.0;
if (HugeHeapDefragmentationRequired(oos, canBeFreedChunks, totalChunks, defaultPercent)) {
TChunksToDefrag chunksToDefrag = calcStat.GetChunksToDefrag(DCtx->MaxChunksToDefrag);
Y_ABORT_UNLESS(chunksToDefrag);
STLOG(PRI_INFO, BS_VDISK_DEFRAG, BSVDD03, VDISKP(DCtx->VCtx->VDiskLogPrefix, "scan finished"),
Expand Down
5 changes: 4 additions & 1 deletion ydb/core/blobstorage/vdisk/defrag/defrag_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace NKikimr {
////////////////////////////////////////////////////////////////////////////
struct TDefragCtx {
const TIntrusivePtr<TVDiskContext> VCtx;
const TIntrusivePtr<TVDiskConfig> VCfg;
const std::shared_ptr<THugeBlobCtx> HugeBlobCtx;
const TPDiskCtxPtr PDiskCtx;
const TActorId SkeletonId;
Expand All @@ -30,6 +31,7 @@ namespace NKikimr {

TDefragCtx(
const TIntrusivePtr<TVDiskContext> &vctx,
const TIntrusivePtr<TVDiskConfig> &vconfig,
const std::shared_ptr<THugeBlobCtx> &hugeBlobCtx,
const TPDiskCtxPtr &pdiskCtx,
const TActorId &skeletonId,
Expand All @@ -45,7 +47,8 @@ namespace NKikimr {
bool HugeHeapDefragmentationRequired(
const TOutOfSpaceState& oos,
ui32 hugeCanBeFreedChunks,
ui32 hugeTotalChunks);
ui32 hugeTotalChunks,
double defaultPercent);

////////////////////////////////////////////////////////////////////////////
// VDISK DEFRAG ACTOR CREATOR
Expand Down
6 changes: 3 additions & 3 deletions ydb/core/blobstorage/vdisk/defrag/defrag_actor_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ namespace NKikimr {
TOutOfSpaceState oos(1, 0);
ui32 hugeCanBeFreedChunks = 9;
ui32 hugeUsedChunks = 20;
bool defrag = HugeHeapDefragmentationRequired(oos, hugeCanBeFreedChunks, hugeUsedChunks);
bool defrag = HugeHeapDefragmentationRequired(oos, hugeCanBeFreedChunks, hugeUsedChunks, 0.30);
UNIT_ASSERT(!defrag);
}
{
TOutOfSpaceState oos(1, 0);
ui32 hugeCanBeFreedChunks = 200;
ui32 hugeUsedChunks = 1000;
bool defrag = HugeHeapDefragmentationRequired(oos, hugeCanBeFreedChunks, hugeUsedChunks);
bool defrag = HugeHeapDefragmentationRequired(oos, hugeCanBeFreedChunks, hugeUsedChunks, 0.30);
UNIT_ASSERT(!defrag);
}
{
TOutOfSpaceState oos(1, 0);
ui32 hugeCanBeFreedChunks = 301;
ui32 hugeUsedChunks = 1000;
bool defrag = HugeHeapDefragmentationRequired(oos, hugeCanBeFreedChunks, hugeUsedChunks);
bool defrag = HugeHeapDefragmentationRequired(oos, hugeCanBeFreedChunks, hugeUsedChunks, 0.30);
UNIT_ASSERT(defrag);
}
}
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/blobstorage/vdisk/defrag/defrag_quantum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ namespace NKikimr {
Compact();

auto hugeStat = GetHugeStat();
Y_ABORT_UNLESS(hugeStat.LockedChunks.size() < 100);
Y_DEBUG_ABORT_UNLESS(hugeStat.LockedChunks.size() < 100);
}

Send(ParentActorId, new TEvDefragQuantumResult(std::move(stat)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ namespace NKikimr {
}

void StartDefrag(const TActorContext &ctx) {
auto defragCtx = std::make_shared<TDefragCtx>(VCtx, HugeBlobCtx, PDiskCtx, ctx.SelfID,
auto defragCtx = std::make_shared<TDefragCtx>(VCtx, Config, HugeBlobCtx, PDiskCtx, ctx.SelfID,
Db->HugeKeeperID, true);
DefragId = ctx.Register(CreateDefragActor(defragCtx, GInfo));
ActiveActors.Insert(DefragId, __FILE__, __LINE__, ctx, NKikimrServices::BLOBSTORAGE); // keep forever
Expand Down
5 changes: 5 additions & 0 deletions ydb/core/protos/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,11 @@ message TImmediateControlsConfig {
MinValue: 1,
MaxValue: 1000000,
DefaultValue: 1000 }];
optional uint64 DefaultHugeGarbagePerMille = 12 [(ControlOptions) = {
Description: "Default threshold of huge chunk garbage per mille which triggers huge chunk defragmentation",
MinValue: 1,
MaxValue: 1000,
DefaultValue: 300 }];
}

message TTabletControls {
Expand Down
Loading