Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables: enhance tidb_enable_gc_tuner #40850

Merged
merged 4 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import (
"github.com/pingcap/tidb/util/engine"
"github.com/pingcap/tidb/util/etcd"
"github.com/pingcap/tidb/util/expensivequery"
"github.com/pingcap/tidb/util/gctuner"
"github.com/pingcap/tidb/util/logutil"
"github.com/pingcap/tidb/util/memory"
"github.com/pingcap/tidb/util/memoryusagealarm"
Expand Down Expand Up @@ -2110,7 +2111,9 @@ func (do *Domain) updateStatsWorker(ctx sessionctx.Context, owner owner.Manager)
}

case <-readMemTricker.C:
memory.ForceReadMemStats()
if gctuner.EnableGOGCTuner.Load() {
TonsnakeLin marked this conversation as resolved.
Show resolved Hide resolved
memory.ForceReadMemStats()
}
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions util/gctuner/tuner.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,18 @@ func (t *tuner) getGCPercent() uint32 {
// tuning check the memory inuse and tune GC percent dynamically.
// Go runtime ensure that it will be called serially.
func (t *tuner) tuning() {
if EnableGOGCTuner.Load() {
return
}

inuse := readMemoryInuse()
threshold := t.getThreshold()
// stop gc tuning
if threshold <= 0 {
return
}
if EnableGOGCTuner.Load() {
t.setGCPercent(calcGCPercent(inuse, threshold))
}

t.setGCPercent(calcGCPercent(inuse, threshold))
}

// threshold = inuse + inuse * (gcPercent / 100)
Expand Down