github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/compactor/settings.go (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package compactor 12 13 import ( 14 "time" 15 16 "github.com/cockroachdb/cockroach/pkg/settings" 17 "github.com/cockroachdb/errors" 18 ) 19 20 func validateFraction(v float64) error { 21 if v >= 0 && v <= 1 { // handles +-Inf, Nan 22 return nil 23 } 24 return errors.Errorf("value %v not between zero and one", v) 25 } 26 27 var enabled = settings.RegisterBoolSetting( 28 "compactor.enabled", 29 "when false, the system will reclaim space occupied by deleted data less aggressively", 30 true, 31 ) 32 33 // minInterval indicates the minimum period of 34 // time to wait before any compaction activity is considered, after 35 // suggestions are made. The intent is to allow sufficient time for 36 // all ranges to be cleared when a big table is dropped, so the 37 // compactor can determine contiguous stretches and efficient delete 38 // sstable files. 39 var minInterval = settings.RegisterDurationSetting( 40 "compactor.min_interval", 41 "minimum time interval to wait before compacting", 42 15*time.Second, 43 ) 44 45 // thresholdBytes is the threshold in bytes of suggested 46 // reclamation, after which the compactor will begin processing 47 // (taking compactor min interval into account). Note that we want 48 // to target roughly the target size of an L6 SSTable (128MB) but 49 // these are logical bytes (as in, from MVCCStats) which can't be 50 // translated into SSTable-bytes. As a result, we conservatively set 51 // a higher threshold. 52 var thresholdBytes = settings.RegisterByteSizeSetting( 53 "compactor.threshold_bytes", 54 "minimum expected logical space reclamation required before considering an aggregated suggestion", 55 256<<20, // more than 256MiB will trigger 56 ) 57 58 // thresholdBytesUsedFraction is the fraction of total logical 59 // bytes used which are up for suggested reclamation, after which 60 // the compactor will begin processing (taking compactor min 61 // interval into account). Note that this threshold handles the case 62 // where a table is dropped which is a significant fraction of the 63 // total space in the database, but does not exceed the absolute 64 // defaultThresholdBytes threshold. 65 var thresholdBytesUsedFraction = settings.RegisterValidatedFloatSetting( 66 "compactor.threshold_used_fraction", 67 "consider suggestions for at least the given percentage of the used logical space (zero to disable)", 68 0.10, // more than 10% of space will trigger 69 validateFraction, 70 ) 71 72 // thresholdBytesAvailableFraction is the fraction of remaining 73 // available space on a disk, which, if exceeded by the size of a suggested 74 // compaction, should trigger the processing of said compaction. This 75 // threshold is meant to make compaction more aggressive when a store is 76 // nearly full, since reclaiming space is much more important in such 77 // scenarios. ThresholdBytesAvailableFraction() float64 78 var thresholdBytesAvailableFraction = settings.RegisterValidatedFloatSetting( 79 "compactor.threshold_available_fraction", 80 "consider suggestions for at least the given percentage of the available logical space (zero to disable)", 81 0.10, // more than 10% of space will trigger 82 validateFraction, 83 ) 84 85 // maxSuggestedCompactionRecordAge is the maximum age of a 86 // suggested compaction record. If not processed within this time 87 // interval since the compaction was suggested, it will be deleted. 88 var maxSuggestedCompactionRecordAge = settings.RegisterNonNegativeDurationSetting( 89 "compactor.max_record_age", 90 "discard suggestions not processed within this duration", 91 24*time.Hour, 92 )