sessionctx: fix tidb_gogc_tuner_threshold (#38851)

This commit is contained in:
Weizhen Wang
2022-11-03 18:32:01 +08:00
committed by GitHub
parent bc7d0aa935
commit fce4fda3a7
2 changed files with 12 additions and 4 deletions

View File

@ -415,7 +415,7 @@ bazel_coverage_test: failpoint-enable bazel_ci_prepare
bazel_build: bazel_ci_prepare
mkdir -p bin
bazel $(BAZEL_GLOBAL_CONFIG) build --remote_download_minimal $(BAZEL_CMD_CONFIG) \
bazel $(BAZEL_GLOBAL_CONFIG) build $(BAZEL_CMD_CONFIG) \
//... --//build:with_nogo_flag=true
bazel $(BAZEL_GLOBAL_CONFIG) build $(BAZEL_CMD_CONFIG) \
//cmd/importer:importer //tidb-server:tidb-server //tidb-server:tidb-server-check --//build:with_nogo_flag=true

View File

@ -748,12 +748,20 @@ 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()
threshold := float64(memTotal) * factor
gctuner.Tuning(uint64(threshold))
if memTotal == 0 {
memTotal, err = memory.MemTotal()
if err != nil {
return err
}
}
if factor > 0 {
threshold := float64(memTotal) * factor
gctuner.Tuning(uint64(threshold))
}
return nil
},
},