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

planner: move more methods from StatsHandle to its sub-packages #47760

Merged
merged 13 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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 pkg/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,7 @@ func quitStatsOwner(do *Domain, mgr owner.Manager) {
func (do *Domain) StartLoadStatsSubWorkers(ctxList []sessionctx.Context) {
statsHandle := do.StatsHandle()
for i, ctx := range ctxList {
statsHandle.StatsLoad.SubCtxs[i] = ctx
statsHandle.SetSubCtxs(i, ctx)
do.wg.Add(1)
go statsHandle.SubLoadWorker(ctx, do.exit, do.wg)
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/statistics/handle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ go_library(
"//pkg/ddl/util",
"//pkg/infoschema",
"//pkg/kv",
"//pkg/metrics",
"//pkg/parser/ast",
"//pkg/parser/model",
"//pkg/parser/mysql",
Expand All @@ -31,14 +30,13 @@ go_library(
"//pkg/statistics/handle/history",
"//pkg/statistics/handle/lockstats",
"//pkg/statistics/handle/storage",
"//pkg/statistics/handle/syncload",
"//pkg/statistics/handle/usage",
"//pkg/statistics/handle/util",
"//pkg/types",
"//pkg/util",
"//pkg/util/chunk",
"//pkg/util/logutil",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_tiancaiamao_gp//:gp",
"@org_uber_go_atomic//:atomic",
"@org_uber_go_zap//:zap",
Expand Down
15 changes: 5 additions & 10 deletions pkg/statistics/handle/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
package handle

import (
"github.com/pingcap/tidb/pkg/statistics/handle/syncload"
hawkingrei marked this conversation as resolved.
Show resolved Hide resolved
"math"
"time"

"github.com/pingcap/tidb/pkg/config"
ddlUtil "github.com/pingcap/tidb/pkg/ddl/util"
"github.com/pingcap/tidb/pkg/infoschema"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/sessionctx/stmtctx"
"github.com/pingcap/tidb/pkg/statistics"
"github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze"
"github.com/pingcap/tidb/pkg/statistics/handle/cache"
Expand Down Expand Up @@ -73,6 +72,9 @@ type Handle struct {
// StatsAnalyze is used to handle auto-analyze and manage analyze jobs.
util.StatsAnalyze

// StatsSyncLoad is used to load stats syncly.
util.StatsSyncLoad

// StatsReadWriter is used to read/write stats from/to storage.
util.StatsReadWriter

Expand All @@ -94,9 +96,6 @@ type Handle struct {
// StatsCache ...
util.StatsCache

// StatsLoad is used to load stats concurrently
StatsLoad StatsLoad

lease atomic2.Duration
}

Expand All @@ -111,7 +110,6 @@ func (h *Handle) Clear() {

// NewHandle creates a Handle for update stats.
func NewHandle(_, initStatsCtx sessionctx.Context, lease time.Duration, pool util.SessionPool, tracker sessionctx.SysProcTracker, autoAnalyzeProcIDGetter func() uint64) (*Handle, error) {
cfg := config.GetGlobalConfig()
handle := &Handle{
gpool: gp.New(math.MaxInt16, time.Minute),
ddlEventCh: make(chan *ddlUtil.Event, 1000),
Expand All @@ -135,10 +133,7 @@ func NewHandle(_, initStatsCtx sessionctx.Context, lease time.Duration, pool uti
handle.StatsHistory = history.NewStatsHistory(handle)
handle.StatsUsage = usage.NewStatsUsageImpl(handle)
handle.StatsAnalyze = autoanalyze.NewStatsAnalyze(handle)
handle.StatsLoad.SubCtxs = make([]sessionctx.Context, cfg.Performance.StatsLoadConcurrency)
handle.StatsLoad.NeededItemsCh = make(chan *NeededItemTask, cfg.Performance.StatsLoadQueueSize)
handle.StatsLoad.TimeoutItemsCh = make(chan *NeededItemTask, cfg.Performance.StatsLoadQueueSize)
handle.StatsLoad.WorkingColMap = map[model.TableItemID][]chan stmtctx.StatsLoadResult{}
handle.StatsSyncLoad = syncload.NewStatsSyncLoad(handle)
return handle, nil
}

Expand Down
Loading