Skip to content

Commit

Permalink
*: Change cpu usages related representation format (#56044)
Browse files Browse the repository at this point in the history
ref #55542
  • Loading branch information
yibin87 committed Sep 14, 2024
1 parent 3688a2b commit a21d9ea
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/executor/slow_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func TestParseSlowLogFile(t *testing.T) {
# Request_unit_read: 2.158
# Request_unit_write: 2.123
# Time_queued_by_rc: 0.05
# Tidb_cpu_usage: 0.01
# Tikv_cpu_usage: 0.021
# Tidb_cpu_time: 0.01
# Tikv_cpu_time: 0.021
# Plan_digest: 60e9378c746d9a2be1c791047e008967cf252eb6de9167ad3aa6098fa2d523f4
# Prev_stmt: update t set i = 1;
use test;
Expand Down
4 changes: 2 additions & 2 deletions pkg/infoschema/internal/testkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ select * from t_slim;
# Resource_group: rg1
# Request_unit_read: 96.66703066666668
# Request_unit_write: 3182.424414062492
# Tidb_cpu_usage: 0.01
# Tikv_cpu_usage: 0.021
# Tidb_cpu_time: 0.01
# Tikv_cpu_time: 0.021
INSERT INTO ...;
`)
require.NoError(t, f.Close())
Expand Down
4 changes: 2 additions & 2 deletions pkg/infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,8 @@ var tableProcesslistCols = []columnInfo{
{name: "RESOURCE_GROUP", tp: mysql.TypeVarchar, size: resourcegroup.MaxGroupNameLength, flag: mysql.NotNullFlag, deflt: ""},
{name: "SESSION_ALIAS", tp: mysql.TypeVarchar, size: 64, flag: mysql.NotNullFlag, deflt: ""},
{name: "ROWS_AFFECTED", tp: mysql.TypeLonglong, size: 21, flag: mysql.UnsignedFlag},
{name: "TIDB_CPU", tp: mysql.TypeDouble, size: 22, flag: mysql.NotNullFlag, deflt: 0},
{name: "TIKV_CPU", tp: mysql.TypeDouble, size: 22, flag: mysql.NotNullFlag, deflt: 0},
{name: "TIDB_CPU", tp: mysql.TypeLonglong, size: 21, flag: mysql.NotNullFlag, deflt: 0},
{name: "TIKV_CPU", tp: mysql.TypeLonglong, size: 21, flag: mysql.NotNullFlag, deflt: 0},
}

var tableTiDBIndexesCols = []columnInfo{
Expand Down
4 changes: 2 additions & 2 deletions pkg/infoschema/test/clustertablestest/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ func TestInfoSchemaFieldValue(t *testing.T) {
" `RESOURCE_GROUP` varchar(32) NOT NULL DEFAULT '',\n" +
" `SESSION_ALIAS` varchar(64) NOT NULL DEFAULT '',\n" +
" `ROWS_AFFECTED` bigint(21) unsigned DEFAULT NULL,\n" +
" `TIDB_CPU` double NOT NULL DEFAULT '0',\n" +
" `TIKV_CPU` double NOT NULL DEFAULT '0'\n" +
" `TIDB_CPU` bigint(21) NOT NULL DEFAULT '0',\n" +
" `TIKV_CPU` bigint(21) NOT NULL DEFAULT '0'\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))
tk.MustQuery("show create table information_schema.cluster_log").Check(
testkit.Rows("" +
Expand Down
4 changes: 2 additions & 2 deletions pkg/sessionctx/variable/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -3331,9 +3331,9 @@ const (
// SlowLogWaitRUDuration is the total duration for kv requests to wait available request-units.
SlowLogWaitRUDuration = "Time_queued_by_rc"
// SlowLogTidbCPUUsageDuration is the total tidb cpu usages.
SlowLogTidbCPUUsageDuration = "Tidb_cpu_usage"
SlowLogTidbCPUUsageDuration = "Tidb_cpu_time"
// SlowLogTikvCPUUsageDuration is the total tikv cpu usages.
SlowLogTikvCPUUsageDuration = "Tikv_cpu_usage"
SlowLogTikvCPUUsageDuration = "Tikv_cpu_time"
)

// GenerateBinaryPlan decides whether we should record binary plan in slow log and stmt summary.
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/processinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (pi *ProcessInfo) ToRow(tz *time.Location) []any {
cpuUsages = pi.SQLCPUUsage.GetCPUUsages()
}
return append(pi.ToRowForShow(true), pi.Digest, bytesConsumed, diskConsumed,
pi.txnStartTs(tz), pi.ResourceGroupName, pi.SessionAlias, affectedRows, cpuUsages.TidbCPUTime.Seconds(), cpuUsages.TikvCPUTime.Seconds())
pi.txnStartTs(tz), pi.ResourceGroupName, pi.SessionAlias, affectedRows, cpuUsages.TidbCPUTime.Nanoseconds(), cpuUsages.TikvCPUTime.Nanoseconds())
}

// ascServerStatus is a slice of all defined server status in ascending order.
Expand Down

0 comments on commit a21d9ea

Please sign in to comment.