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: Revise SimpleLRUCache Configuration #17532

Merged
merged 12 commits into from
Jun 18, 2020
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,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"`
StatsLease string `toml:"stats-lease" json:"stats-lease"`
StmtCountLimit uint `toml:"stmt-count-limit" json:"stmt-count-limit"`
FeedbackProbability float64 `toml:"feedback-probability" json:"feedback-probability"`
Expand Down Expand Up @@ -603,6 +604,7 @@ var defaultConf = Config{
},
Performance: Performance{
MaxMemory: 0,
ServerMemoryQuota: 0,
TCPKeepAlive: true,
CrossJoin: true,
StatsLease: "3s",
Expand Down
3 changes: 3 additions & 0 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,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
Yisaer marked this conversation as resolved.
Show resolved Hide resolved
server-memory-quota = 0

# StmtCountLimit limits the max count of statement inside a transaction.
stmt-count-limit = 5000

Expand Down
4 changes: 2 additions & 2 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,11 +604,11 @@ func setGlobalVars() {
domainutil.RepairInfo.SetRepairTableList(cfg.RepairTableList)
c := config.GetGlobalConfig()
executor.GlobalDiskUsageTracker.SetBytesLimit(c.TempStorageQuota)
if c.Performance.MaxMemory < 1 {
if c.Performance.ServerMemoryQuota < 1 {
// If MaxMemory equals 0, it means unlimited
executor.GlobalMemoryUsageTracker.SetBytesLimit(-1)
} else {
executor.GlobalMemoryUsageTracker.SetBytesLimit(int64(c.Performance.MaxMemory))
executor.GlobalMemoryUsageTracker.SetBytesLimit(int64(c.Performance.ServerMemoryQuota))
}
kvcache.GlobalLRUMemUsageTracker.AttachToGlobalTracker(executor.GlobalMemoryUsageTracker)
}
Expand Down