Fix GC Tuner when memory is too large (#20353)

Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com>

Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com>
pull/20370/head
Xiaofan 2022-11-07 12:17:05 +08:00 committed by GitHub
parent a4b3a53123
commit 3f67fad59a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -60,11 +60,16 @@ func optimizeGOGC() {
totaluse := hardware.GetUsedMemoryCount()
heapTarget := memoryThreshold - (totaluse - heapuse)
newGoGC := uint32(math.Floor(float64(heapTarget-heapuse) / float64(heapuse) * 100))
if newGoGC < minGOGC {
var newGoGC uint32
if heapTarget < heapuse {
newGoGC = minGOGC
} else if newGoGC > maxGOGC {
newGoGC = maxGOGC
} else {
newGoGC = uint32(math.Floor(float64(heapTarget-heapuse) / float64(heapuse) * 100))
if newGoGC < minGOGC {
newGoGC = minGOGC
} else if newGoGC > maxGOGC {
newGoGC = maxGOGC
}
}
action(newGoGC)