UpdateCacheMb updates the value of cache_mb and updates the corresponding cache sizes.
(memoryMB int64)
| 136 | |
| 137 | // UpdateCacheMb updates the value of cache_mb and updates the corresponding cache sizes. |
| 138 | func UpdateCacheMb(memoryMB int64) error { |
| 139 | glog.Infof("Updating cacheMb to %d", memoryMB) |
| 140 | if memoryMB < 0 { |
| 141 | return errors.Errorf("cache_mb must be non-negative") |
| 142 | } |
| 143 | |
| 144 | cachePercent, err := x.GetCachePercentages(Config.CachePercentage, 3) |
| 145 | if err != nil { |
| 146 | return err |
| 147 | } |
| 148 | plCacheSize := (cachePercent[0] * (memoryMB << 20)) / 100 |
| 149 | blockCacheSize := (cachePercent[1] * (memoryMB << 20)) / 100 |
| 150 | indexCacheSize := (cachePercent[2] * (memoryMB << 20)) / 100 |
| 151 | |
| 152 | if posting.MemLayerInstance != nil { |
| 153 | posting.MemLayerInstance.UpdateMaxCost(plCacheSize) |
| 154 | } |
| 155 | if _, err := pstore.CacheMaxCost(badger.BlockCache, blockCacheSize); err != nil { |
| 156 | return errors.Wrapf(err, "cannot update block cache size") |
| 157 | } |
| 158 | if _, err := pstore.CacheMaxCost(badger.IndexCache, indexCacheSize); err != nil { |
| 159 | return errors.Wrapf(err, "cannot update index cache size") |
| 160 | } |
| 161 | |
| 162 | Config.CacheMb = memoryMB |
| 163 | return nil |
| 164 | } |
| 165 | |
| 166 | // UpdateLogDQLRequest updates value of x.WorkerConfig.LogDQLRequest. |
| 167 | func UpdateLogDQLRequest(val bool) { |
no test coverage detected