@@ -16,12 +16,14 @@ namespace NKikimr {
16
16
// //////////////////////////////////////////////////////////////////////////
17
17
TDefragCtx::TDefragCtx (
18
18
const TIntrusivePtr<TVDiskContext> &vctx,
19
+ const TIntrusivePtr<TVDiskConfig> &vconfig,
19
20
const std::shared_ptr<THugeBlobCtx> &hugeBlobCtx,
20
21
const TPDiskCtxPtr &pdiskCtx,
21
22
const TActorId &skeletonId,
22
23
const TActorId &hugeKeeperId,
23
24
bool runDefrageBySchedule)
24
25
: VCtx(vctx)
26
+ , VCfg(vconfig)
25
27
, HugeBlobCtx(hugeBlobCtx)
26
28
, PDiskCtx(pdiskCtx)
27
29
, SkeletonId(skeletonId)
@@ -48,19 +50,23 @@ namespace NKikimr {
48
50
bool HugeHeapDefragmentationRequired (
49
51
const TOutOfSpaceState& oos,
50
52
ui32 hugeCanBeFreedChunks,
51
- ui32 hugeTotalChunks) {
53
+ ui32 hugeTotalChunks,
54
+ double defaultPercent) {
52
55
53
56
if (hugeCanBeFreedChunks < 10 )
54
57
return false ;
55
58
56
59
double percentOfGarbage = static_cast <double >(hugeCanBeFreedChunks) / hugeTotalChunks;
57
60
58
61
if (oos.GetLocalColor () > TSpaceColor::CYAN) {
59
- return percentOfGarbage >= 0.02 ;
62
+ // For anything worse than CYAN
63
+ return percentOfGarbage >= Min (0.02 , defaultPercent);
60
64
} else if (oos.GetLocalColor () > TSpaceColor::GREEN) {
61
- return percentOfGarbage >= 0.15 ;
65
+ // For CYAN
66
+ return percentOfGarbage >= Min (0.15 , defaultPercent);
62
67
} else {
63
- return percentOfGarbage >= 0.30 ;
68
+ // For GREEN
69
+ return percentOfGarbage >= Min (0.30 , defaultPercent);
64
70
}
65
71
}
66
72
@@ -113,7 +119,8 @@ namespace NKikimr {
113
119
const auto & oos = DCtx->VCtx ->GetOutOfSpaceState ();
114
120
Y_ABORT_UNLESS (usefulChunks <= totalChunks);
115
121
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)) {
117
124
TChunksToDefrag chunksToDefrag = calcStat.GetChunksToDefrag (DCtx->MaxChunksToDefrag );
118
125
Y_ABORT_UNLESS (chunksToDefrag);
119
126
STLOG (PRI_INFO, BS_VDISK_DEFRAG, BSVDD03, VDISKP (DCtx->VCtx ->VDiskLogPrefix , " scan finished" ),
0 commit comments