Skip to content

Commit

Permalink
add config item
Browse files Browse the repository at this point in the history
  • Loading branch information
wshwsh12 committed Oct 19, 2020
1 parent 31e7c44 commit 005258f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ type Status struct {
type Performance struct {
MaxProcs uint `toml:"max-procs" json:"max-procs"`
MaxMemory uint64 `toml:"max-memory" json:"max-memory"`
ServerMemoryQuota uint64 `toml:"server-memory-quota" json:"server-memory-quota"`
MemoryUsageAlarmRatio float64 `toml:"memory-usage-alarm-ratio" json:"memory-usage-alarm-ratio"`
StatsLease string `toml:"stats-lease" json:"stats-lease"`
StmtCountLimit uint `toml:"stmt-count-limit" json:"stmt-count-limit"`
Expand Down Expand Up @@ -610,6 +611,7 @@ var defaultConf = Config{
},
Performance: Performance{
MaxMemory: 0,
ServerMemoryQuota: 0,
MemoryUsageAlarmRatio: 0.8,
TCPKeepAlive: true,
CrossJoin: true,
Expand Down
3 changes: 3 additions & 0 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ max-procs = 0
# Max memory size to use, 0 use the total usable memory in the machine.
max-memory = 0

# Memory size quota for tidb server, 0 means unlimited
server-memory-quota = 0

# The alarm threshold when memory usage of the tidb-server exceeds. The valid value range is greater than or equal to 0
# and less than or equal to 1. The default value is 0.8.
# If this configuration is set to 0 or 1, it'll disable the alarm.
Expand Down
2 changes: 1 addition & 1 deletion util/expensivequery/memory_usage_alarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func initMemoryUsageAlarmRecord() (record *memoryUsageAlarm) {
record.err = errors.New("close memory usage alarm recorder")
return
}
if quota := config.GetGlobalConfig().Performance.MaxMemory; quota != 0 {
if quota := config.GetGlobalConfig().Performance.ServerMemoryQuota; quota != 0 {
record.serverMemoryQuota = quota
record.isServerMemoryQuotaSet = true
} else {
Expand Down

0 comments on commit 005258f

Please sign in to comment.