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

*: remove unused profile memory tracker from global tracker #30143

Merged
merged 8 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
41 changes: 21 additions & 20 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,12 @@ type Performance struct {
DistinctAggPushDown bool `toml:"distinct-agg-push-down" json:"distinct-agg-push-down"`
CommitterConcurrency int `toml:"committer-concurrency" json:"committer-concurrency"`
MaxTxnTTL uint64 `toml:"max-txn-ttl" json:"max-txn-ttl"`
MemProfileInterval string `toml:"mem-profile-interval" json:"mem-profile-interval"`
IndexUsageSyncLease string `toml:"index-usage-sync-lease" json:"index-usage-sync-lease"`
PlanReplayerGCLease string `toml:"plan-replayer-gc-lease" json:"plan-replayer-gc-lease"`
GOGC int `toml:"gogc" json:"gogc"`
EnforceMPP bool `toml:"enforce-mpp" json:"enforce-mpp"`
// Deprecated
MemProfileInterval string `toml:"mem-profile-interval" json:"mem-profile-interval"`
IndexUsageSyncLease string `toml:"index-usage-sync-lease" json:"index-usage-sync-lease"`
PlanReplayerGCLease string `toml:"plan-replayer-gc-lease" json:"plan-replayer-gc-lease"`
GOGC int `toml:"gogc" json:"gogc"`
EnforceMPP bool `toml:"enforce-mpp" json:"enforce-mpp"`
}

// PlanCache is the PlanCache section of the config.
Expand Down Expand Up @@ -647,7 +648,6 @@ var defaultConf = Config{
DistinctAggPushDown: false,
CommitterConcurrency: defTiKVCfg.CommitterConcurrency,
MaxTxnTTL: defTiKVCfg.MaxTxnTTL, // 1hour
MemProfileInterval: "1m",
// TODO: set indexUsageSyncLease to 60s.
IndexUsageSyncLease: "0s",
GOGC: 100,
Expand Down Expand Up @@ -738,20 +738,21 @@ func StoreGlobalConfig(config *Config) {
}

var deprecatedConfig = map[string]struct{}{
"pessimistic-txn.ttl": {},
"pessimistic-txn.enable": {},
"log.file.log-rotate": {},
"log.log-slow-query": {},
"txn-local-latches": {},
"txn-local-latches.enabled": {},
"txn-local-latches.capacity": {},
"performance.max-memory": {},
"max-txn-time-use": {},
"experimental.allow-auto-random": {},
"enable-redact-log": {}, // use variable tidb_redact_log instead
"tikv-client.copr-cache.enable": {},
"alter-primary-key": {}, // use NONCLUSTERED keyword instead
"enable-streaming": {},
"pessimistic-txn.ttl": {},
"pessimistic-txn.enable": {},
"log.file.log-rotate": {},
"log.log-slow-query": {},
"txn-local-latches": {},
"txn-local-latches.enabled": {},
"txn-local-latches.capacity": {},
"performance.max-memory": {},
"max-txn-time-use": {},
"experimental.allow-auto-random": {},
"enable-redact-log": {}, // use variable tidb_redact_log instead
"tikv-client.copr-cache.enable": {},
"alter-primary-key": {}, // use NONCLUSTERED keyword instead
"enable-streaming": {},
"performance.mem-profile-interval": {},
}

func isAllDeprecatedConfigItems(items []string) bool {
Expand Down
3 changes: 0 additions & 3 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,6 @@ committer-concurrency = 128
# max lifetime of transaction ttl manager.
max-txn-ttl = 3600000

# the interval duration between two memory profile into global tracker
mem-profile-interval = "1m"

# The Go GC trigger factor, you can get more information about it at https://golang.org/pkg/runtime.
# If you encounter OOM when executing large query, you can decrease this value to trigger GC earlier.
# If you find the CPU used by GC is too high or GC is too frequent and impact your business you can increase this value.
Expand Down
8 changes: 0 additions & 8 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ import (
"github.com/pingcap/tidb/util/logutil"
"github.com/pingcap/tidb/util/memory"
"github.com/pingcap/tidb/util/printer"
"github.com/pingcap/tidb/util/profile"
"github.com/pingcap/tidb/util/sem"
"github.com/pingcap/tidb/util/signal"
"github.com/pingcap/tidb/util/sys/linux"
Expand Down Expand Up @@ -191,7 +190,6 @@ func main() {
setGlobalVars()
setCPUAffinity()
setupLog()
setHeapProfileTracker()
setupTracing() // Should before createServer and after setup config.
printInfo()
setupBinlogClient()
Expand Down Expand Up @@ -275,12 +273,6 @@ func setCPUAffinity() {
metrics.MaxProcs.Set(float64(runtime.GOMAXPROCS(0)))
}

func setHeapProfileTracker() {
c := config.GetGlobalConfig()
d := parseDuration(c.Performance.MemProfileInterval)
go profile.HeapProfileForGlobalMemTracker(d)
}

func registerStores() {
err := kvstore.Register("tikv", driver.TiKVDriver{})
terror.MustNil(err)
Expand Down
8 changes: 4 additions & 4 deletions util/profile/trackerRecorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ import (
var col = &Collector{}

// HeapProfileForGlobalMemTracker record heap profile data into each global function memory tracker
func HeapProfileForGlobalMemTracker(d time.Duration) {
func HeapProfileForGlobalMemTracker(profileName string, d time.Duration) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this function be deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

log.Info("Mem Profile Tracker started")
t := time.NewTicker(d)
defer t.Stop()
for {
<-t.C
err := heapProfileForGlobalMemTracker()
err := heapProfileForGlobalMemTracker(profileName)
if err != nil {
log.Warn("profile memory into tracker failed", zap.Error(err))
}
}
}

func heapProfileForGlobalMemTracker() error {
bytes, err := col.getFuncMemUsage(kvcache.ProfileName)
func heapProfileForGlobalMemTracker(profileName string) error {
bytes, err := col.getFuncMemUsage(profileName)
if err != nil {
return err
}
Expand Down
88 changes: 0 additions & 88 deletions util/profile/trackerrecorder_test.go

This file was deleted.