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
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: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
hawkingrei marked this conversation as resolved.
Show resolved Hide resolved
memTotal, err = memory.MemTotal()
if err != nil {
return err
}
}
if factor > 0 {
threshold := float64(memTotal) * factor
gctuner.Tuning(uint64(threshold))
}
return nil
},
},
Expand Down