@@ -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" ),
0 commit comments