@@ -365,7 +365,7 @@ func (a *ExecStmt) PointGet(ctx context.Context) (*recordSet, error) {
365365 sessiontxn .AssertTxnManagerInfoSchema (a .Ctx , a .InfoSchema )
366366 })
367367
368- ctx = a .observeStmtBeginForTopSQL (ctx )
368+ ctx = a .observeStmtBeginForTopProfiling (ctx )
369369 startTs , err := sessiontxn .GetTxnManager (a .Ctx ).GetStmtReadTS ()
370370 if err != nil {
371371 return nil , err
@@ -638,7 +638,7 @@ func (a *ExecStmt) Exec(ctx context.Context) (_ sqlexec.RecordSet, err error) {
638638 stmtCtx .ResourceGroupName = switchGroupName
639639 }
640640 }
641- ctx = a .observeStmtBeginForTopSQL (ctx )
641+ ctx = a .observeStmtBeginForTopProfiling (ctx )
642642
643643 // Record start time before buildExecutor() to include TSO waiting time in maxExecutionTime timeout.
644644 // buildExecutor() may block waiting for TSO, so we should start the timer earlier.
@@ -1520,7 +1520,7 @@ func (a *ExecStmt) FinishExecuteStmt(txnTS uint64, err error, hasMoreResults boo
15201520 // `LowSlowQuery` and `SummaryStmt` must be called before recording `PrevStmt`.
15211521 a .LogSlowQuery (txnTS , succ , hasMoreResults )
15221522 a .SummaryStmt (succ )
1523- a .observeStmtFinishedForTopSQL ()
1523+ a .observeStmtFinishedForTopProfiling ()
15241524 a .UpdatePlanCacheRuntimeInfo ()
15251525 if sessVars .StmtCtx .IsTiFlash .Load () {
15261526 if succ {
@@ -2152,10 +2152,10 @@ func (a *ExecStmt) updatePrevStmt() {
21522152 }
21532153}
21542154
2155- func (a * ExecStmt ) observeStmtBeginForTopSQL (ctx context.Context ) context.Context {
2156- if ! topsqlstate .TopSQLEnabled () && IsFastPlan (a .Plan ) {
2155+ func (a * ExecStmt ) observeStmtBeginForTopProfiling (ctx context.Context ) context.Context {
2156+ if ! topsqlstate .TopProfilingEnabled () && IsFastPlan (a .Plan ) {
21572157 // To reduce the performance impact on fast plan.
2158- // Drop them does not cause notable accuracy issue in TopSQL .
2158+ // Drop them does not cause notable accuracy issue in Top Profiling .
21592159 return ctx
21602160 }
21612161
@@ -2171,8 +2171,9 @@ func (a *ExecStmt) observeStmtBeginForTopSQL(ctx context.Context) context.Contex
21712171 planDigestByte = planDigest .Bytes ()
21722172 }
21732173 stats := a .Ctx .GetStmtStats ()
2174- if ! topsqlstate .TopSQLEnabled () {
2175- // Always attach the SQL and plan info uses to catch the running SQL when Top SQL is enabled in execution.
2174+ if ! topsqlstate .TopProfilingEnabled () {
2175+ // Always attach the SQL and plan info uses to catch the running SQL when Top Profiling is enabled in execution.
2176+ // Note: Goroutine labels for CPU profiling are only set when TopSQL is enabled.
21762177 if stats != nil {
21772178 stats .OnExecutionBegin (sqlDigestByte , planDigestByte , vars .InPacketBytes .Load ())
21782179 }
@@ -2222,12 +2223,12 @@ func (a *ExecStmt) UpdatePlanCacheRuntimeInfo() {
22222223 a .Ctx .GetSessionVars ().PlanCacheValue = nil // reset
22232224}
22242225
2225- func (a * ExecStmt ) observeStmtFinishedForTopSQL () {
2226+ func (a * ExecStmt ) observeStmtFinishedForTopProfiling () {
22262227 vars := a .Ctx .GetSessionVars ()
22272228 if vars == nil {
22282229 return
22292230 }
2230- if stats := a .Ctx .GetStmtStats (); stats != nil && topsqlstate .TopSQLEnabled () {
2231+ if stats := a .Ctx .GetStmtStats (); stats != nil && topsqlstate .TopProfilingEnabled () {
22312232 sqlDigest , planDigest := a .getSQLPlanDigest ()
22322233 execDuration := vars .GetTotalCostDuration ()
22332234 stats .OnExecutionFinished (sqlDigest , planDigest , execDuration , vars .OutPacketBytes .Load ())
0 commit comments