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

sessionctx: fix tidb_gogc_tuner_threshold #38851

Merged
merged 8 commits into from
Nov 3, 2022
8 changes: 7 additions & 1 deletion sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,16 @@ var defaultSysVars = []*SysVar{
}
return strconv.FormatFloat(floatValue, 'f', -1, 64), nil
},
SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
SetGlobal: func(_ context.Context, s *SessionVars, val string) (err error) {
factor := tidbOptFloat64(val, DefTiDBGOGCTunerThreshold)
GOGCTunerThreshold.Store(factor)
memTotal := memory.ServerMemoryLimit.Load()
if memTotal == 0 {
hawkingrei marked this conversation as resolved.
Show resolved Hide resolved
memTotal, err = memory.MemTotal()
if err != nil {
return err
}
}
threshold := float64(memTotal) * factor
gctuner.Tuning(uint64(threshold))
return nil
Expand Down