github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/tae/testutils/config/options.go (about) 1 // Copyright 2021 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package config 16 17 import ( 18 "context" 19 "time" 20 21 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/options" 22 ) 23 24 type CacheSizeType uint8 25 26 const ( 27 CST_None CacheSizeType = iota 28 CST_Customize 29 ) 30 31 func WithQuickScanAndCKPOpts2(in *options.Options, factor int) (opts *options.Options) { 32 opts = WithQuickScanAndCKPOpts(in) 33 opts.CheckpointCfg.ScanInterval *= time.Duration(factor) 34 opts.CheckpointCfg.FlushInterval *= time.Duration(factor) 35 opts.CheckpointCfg.MinCount = int64(factor) 36 opts.CheckpointCfg.IncrementalInterval *= time.Duration(factor) 37 opts.CheckpointCfg.BlockRows = 10 38 opts.Ctx = context.Background() 39 return opts 40 } 41 42 func WithQuickScanAndCKPOpts(in *options.Options) (opts *options.Options) { 43 if in == nil { 44 opts = new(options.Options) 45 } else { 46 opts = in 47 } 48 opts.CheckpointCfg = new(options.CheckpointCfg) 49 opts.CheckpointCfg.ScanInterval = time.Millisecond * 10 50 opts.CheckpointCfg.FlushInterval = time.Millisecond * 10 51 opts.CheckpointCfg.MinCount = 1 52 opts.CheckpointCfg.IncrementalInterval = time.Millisecond * 20 53 opts.CheckpointCfg.GlobalMinCount = 1 54 opts.CheckpointCfg.GCCheckpointInterval = time.Millisecond * 10 55 opts.CheckpointCfg.BlockRows = 10 56 opts.CheckpointCfg.GlobalVersionInterval = time.Millisecond * 10 57 opts.GCCfg = new(options.GCCfg) 58 opts.GCCfg.ScanGCInterval = time.Millisecond * 10 59 opts.GCCfg.GCTTL = time.Millisecond * 1 60 opts.CatalogCfg = new(options.CatalogCfg) 61 opts.CatalogCfg.GCInterval = time.Millisecond * 1 62 opts.Ctx = context.Background() 63 return opts 64 } 65 66 func WithQuickScanAndCKPAndGCOpts(in *options.Options) (opts *options.Options) { 67 if in == nil { 68 opts = new(options.Options) 69 } else { 70 opts = in 71 } 72 opts.CheckpointCfg = new(options.CheckpointCfg) 73 opts.CheckpointCfg.ScanInterval = time.Millisecond * 10 74 opts.CheckpointCfg.FlushInterval = time.Millisecond * 10 75 opts.CheckpointCfg.MinCount = 1 76 opts.CheckpointCfg.IncrementalInterval = time.Millisecond * 20 77 opts.CheckpointCfg.GlobalMinCount = 1 78 opts.CheckpointCfg.BlockRows = 10 79 80 opts.GCCfg = new(options.GCCfg) 81 // ScanGCInterval does not need to be too fast, because manual gc will be performed in the case 82 opts.GCCfg.ScanGCInterval = time.Second * 10 83 opts.CatalogCfg = new(options.CatalogCfg) 84 opts.CatalogCfg.GCInterval = time.Millisecond * 1 85 opts.GCCfg.GCTTL = time.Millisecond * 1 86 opts.Ctx = context.Background() 87 return opts 88 } 89 90 func WithOpts(in *options.Options, factor float64) (opts *options.Options) { 91 if in == nil { 92 opts = new(options.Options) 93 } else { 94 opts = in 95 } 96 opts.CheckpointCfg = new(options.CheckpointCfg) 97 opts.CheckpointCfg.ScanInterval = time.Second * time.Duration(factor) 98 opts.CheckpointCfg.FlushInterval = time.Second * time.Duration(factor) 99 opts.CheckpointCfg.MinCount = 1 * int64(factor) 100 opts.CheckpointCfg.IncrementalInterval = time.Second * 2 * time.Duration(factor) 101 opts.CheckpointCfg.GlobalMinCount = 10 102 opts.CheckpointCfg.BlockRows = 10 103 opts.Ctx = context.Background() 104 return opts 105 } 106 107 func WithLongScanAndCKPOpts(in *options.Options) (opts *options.Options) { 108 if in == nil { 109 opts = new(options.Options) 110 } else { 111 opts = in 112 } 113 opts.CheckpointCfg = new(options.CheckpointCfg) 114 opts.CheckpointCfg.ScanInterval = time.Hour 115 opts.CheckpointCfg.MinCount = 100000000 116 opts.CheckpointCfg.IncrementalInterval = time.Hour 117 opts.CheckpointCfg.GlobalMinCount = 10000000 118 opts.CheckpointCfg.BlockRows = 10 119 opts.Ctx = context.Background() 120 return opts 121 } 122 123 func WithLongScanAndCKPOptsAndQuickGC(in *options.Options) (opts *options.Options) { 124 if in == nil { 125 opts = new(options.Options) 126 } else { 127 opts = in 128 } 129 opts.CheckpointCfg = new(options.CheckpointCfg) 130 opts.CheckpointCfg.ScanInterval = time.Hour 131 opts.CheckpointCfg.MinCount = 100000000 132 opts.CheckpointCfg.IncrementalInterval = time.Hour 133 opts.CheckpointCfg.GlobalMinCount = 10000000 134 opts.CheckpointCfg.BlockRows = 10 135 opts.GCCfg = new(options.GCCfg) 136 opts.GCCfg.ScanGCInterval = time.Second * 1 137 opts.GCCfg.GCTTL = time.Millisecond * 1 138 opts.Ctx = context.Background() 139 return opts 140 }