MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / UpdateCacheMb

Function UpdateCacheMb

worker/worker.go:138–164  ·  view source on GitHub ↗

UpdateCacheMb updates the value of cache_mb and updates the corresponding cache sizes.

(memoryMB int64)

Source from the content-addressed store, hash-verified

136
137// UpdateCacheMb updates the value of cache_mb and updates the corresponding cache sizes.
138func 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.
167func UpdateLogDQLRequest(val bool) {

Callers 1

resolveUpdateConfigFunction · 0.92

Calls 4

GetCachePercentagesFunction · 0.92
InfofMethod · 0.80
UpdateMaxCostMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected