From 1ab736a23a693198ce2f2f3f180a5b6504f155a6 Mon Sep 17 00:00:00 2001 From: robdrynkin Date: Mon, 21 Oct 2024 16:55:02 +0000 Subject: [PATCH] Decrease number of inflyght chunks to defrag while disk space green --- ydb/core/blobstorage/vdisk/defrag/defrag_actor.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ydb/core/blobstorage/vdisk/defrag/defrag_actor.cpp b/ydb/core/blobstorage/vdisk/defrag/defrag_actor.cpp index ba9248b30d66..6f3913971410 100644 --- a/ydb/core/blobstorage/vdisk/defrag/defrag_actor.cpp +++ b/ydb/core/blobstorage/vdisk/defrag/defrag_actor.cpp @@ -78,6 +78,14 @@ namespace NKikimr { return HugeHeapDefragmentationRequired(hugeCanBeFreedChunks, hugeTotalChunks, defragThreshold); } + ui32 MaxInflyghtDefragChunks(const TOutOfSpaceState& oos, ui32 maxChunksToDefrag) { + if (oos.GetLocalColor() > TSpaceColor::GREEN) { + return maxChunksToDefrag; + } else { + return 1; + } + } + //////////////////////////////////////////////////////////////////////////// // TDefragLocalScheduler // We use statistics about free space share and numbe of used/canBeFreed chunks @@ -131,7 +139,7 @@ namespace NKikimr { double hugeDefragFreeSpaceBorder = DCtx->VCfg->HugeDefragFreeSpaceBorderPerMille / 1000.0; DCtx->DefragMonGroup.DefragThreshold() = DefragThreshold(oos, defaultPercent, hugeDefragFreeSpaceBorder); if (HugeHeapDefragmentationRequired(oos, canBeFreedChunks, totalChunks, defaultPercent, hugeDefragFreeSpaceBorder)) { - TChunksToDefrag chunksToDefrag = calcStat.GetChunksToDefrag(DCtx->MaxChunksToDefrag); + TChunksToDefrag chunksToDefrag = calcStat.GetChunksToDefrag(MaxInflyghtDefragChunks(oos, DCtx->MaxChunksToDefrag)); Y_ABORT_UNLESS(chunksToDefrag); STLOG(PRI_INFO, BS_VDISK_DEFRAG, BSVDD03, VDISKP(DCtx->VCtx->VDiskLogPrefix, "scan finished"), (TotalChunks, totalChunks), (UsefulChunks, usefulChunks),