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

config: add GOGC under performance section (#20872) #20922

Merged
merged 6 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ type Performance struct {
DistinctAggPushDown bool `toml:"distinct-agg-push-down" json:"agg-push-down-join"`
CommitterConcurrency int `toml:"committer-concurrency" json:"committer-concurrency"`
MaxTxnTTL uint64 `toml:"max-txn-ttl" json:"max-txn-ttl"`
GOGC int `toml:"gogc" json:"gogc"`
}

// PlanCache is the PlanCache section of the config.
Expand Down Expand Up @@ -627,6 +628,7 @@ var defaultConf = Config{
DistinctAggPushDown: false,
CommitterConcurrency: 16,
MaxTxnTTL: 10 * 60 * 1000, // 10min
GOGC: 100,
},
ProxyProtocol: ProxyProtocol{
Networks: "",
Expand Down
5 changes: 5 additions & 0 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ committer-concurrency = 16
# max lifetime of transaction ttl manager.
max-txn-ttl = 600000

# The Go GC trigger factor, you can get more information about it at https://golang.org/pkg/runtime.
# If you encounter OOM when executing large query, you can decrease this value to trigger GC earlier.
# If you find the CPU used by GC is too high or GC is too frequent and impact your business you can increase this value.
gogc = 100

[proxy-protocol]
# PROXY protocol acceptable client networks.
# Empty string means disable PROXY protocol, * means all networks.
Expand Down
2 changes: 2 additions & 0 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ func setGlobalVars() {
runtime.GOMAXPROCS(int(cfg.Performance.MaxProcs))
metrics.MaxProcs.Set(float64(runtime.GOMAXPROCS(0)))

util.SetGOGC(cfg.Performance.GOGC)

ddlLeaseDuration := parseDuration(cfg.Lease)
session.SetSchemaLease(ddlLeaseDuration)
statsLeaseDuration := parseDuration(cfg.Performance.StatsLease)
Expand Down
3 changes: 3 additions & 0 deletions util/gogc.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func init() {

// SetGOGC update GOGC and related metrics.
func SetGOGC(val int) {
if val <= 0 {
val = 100
}
debug.SetGCPercent(val)
metrics.GOGC.Set(float64(val))
atomic.StoreInt64(&gogcValue, int64(val))
Expand Down