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 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
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:"-" json:"-"`
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
9 changes: 8 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,16 @@ receiver-address = "127.0.0.1:10100"
require.Equal(t, "127.0.0.1:10100", conf.TopSQL.ReceiverAddress)
require.True(t, conf.Experimental.AllowsExpressionIndex)

err = f.Truncate(0)
require.NoError(t, err)
_, err = f.Seek(0, 0)
require.NoError(t, err)
require.NoError(t, f.Sync())
_, err = f.WriteString(`
[log.file]
log-rotate = true`)
log-rotate = true
[performance]
mem-profile-interval="1m"`)
require.NoError(t, err)
err = conf.Load(configFile)
tmp := err.(*ErrConfigValidationFailed)
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
15 changes: 0 additions & 15 deletions util/profile/flamegraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,6 @@ func (n *flamegraphNode) add(sample *profile.Sample) {
}
}

// collectFuncUsage collect the value by given function name
func (n *flamegraphNode) collectFuncUsage(name string) int64 {
if n.name == name {
return n.cumValue
}
if len(n.children) == 0 {
return 0
}
var usage int64 = 0
for _, child := range n.children {
usage = child.collectFuncUsage(name) + usage
}
return usage
}

type flamegraphNodeWithLocation struct {
*flamegraphNode
locID uint64
Expand Down
22 changes: 0 additions & 22 deletions util/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,3 @@ func (c *Collector) ParseGoroutines(reader io.Reader) ([][]types.Datum, error) {
}
return rows, nil
}

// getFuncMemUsage get function memory usage from heap profile
func (c *Collector) getFuncMemUsage(name string) (int64, error) {
prof := pprof.Lookup("heap")
if prof == nil {
return 0, errors.Errorf("cannot retrieve %s profile", name)
}
debug := 0
buffer := &bytes.Buffer{}
if err := prof.WriteTo(buffer, debug); err != nil {
return 0, err
}
p, err := profile.Parse(buffer)
if err != nil {
return 0, err
}
root, err := c.profileToFlamegraphNode(p)
if err != nil {
return 0, err
}
return root.collectFuncUsage(name), nil
}
53 changes: 0 additions & 53 deletions util/profile/trackerRecorder.go

This file was deleted.

88 changes: 0 additions & 88 deletions util/profile/trackerrecorder_test.go

This file was deleted.