Skip to content

Commit 8692bcf

Browse files
committed
YDB-7262 Add default permille ICB configuration for vdisk garbage compaction threshold (#6819)
Сloses #7262 (cherry picked from commit 18c3f7a)
1 parent 725b0df commit 8692bcf

File tree

9 files changed

+26
-11
lines changed

9 files changed

+26
-11
lines changed

ydb/core/blobstorage/nodewarden/node_warden_impl.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ void TNodeWarden::Bootstrap() {
179179
icb->RegisterSharedControl(EnableSyncLogChunkCompressionSSD, "VDiskControls.EnableSyncLogChunkCompressionSSD");
180180
icb->RegisterSharedControl(MaxSyncLogChunksInFlightHDD, "VDiskControls.MaxSyncLogChunksInFlightHDD");
181181
icb->RegisterSharedControl(MaxSyncLogChunksInFlightSSD, "VDiskControls.MaxSyncLogChunksInFlightSSD");
182+
icb->RegisterSharedControl(DefaultHugeGarbagePerMille, "VDiskControls.DefaultHugeGarbagePerMille");
182183

183184
icb->RegisterSharedControl(CostMetricsParametersByMedia[NPDisk::DEVICE_TYPE_ROT].BurstThresholdNs,
184185
"VDiskControls.BurstThresholdNsHDD");

ydb/core/blobstorage/nodewarden/node_warden_impl.h

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ namespace NKikimr::NStorage {
139139
TControlWrapper EnableSyncLogChunkCompressionSSD;
140140
TControlWrapper MaxSyncLogChunksInFlightHDD;
141141
TControlWrapper MaxSyncLogChunksInFlightSSD;
142+
TControlWrapper DefaultHugeGarbagePerMille;
142143

143144
TReplQuoter::TPtr ReplNodeRequestQuoter;
144145
TReplQuoter::TPtr ReplNodeResponseQuoter;
@@ -162,6 +163,7 @@ namespace NKikimr::NStorage {
162163
, EnableSyncLogChunkCompressionSSD(0, 0, 1)
163164
, MaxSyncLogChunksInFlightHDD(10, 1, 1024)
164165
, MaxSyncLogChunksInFlightSSD(10, 1, 1024)
166+
, DefaultHugeGarbagePerMille(300, 1, 1000)
165167
, CostMetricsParametersByMedia({
166168
TCostMetricsParameters{200},
167169
TCostMetricsParameters{50},

ydb/core/blobstorage/nodewarden/node_warden_vdisk.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ namespace NKikimr::NStorage {
179179
vdiskConfig->EnableVDiskCooldownTimeout = Cfg->EnableVDiskCooldownTimeout;
180180
vdiskConfig->ReplPausedAtStart = Cfg->VDiskReplPausedAtStart;
181181
vdiskConfig->EnableVPatch = EnableVPatch;
182+
vdiskConfig->DefaultHugeGarbagePerMille = DefaultHugeGarbagePerMille;
182183

183184
vdiskConfig->EnableLocalSyncLogDataCutting = EnableLocalSyncLogDataCutting;
184185
if (deviceType == NPDisk::EDeviceType::DEVICE_TYPE_ROT) {

ydb/core/blobstorage/vdisk/common/vdisk_config.h

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ namespace NKikimr {
218218
TDuration WhiteboardUpdateInterval;
219219
bool EnableVDiskCooldownTimeout;
220220
TControlWrapper EnableVPatch = true;
221+
TControlWrapper DefaultHugeGarbagePerMille;
221222

222223
///////////// COST METRICS SETTINGS ////////////////
223224
bool UseCostTracker = true;

ydb/core/blobstorage/vdisk/defrag/defrag_actor.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ namespace NKikimr {
1616
////////////////////////////////////////////////////////////////////////////
1717
TDefragCtx::TDefragCtx(
1818
const TIntrusivePtr<TVDiskContext> &vctx,
19+
const TIntrusivePtr<TVDiskConfig> &vconfig,
1920
const std::shared_ptr<THugeBlobCtx> &hugeBlobCtx,
2021
const TPDiskCtxPtr &pdiskCtx,
2122
const TActorId &skeletonId,
2223
const TActorId &hugeKeeperId,
2324
bool runDefrageBySchedule)
2425
: VCtx(vctx)
26+
, VCfg(vconfig)
2527
, HugeBlobCtx(hugeBlobCtx)
2628
, PDiskCtx(pdiskCtx)
2729
, SkeletonId(skeletonId)
@@ -48,19 +50,23 @@ namespace NKikimr {
4850
bool HugeHeapDefragmentationRequired(
4951
const TOutOfSpaceState& oos,
5052
ui32 hugeCanBeFreedChunks,
51-
ui32 hugeTotalChunks) {
53+
ui32 hugeTotalChunks,
54+
double defaultPercent) {
5255

5356
if (hugeCanBeFreedChunks < 10)
5457
return false;
5558

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

5861
if (oos.GetLocalColor() > TSpaceColor::CYAN) {
59-
return percentOfGarbage >= 0.02;
62+
// For anything worse than CYAN
63+
return percentOfGarbage >= Min(0.02, defaultPercent);
6064
} else if (oos.GetLocalColor() > TSpaceColor::GREEN) {
61-
return percentOfGarbage >= 0.15;
65+
// For CYAN
66+
return percentOfGarbage >= Min(0.15, defaultPercent);
6267
} else {
63-
return percentOfGarbage >= 0.30;
68+
// For GREEN
69+
return percentOfGarbage >= Min(0.30, defaultPercent);
6470
}
6571
}
6672

@@ -113,7 +119,8 @@ namespace NKikimr {
113119
const auto& oos = DCtx->VCtx->GetOutOfSpaceState();
114120
Y_ABORT_UNLESS(usefulChunks <= totalChunks);
115121
const ui32 canBeFreedChunks = totalChunks - usefulChunks;
116-
if (HugeHeapDefragmentationRequired(oos, canBeFreedChunks, totalChunks)) {
122+
double defaultPercent = DCtx->VCfg->DefaultHugeGarbagePerMille / 1000.0;
123+
if (HugeHeapDefragmentationRequired(oos, canBeFreedChunks, totalChunks, defaultPercent)) {
117124
TChunksToDefrag chunksToDefrag = calcStat.GetChunksToDefrag(DCtx->MaxChunksToDefrag);
118125
Y_ABORT_UNLESS(chunksToDefrag);
119126
STLOG(PRI_INFO, BS_VDISK_DEFRAG, BSVDD03, VDISKP(DCtx->VCtx->VDiskLogPrefix, "scan finished"),

ydb/core/blobstorage/vdisk/defrag/defrag_actor.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace NKikimr {
1818
////////////////////////////////////////////////////////////////////////////
1919
struct TDefragCtx {
2020
const TIntrusivePtr<TVDiskContext> VCtx;
21+
const TIntrusivePtr<TVDiskConfig> VCfg;
2122
const std::shared_ptr<THugeBlobCtx> HugeBlobCtx;
2223
const TPDiskCtxPtr PDiskCtx;
2324
const TActorId SkeletonId;
@@ -30,6 +31,7 @@ namespace NKikimr {
3031

3132
TDefragCtx(
3233
const TIntrusivePtr<TVDiskContext> &vctx,
34+
const TIntrusivePtr<TVDiskConfig> &vconfig,
3335
const std::shared_ptr<THugeBlobCtx> &hugeBlobCtx,
3436
const TPDiskCtxPtr &pdiskCtx,
3537
const TActorId &skeletonId,
@@ -45,7 +47,8 @@ namespace NKikimr {
4547
bool HugeHeapDefragmentationRequired(
4648
const TOutOfSpaceState& oos,
4749
ui32 hugeCanBeFreedChunks,
48-
ui32 hugeTotalChunks);
50+
ui32 hugeTotalChunks,
51+
double defaultPercent);
4952

5053
////////////////////////////////////////////////////////////////////////////
5154
// VDISK DEFRAG ACTOR CREATOR

ydb/core/blobstorage/vdisk/defrag/defrag_actor_ut.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ namespace NKikimr {
1515
TOutOfSpaceState oos(1, 0);
1616
ui32 hugeCanBeFreedChunks = 9;
1717
ui32 hugeUsedChunks = 20;
18-
bool defrag = HugeHeapDefragmentationRequired(oos, hugeCanBeFreedChunks, hugeUsedChunks);
18+
bool defrag = HugeHeapDefragmentationRequired(oos, hugeCanBeFreedChunks, hugeUsedChunks, 0.30);
1919
UNIT_ASSERT(!defrag);
2020
}
2121
{
2222
TOutOfSpaceState oos(1, 0);
2323
ui32 hugeCanBeFreedChunks = 200;
2424
ui32 hugeUsedChunks = 1000;
25-
bool defrag = HugeHeapDefragmentationRequired(oos, hugeCanBeFreedChunks, hugeUsedChunks);
25+
bool defrag = HugeHeapDefragmentationRequired(oos, hugeCanBeFreedChunks, hugeUsedChunks, 0.30);
2626
UNIT_ASSERT(!defrag);
2727
}
2828
{
2929
TOutOfSpaceState oos(1, 0);
3030
ui32 hugeCanBeFreedChunks = 301;
3131
ui32 hugeUsedChunks = 1000;
32-
bool defrag = HugeHeapDefragmentationRequired(oos, hugeCanBeFreedChunks, hugeUsedChunks);
32+
bool defrag = HugeHeapDefragmentationRequired(oos, hugeCanBeFreedChunks, hugeUsedChunks, 0.30);
3333
UNIT_ASSERT(defrag);
3434
}
3535
}

ydb/core/blobstorage/vdisk/defrag/defrag_quantum.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace NKikimr {
9595
Compact();
9696

9797
auto hugeStat = GetHugeStat();
98-
Y_ABORT_UNLESS(hugeStat.LockedChunks.size() < 100);
98+
Y_DEBUG_ABORT_UNLESS(hugeStat.LockedChunks.size() < 100);
9999
}
100100

101101
Send(ParentActorId, new TEvDefragQuantumResult(std::move(stat)));

ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ namespace NKikimr {
17891789
}
17901790

17911791
void StartDefrag(const TActorContext &ctx) {
1792-
auto defragCtx = std::make_shared<TDefragCtx>(VCtx, HugeBlobCtx, PDiskCtx, ctx.SelfID,
1792+
auto defragCtx = std::make_shared<TDefragCtx>(VCtx, Config, HugeBlobCtx, PDiskCtx, ctx.SelfID,
17931793
Db->HugeKeeperID, true);
17941794
DefragId = ctx.Register(CreateDefragActor(defragCtx, GInfo));
17951795
ActiveActors.Insert(DefragId, __FILE__, __LINE__, ctx, NKikimrServices::BLOBSTORAGE); // keep forever

0 commit comments

Comments
 (0)