execdetails

package
v1.1.0-beta.0...-e2f85cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CopTimeStr represents the sum of cop-task time spend in TiDB distSQL.
	CopTimeStr = "Cop_time"
	// WaitTimeStr means the time of all coprocessor wait.
	WaitTimeStr = "Wait_time"
	// LockKeysTimeStr means the time interval between pessimistic lock wait start and lock got obtain
	LockKeysTimeStr = "LockKeys_time"
	// RequestCountStr means the request count.
	RequestCountStr = "Request_count"
	// ReadPoolTaskDetailsStr is the slow-query field name for read-pool task details.
	ReadPoolTaskDetailsStr = "Read_pool_task_details"
	// WaitPrewriteBinlogTimeStr means the time of waiting prewrite binlog finished when transaction committing.
	WaitPrewriteBinlogTimeStr = "Wait_prewrite_binlog_time"
	// GetCommitTSTimeStr means the time of getting commit ts.
	GetCommitTSTimeStr = "Get_commit_ts_time"
	// GetLatestTsTimeStr means the time of getting latest ts in async commit and 1pc.
	GetLatestTsTimeStr = "Get_latest_ts_time"
	// CommitBackoffTimeStr means the time of commit backoff.
	CommitBackoffTimeStr = "Commit_backoff_time"
	// BackoffTypesStr means the backoff type.
	BackoffTypesStr = "Backoff_types"
	// SlowestPrewriteRPCDetailStr means the details of the slowest RPC during the transaction 2pc prewrite process.
	SlowestPrewriteRPCDetailStr = "Slowest_prewrite_rpc_detail"
	// CommitPrimaryRPCDetailStr means the details of the slowest RPC during the transaction 2pc commit process.
	CommitPrimaryRPCDetailStr = "Commit_primary_rpc_detail"
	// ResolveLockTimeStr means the time of resolving lock.
	ResolveLockTimeStr = "Resolve_lock_time"
	// LocalLatchWaitTimeStr means the time of waiting in local latch.
	LocalLatchWaitTimeStr = "Local_latch_wait_time"
	// TxnRetryStr means the count of transaction retry.
	TxnRetryStr = "Txn_retry"
	// GetSnapshotTimeStr means the time spent on getting an engine snapshot.
	GetSnapshotTimeStr = "Get_snapshot_time"
	// RocksdbDeleteSkippedCountStr means the count of rocksdb delete skipped count.
	RocksdbDeleteSkippedCountStr = "Rocksdb_delete_skipped_count"
	// RocksdbKeySkippedCountStr means the count of rocksdb key skipped count.
	RocksdbKeySkippedCountStr = "Rocksdb_key_skipped_count"
	// RocksdbBlockCacheHitCountStr means the count of rocksdb block cache hit.
	RocksdbBlockCacheHitCountStr = "Rocksdb_block_cache_hit_count"
	// RocksdbBlockReadCountStr means the count of rocksdb block read.
	RocksdbBlockReadCountStr = "Rocksdb_block_read_count"
	// RocksdbBlockReadByteStr means the bytes of rocksdb block read.
	RocksdbBlockReadByteStr = "Rocksdb_block_read_byte"
	// RocksdbBlockReadTimeStr means the time spent on rocksdb block read.
	RocksdbBlockReadTimeStr = "Rocksdb_block_read_time"
	// IARemoteReadSegmentCountStr means the number of IA remote segment reads.
	IARemoteReadSegmentCountStr = "IA_remote_read_segment_count"
	// IARemoteReadSegmentSizeStr means the number of bytes returned from IA remote segment reads.
	IARemoteReadSegmentSizeStr = "IA_remote_read_segment_size"
	// IARemoteReadSegmentWaitTimeStr means the total time spent waiting for IA remote segment reads.
	IARemoteReadSegmentWaitTimeStr = "IA_remote_read_segment_wait_time"

	// ProcessTimeStr represents the sum of process time of all the coprocessor tasks.
	ProcessTimeStr = "Process_time"
	// BackoffTimeStr means the time of all back-off.
	BackoffTimeStr = "Backoff_time"
	// TotalKeysStr means the total scan keys.
	TotalKeysStr = "Total_keys"
	// ProcessKeysStr means the total processed keys.
	ProcessKeysStr = "Process_keys"
	// PreWriteTimeStr means the time of pre-write.
	PreWriteTimeStr = "Prewrite_time"
	// CommitTimeStr means the time of commit.
	CommitTimeStr = "Commit_time"
	// WriteKeysStr means the count of keys in the transaction.
	WriteKeysStr = "Write_keys"
	// WriteSizeStr means the key/value size in the transaction.
	WriteSizeStr = "Write_size"
	// PrewriteRegionStr means the count of region when pre-write.
	PrewriteRegionStr = "Prewrite_region"
)
View Source
const (
	// TpBasicRuntimeStats is the tp for BasicRuntimeStats.
	TpBasicRuntimeStats int = iota
	// TpRuntimeStatsWithCommit is the tp for RuntimeStatsWithCommit.
	TpRuntimeStatsWithCommit
	// TpRuntimeStatsWithConcurrencyInfo is the tp for RuntimeStatsWithConcurrencyInfo.
	TpRuntimeStatsWithConcurrencyInfo
	// TpSnapshotRuntimeStats is the tp for SnapshotRuntimeStats.
	TpSnapshotRuntimeStats
	// TpHashJoinRuntimeStats is the tp for HashJoinRuntimeStats.
	TpHashJoinRuntimeStats
	// TpHashJoinRuntimeStatsV2 is the tp for hashJoinRuntimeStatsV2.
	TpHashJoinRuntimeStatsV2
	// TpIndexLookUpJoinRuntimeStats is the tp for IndexLookUpJoinRuntimeStats.
	TpIndexLookUpJoinRuntimeStats
	// TpRuntimeStatsWithSnapshot is the tp for RuntimeStatsWithSnapshot.
	TpRuntimeStatsWithSnapshot
	// TpJoinRuntimeStats is the tp for JoinRuntimeStats.
	TpJoinRuntimeStats
	// TpSelectResultRuntimeStats is the tp for SelectResultRuntimeStats.
	TpSelectResultRuntimeStats
	// TpInsertRuntimeStat is the tp for InsertRuntimeStat
	TpInsertRuntimeStat
	// TpIndexLookUpRunTimeStats is the tp for IndexLookUpRunTimeStats
	TpIndexLookUpRunTimeStats
	// TpSlowQueryRuntimeStat is the tp for SlowQueryRuntimeStat
	TpSlowQueryRuntimeStat
	// TpHashAggRuntimeStat is the tp for HashAggRuntimeStat
	TpHashAggRuntimeStat
	// TpIndexMergeRunTimeStats is the tp for IndexMergeRunTimeStats
	TpIndexMergeRunTimeStats
	// TpBasicCopRunTimeStats is the tp for BasicCopRunTimeStats
	TpBasicCopRunTimeStats
	// TpUpdateRuntimeStats is the tp for UpdateRuntimeStats
	TpUpdateRuntimeStats
	// TpFKCheckRuntimeStats is the tp for FKCheckRuntimeStats
	TpFKCheckRuntimeStats
	// TpFKCascadeRuntimeStats is the tp for FKCascadeRuntimeStats
	TpFKCascadeRuntimeStats
	// TpRURuntimeStats is the tp for RURuntimeStats
	TpRURuntimeStats
	// TpExplainRURuntimeStats is the tp for ExplainRURuntimeStats
	TpExplainRURuntimeStats
	// TpHashStateRuntimeStats is the tp for typed hash-state evidence.
	TpHashStateRuntimeStats
	// TpWriteRuntimeStats is the type for processed DML work.
	TpWriteRuntimeStats
	// TpJoinedRowsRuntimeStats is the type for join pairs before residual filtering.
	TpJoinedRowsRuntimeStats
	// TpMViewDeltaMergeAggRuntimeStats is the type for MV delta merge aggregation.
	TpMViewDeltaMergeAggRuntimeStats
	// TpMViewCompleteDeltaApplyRuntimeStats is the type for MV complete delta apply.
	TpMViewCompleteDeltaApplyRuntimeStats
)
View Source
const MaxDetailsNumsForOneQuery = 1000

MaxDetailsNumsForOneQuery is the max number of details to keep for P90 for one query.

Variables

View Source
var RUV2MetricsCtxKey = ruv2MetricsKeyType{}

RUV2MetricsCtxKey is used to carry statement-level RUv2 metrics in context.Context.

View Source
var StmtExecDetailKey = stmtExecDetailKeyType{}

StmtExecDetailKey used to carry StmtExecDetail info in context.Context.

Functions

func ContextWithInheritedRUV2Details

func ContextWithInheritedRUV2Details(ctx, source context.Context) context.Context

ContextWithInheritedRUV2Details reuses statement-level RUDetails and RUv2 metrics from source when ctx does not already carry them.

func ContextWithInitializedExecDetails

func ContextWithInitializedExecDetails(ctx context.Context) context.Context

ContextWithInitializedExecDetails returns a context with initialized stmt execution, execution and resource usage details.

func ContextWithMissingExecDetailsInitialized

func ContextWithMissingExecDetailsInitialized(ctx context.Context) context.Context

ContextWithMissingExecDetailsInitialized initializes any missing statement execution, execution, and resource usage details in the context while preserving existing objects.

func ContextWithRUV2Metrics

func ContextWithRUV2Metrics(ctx context.Context, metrics *RUV2Metrics) context.Context

ContextWithRUV2Metrics returns a context with metrics as the active statement-level RUv2 metrics.

func EstimateScanBytes

func EstimateScanBytes(totalKeys, processedKeys, processedBytes, totalBytes int64) (float64, bool)

EstimateScanBytes prefers backend-reported total bytes for a logical scan request and falls back to the processed-byte ratio when total bytes are zero. Run it before merging independent requests because the fallback is not linear.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration uses to format duration, this function will prune precision before format duration. Pruning precision is for human readability. The prune rule is:

  1. if the duration was less than 1us, return the original string.
  2. readable value >=10, keep 1 decimal, otherwise, keep 2 decimal. such as: 9.412345ms -> 9.41ms 10.412345ms -> 10.4ms 5.999s -> 6s 100.45µs -> 100.5µs

func GetExecDetailsFromContext

func GetExecDetailsFromContext(ctx context.Context) (writeSQLRespDuration time.Duration, tikvExecDetail util.ExecDetails, ruDetails *util.RUDetails)

GetExecDetailsFromContext gets stmt response duration, execution and resource usage details from context.

func LoadTiKVExecDetails

func LoadTiKVExecDetails(detail *util.ExecDetails) util.ExecDetails

LoadTiKVExecDetails snapshots the fields in util.ExecDetails that are updated via atomic operations.

func MergeTiFlashRUConsumption

func MergeTiFlashRUConsumption(executionSummaries []*tipb.ExecutorExecutionSummary, ruDetails *util.RUDetails) error

MergeTiFlashRUConsumption merge execution summaries from selectResponse into ruDetails.

func SyncRUV2MetricsFromRUDetails

func SyncRUV2MetricsFromRUDetails(metrics *RUV2Metrics, ruDetails *tikvutil.RUDetails)

SyncRUV2MetricsFromRUDetails drains the raw RUv2 counters accumulated in RUDetails since the last drain and adds them into the statement-level metrics. It is safe to call multiple times; each call transfers only the delta.

func UpdateRUV2MetricsFromRUV2

func UpdateRUV2MetricsFromRUV2(m *RUV2Metrics, ru *kvrpcpb.RUV2)

UpdateRUV2MetricsFromRUV2 adds raw RUv2 counters into the statement-level metrics snapshot.

Types

type BasicRuntimeStats

type BasicRuntimeStats struct {
	// contains filtered or unexported fields
}

BasicRuntimeStats is the basic runtime stats.

func (*BasicRuntimeStats) Clone

Clone implements the RuntimeStats interface. BasicRuntimeStats shouldn't implement Clone interface because all executors with the same executor_id should share the same BasicRuntimeStats, duplicated BasicRuntimeStats are easy to cause mistakes.

func (*BasicRuntimeStats) GetActRows

func (e *BasicRuntimeStats) GetActRows() int64

GetActRows return total rows of BasicRuntimeStats.

func (*BasicRuntimeStats) GetTime

func (e *BasicRuntimeStats) GetTime() int64

GetTime get the int64 total time

func (*BasicRuntimeStats) Merge

func (e *BasicRuntimeStats) Merge(rs RuntimeStats)

Merge implements the RuntimeStats interface.

func (*BasicRuntimeStats) Record

func (e *BasicRuntimeStats) Record(d time.Duration, rowNum int)

Record records executor's execution.

func (*BasicRuntimeStats) RecordClose

func (e *BasicRuntimeStats) RecordClose(d time.Duration)

RecordClose records executor's close time.

func (*BasicRuntimeStats) RecordOpen

func (e *BasicRuntimeStats) RecordOpen(d time.Duration)

RecordOpen records executor's open time.

func (*BasicRuntimeStats) SetRowNum

func (e *BasicRuntimeStats) SetRowNum(rowNum int64)

SetRowNum sets the row num.

func (*BasicRuntimeStats) String

func (e *BasicRuntimeStats) String() string

String implements the RuntimeStats interface.

func (*BasicRuntimeStats) Tp

func (*BasicRuntimeStats) Tp() int

Tp implements the RuntimeStats interface.

type ConcurrencyInfo

type ConcurrencyInfo struct {
	// contains filtered or unexported fields
}

ConcurrencyInfo is used to save the concurrency information of the executor operator

func NewConcurrencyInfo

func NewConcurrencyInfo(name string, num int) *ConcurrencyInfo

NewConcurrencyInfo creates new executor's concurrencyInfo.

type CopExecDetails

type CopExecDetails struct {
	ScanDetail    *util.ScanDetail
	TimeDetail    util.TimeDetail
	CalleeAddress string
	BackoffTime   time.Duration
	BackoffSleep  map[string]time.Duration
	BackoffTimes  map[string]int
}

CopExecDetails contains cop execution detail information.

type CopRowsSnapshot

type CopRowsSnapshot struct {
	Rows              int64
	ObservedSummaries uint64
	ExpectedSummaries uint64
	Invalid           bool
}

CopRowsSnapshot is a value-only copy of TiKV execution-summary evidence. ExpectedSummaries counts received responses that should contain this plan's summary; it is response-summary coverage, not physical-attempt coverage.

func (CopRowsSnapshot) Complete

func (s CopRowsSnapshot) Complete() bool

Complete reports whether every received-response expectation has one valid execution summary. A real zero has equal positive counts and Rows == 0.

func (CopRowsSnapshot) Observed

func (s CopRowsSnapshot) Observed() bool

Observed reports whether at least one valid response summary can contribute rows. Missing summary slots remain visible through Complete and are skipped; contradictory counts and negative row counts are not usable.

type CopRuntimeStats

type CopRuntimeStats struct {
	// contains filtered or unexported fields
}

CopRuntimeStats collects cop tasks' execution info.

func (*CopRuntimeStats) GetActRows

func (crs *CopRuntimeStats) GetActRows() int64

GetActRows return total rows of CopRuntimeStats.

func (*CopRuntimeStats) GetTasks

func (crs *CopRuntimeStats) GetTasks() int32

GetTasks return total tasks of CopRuntimeStats

func (*CopRuntimeStats) String

func (crs *CopRuntimeStats) String() string

type CopTasksDetails

type CopTasksDetails struct {
	NumCopTasks int

	ProcessTimeStats TaskTimeStats
	WaitTimeStats    TaskTimeStats

	BackoffTimeStatsMap map[string]TaskTimeStats
	TotBackoffTimes     map[string]int
}

CopTasksDetails collects some useful information of cop-tasks during execution.

func (*CopTasksDetails) ToZapFields

func (d *CopTasksDetails) ToZapFields() (fields []zap.Field)

ToZapFields wraps the CopTasksDetails as zap.Fileds.

type CopTasksSummary

type CopTasksSummary struct {
	NumCopTasks       int
	MaxProcessAddress string
	MaxProcessTime    time.Duration
	TotProcessTime    time.Duration
	MaxWaitAddress    string
	MaxWaitTime       time.Duration
	TotWaitTime       time.Duration
}

CopTasksSummary collects some summary information of cop-tasks for statement summary.

type Duration

type Duration time.Duration

Duration is a wrapper of time.Duration to implement the canGetFloat64 interface.

func (Duration) GetFloat64

func (d Duration) GetFloat64() float64

GetFloat64 implements the canGetFloat64 interface.

type DurationWithAddr

type DurationWithAddr struct {
	D    time.Duration
	Addr string
}

DurationWithAddr is a wrapper of time.Duration and string to implement the canGetFloat64 interface.

func (DurationWithAddr) GetFloat64

func (d DurationWithAddr) GetFloat64() float64

GetFloat64 implements the canGetFloat64 interface.

type ExecDetails

type ExecDetails struct {
	CopExecDetails
	CommitDetail         *util.CommitDetails
	LockKeysDetail       *util.LockKeysDetails
	SharedLockKeysDetail *util.LockKeysDetails
	ReadPoolTaskDetails  *util.PoolTaskDetails
	CopTime              time.Duration
	LockKeysDuration     time.Duration
	RequestCount         int
}

ExecDetails contains execution detail information.

func (ExecDetails) String

func (d ExecDetails) String() string

String implements the fmt.Stringer interface.

func (ExecDetails) ToZapFields

func (d ExecDetails) ToZapFields() (fields []zap.Field)

ToZapFields wraps the ExecDetails as zap.Fields.

type ExplainRURuntimeStats

type ExplainRURuntimeStats struct {
	SelfRU float64
	CumRU  float64
}

ExplainRURuntimeStats stores per-operator RU values for EXPLAIN ANALYZE FORMAT='ru'.

func (*ExplainRURuntimeStats) Clone

Clone implements the RuntimeStats interface.

func (*ExplainRURuntimeStats) Merge

func (e *ExplainRURuntimeStats) Merge(other RuntimeStats)

Merge implements the RuntimeStats interface.

func (*ExplainRURuntimeStats) String

func (e *ExplainRURuntimeStats) String() string

String implements the RuntimeStats interface.

func (*ExplainRURuntimeStats) Tp

func (*ExplainRURuntimeStats) Tp() int

Tp implements the RuntimeStats interface.

type HashStateRowsSnapshot

type HashStateRowsSnapshot struct {
	Rows int64
}

HashStateRowsSnapshot is a value-only snapshot of entries admitted to lookup/group structures. Consumers read it after statement teardown so it includes work from producers that stopped before emitting their results.

func (HashStateRowsSnapshot) Invalid

func (s HashStateRowsSnapshot) Invalid() bool

Invalid reports an overflowed row count.

type HashStateRuntimeStats

type HashStateRuntimeStats struct {
	// contains filtered or unexported fields
}

HashStateRuntimeStats accumulates constructed hash entries for one root executor Open. It is display-neutral and merges across repeated executions.

func NewHashStateRuntimeStats

func NewHashStateRuntimeStats() *HashStateRuntimeStats

NewHashStateRuntimeStats initializes an empty construction counter.

func (*HashStateRuntimeStats) AddRows

func (s *HashStateRuntimeStats) AddRows(rows uint64)

AddRows records constructed lookup/group entries, including spill/restore rounds. A negative sentinel preserves overflow through subsequent updates.

func (*HashStateRuntimeStats) Clone

Clone implements RuntimeStats.

func (*HashStateRuntimeStats) HashStateRowsSnapshot

func (s *HashStateRuntimeStats) HashStateRowsSnapshot() HashStateRowsSnapshot

HashStateRowsSnapshot returns a scalar copy of the construction counter.

func (*HashStateRuntimeStats) Merge

func (s *HashStateRuntimeStats) Merge(other RuntimeStats)

Merge implements RuntimeStats.

func (*HashStateRuntimeStats) String

func (*HashStateRuntimeStats) String() string

String keeps typed evidence out of EXPLAIN runtime-stat rendering.

func (*HashStateRuntimeStats) Tp

func (*HashStateRuntimeStats) Tp() int

Tp implements RuntimeStats.

type IARemoteReadSegmentStats

type IARemoteReadSegmentStats struct {
	Count    uint64
	Bytes    uint64
	WaitTime time.Duration
}

IARemoteReadSegmentStats contains IA remote-read scan statistics.

func GetIARemoteReadSegmentStats

func GetIARemoteReadSegmentStats(scanDetail *util.ScanDetail) IARemoteReadSegmentStats

GetIARemoteReadSegmentStats reads IA remote-read scan statistics from client-go ScanDetail.

type Int64

type Int64 int64

Int64 is a wrapper of int64 to implement the canGetFloat64 interface.

func (Int64) GetFloat64

func (i Int64) GetFloat64() float64

GetFloat64 implements the canGetFloat64 interface.

type JoinedRowsRuntimeStats

type JoinedRowsRuntimeStats struct {
	Rows int64
}

JoinedRowsRuntimeStats counts candidate pairs processed before other conditions. Each join worker owns its counter until Close; it is not concurrency-safe. Null-extension rows and pairs skipped by semi-join short circuit are excluded.

func (*JoinedRowsRuntimeStats) AddRows

func (s *JoinedRowsRuntimeStats) AddRows(rows int64)

AddRows preserves a negative overflow sentinel through subsequent updates.

func (*JoinedRowsRuntimeStats) Clone

Clone implements RuntimeStats.

func (*JoinedRowsRuntimeStats) Merge

func (s *JoinedRowsRuntimeStats) Merge(other RuntimeStats)

Merge implements RuntimeStats.

func (*JoinedRowsRuntimeStats) String

func (*JoinedRowsRuntimeStats) String() string

String keeps accounting evidence out of EXPLAIN runtime-stat rendering.

func (*JoinedRowsRuntimeStats) Tp

Tp implements RuntimeStats.

type P90BackoffSummary

type P90BackoffSummary struct {
	ReqTimes          int
	BackoffPercentile Percentile[DurationWithAddr]
	TotBackoffTime    time.Duration
	TotBackoffTimes   int
}

P90BackoffSummary contains execution summary for a backoff type.

type P90Summary

type P90Summary struct {
	NumCopTasks int

	ProcessTimePercentile Percentile[DurationWithAddr]
	WaitTimePercentile    Percentile[DurationWithAddr]

	BackoffInfo map[string]*P90BackoffSummary
}

P90Summary contains execution summary for cop tasks.

func (*P90Summary) Merge

func (d *P90Summary) Merge(backoffSleep map[string]time.Duration, backoffTimes map[string]int, calleeAddress string, timeDetail util.TimeDetail)

Merge merges DetailsNeedP90 into P90Summary.

func (*P90Summary) Reset

func (d *P90Summary) Reset()

Reset resets all fields in DetailsNeedP90Summary.

type Percentile

type Percentile[valueType canGetFloat64] struct {
	// contains filtered or unexported fields
}

Percentile is a struct to calculate the percentile of a series of values.

func (*Percentile[valueType]) Add

func (p *Percentile[valueType]) Add(value valueType)

Add adds a value to calculate the percentile.

func (*Percentile[valueType]) GetMax

func (p *Percentile[valueType]) GetMax() valueType

GetMax returns the max value.

func (*Percentile[valueType]) GetMin

func (p *Percentile[valueType]) GetMin() valueType

GetMin returns the min value.

func (*Percentile[valueType]) GetPercentile

func (p *Percentile[valueType]) GetPercentile(f float64) float64

GetPercentile returns the percentile `f` of the values.

func (*Percentile[valueType]) MergePercentile

func (p *Percentile[valueType]) MergePercentile(p2 *Percentile[valueType])

MergePercentile merges two Percentile.

func (*Percentile[valueType]) Size

func (p *Percentile[valueType]) Size() int

Size returns the size of the values.

func (*Percentile[valueType]) Sum

func (p *Percentile[valueType]) Sum() float64

Sum returns the sum of the values.

type RURuntimeStats

type RURuntimeStats struct {
	*util.RUDetails
}

RURuntimeStats wraps RU v1 details for EXPLAIN output.

func (*RURuntimeStats) Clone

func (e *RURuntimeStats) Clone() RuntimeStats

Clone implements the RuntimeStats interface.

func (*RURuntimeStats) Merge

func (e *RURuntimeStats) Merge(other RuntimeStats)

Merge implements the RuntimeStats interface.

func (*RURuntimeStats) String

func (e *RURuntimeStats) String() string

String implements the RuntimeStats interface.

func (*RURuntimeStats) Tp

func (*RURuntimeStats) Tp() int

Tp implements the RuntimeStats interface.

type RUV2Metrics

type RUV2Metrics struct {
	// contains filtered or unexported fields
}

RUV2Metrics stores statement-level RUv2 metrics.

func NewRUV2Metrics

func NewRUV2Metrics() *RUV2Metrics

NewRUV2Metrics creates a new RUv2 metrics container.

func RUV2MetricsFromContext

func RUV2MetricsFromContext(ctx context.Context) *RUV2Metrics

RUV2MetricsFromContext returns the RUv2 metrics stored in ctx.

func SyncRUV2MetricsFromContext

func SyncRUV2MetricsFromContext(ctx context.Context) *RUV2Metrics

SyncRUV2MetricsFromContext drains any raw RUv2 counters in ctx's RUDetails into the statement-level RUv2 metrics and returns the metrics object.

func (*RUV2Metrics) AddTiKVCoprocessorResponseBytes

func (m *RUV2Metrics) AddTiKVCoprocessorResponseBytes(delta int64)

AddTiKVCoprocessorResponseBytes records TiKV coprocessor response bytes.

func (*RUV2Metrics) Bypass

func (m *RUV2Metrics) Bypass() bool

Bypass returns whether statement-level RU accounting should be skipped.

func (*RUV2Metrics) SetBypass

func (m *RUV2Metrics) SetBypass(enabled bool)

SetBypass marks whether statement-level RU accounting should be skipped.

func (*RUV2Metrics) TiKVCoprocessorResponseBytes

func (m *RUV2Metrics) TiKVCoprocessorResponseBytes() int64

TiKVCoprocessorResponseBytes returns TiKV coprocessor response bytes.

type RootRowsSnapshot

type RootRowsSnapshot struct {
	Rows int64
	// contains filtered or unexported fields
}

RootRowsSnapshot is a value-only copy of one root operator's row evidence.

func (RootRowsSnapshot) Invalid

func (s RootRowsSnapshot) Invalid() bool

Invalid reports malformed row or record counters.

func (RootRowsSnapshot) Observed

func (s RootRowsSnapshot) Observed() bool

Observed reports whether at least one executor Next call recorded rows.

type RootRuntimeStats

type RootRuntimeStats struct {
	// contains filtered or unexported fields
}

RootRuntimeStats is the executor runtime stats that combine with multiple runtime stats.

func NewRootRuntimeStats

func NewRootRuntimeStats() *RootRuntimeStats

NewRootRuntimeStats returns a new RootRuntimeStats

func (*RootRuntimeStats) GetActRows

func (e *RootRuntimeStats) GetActRows() int64

GetActRows return total rows of RootRuntimeStats.

func (*RootRuntimeStats) MergeStats

func (e *RootRuntimeStats) MergeStats() (basic *BasicRuntimeStats, groups []RuntimeStats)

MergeStats merges stats in the RootRuntimeStats and return the stats suitable for display directly.

func (*RootRuntimeStats) String

func (e *RootRuntimeStats) String() string

String implements the RuntimeStats interface.

type RuntimeStats

type RuntimeStats interface {
	String() string
	Merge(RuntimeStats)
	Clone() RuntimeStats
	Tp() int
}

RuntimeStats is used to express the executor runtime information.

type RuntimeStatsColl

type RuntimeStatsColl struct {
	// contains filtered or unexported fields
}

RuntimeStatsColl collects executors's execution info.

func NewRuntimeStatsColl

func NewRuntimeStatsColl(reuse *RuntimeStatsColl) *RuntimeStatsColl

NewRuntimeStatsColl creates new executor collector. Reuse the object to reduce allocation when *RuntimeStatsColl is not nil.

func (*RuntimeStatsColl) ExistsCopStats

func (e *RuntimeStatsColl) ExistsCopStats(planID int) bool

ExistsCopStats checks if the planID exists in the copStats collection.

func (*RuntimeStatsColl) ExistsRootStats

func (e *RuntimeStatsColl) ExistsRootStats(planID int) bool

ExistsRootStats checks if the planID exists in the rootStats collection.

func (*RuntimeStatsColl) GetAnalyzeScanBytes

func (e *RuntimeStatsColl) GetAnalyzeScanBytes(planID int) (float64, bool)

GetAnalyzeScanBytes returns the statement total accumulated from logical Analyze requests before their scan-detail fields were flattened together.

func (*RuntimeStatsColl) GetBasicRuntimeStats

func (e *RuntimeStatsColl) GetBasicRuntimeStats(planID int, initNewExecutorStats bool) *BasicRuntimeStats

GetBasicRuntimeStats gets basicRuntimeStats for a executor When rootStat/rootStat's basicRuntimeStats is nil, the behavior is decided by initNewExecutorStats argument: 1. If true, it created a new one, and increase basicRuntimeStats' executorCount 2. Else, it returns nil

func (*RuntimeStatsColl) GetCopCountAndRows

func (e *RuntimeStatsColl) GetCopCountAndRows(planID int) (int32, int64)

GetCopCountAndRows returns the total cop-tasks count and total rows of all cop-tasks.

func (*RuntimeStatsColl) GetCopRowsSnapshot

func (e *RuntimeStatsColl) GetCopRowsSnapshot(planID int) CopRowsSnapshot

GetCopRowsSnapshot returns checked row and response-summary evidence for one cop plan lookup key without exposing its mutable runtime-stat object.

func (*RuntimeStatsColl) GetCopScanDetail

func (e *RuntimeStatsColl) GetCopScanDetail(planID int) (util.ScanDetail, bool)

GetCopScanDetail returns a value snapshot of the scan detail collected for the cop plan identified by planID.

func (*RuntimeStatsColl) GetCopStats

func (e *RuntimeStatsColl) GetCopStats(planID int) *CopRuntimeStats

GetCopStats gets the CopRuntimeStats specified by planID.

func (*RuntimeStatsColl) GetPlanActRows

func (e *RuntimeStatsColl) GetPlanActRows(planID int) int64

GetPlanActRows returns the actual rows of the plan.

func (*RuntimeStatsColl) GetRootHashStateRowsSnapshot

func (e *RuntimeStatsColl) GetRootHashStateRowsSnapshot(planID int) (HashStateRowsSnapshot, bool)

GetRootHashStateRowsSnapshot returns the typed hash-state provider's scalar snapshot without exposing the live runtime-stat object.

func (*RuntimeStatsColl) GetRootJoinedRows

func (e *RuntimeStatsColl) GetRootJoinedRows(planID int) (int64, bool)

GetRootJoinedRows returns candidate pairs, distinguishing missing evidence from zero. Like the producer counters, this evidence is consumed after executor teardown.

func (*RuntimeStatsColl) GetRootRowsSnapshot

func (e *RuntimeStatsColl) GetRootRowsSnapshot(planID int) RootRowsSnapshot

GetRootRowsSnapshot returns scalar evidence without creating a root-stats entry or exposing a live BasicRuntimeStats pointer.

func (*RuntimeStatsColl) GetRootStats

func (e *RuntimeStatsColl) GetRootStats(planID int) *RootRuntimeStats

GetRootStats gets execStat for a executor.

func (*RuntimeStatsColl) GetRootStatsIfExists

func (e *RuntimeStatsColl) GetRootStatsIfExists(planID int) (*RootRuntimeStats, bool)

GetRootStatsIfExists gets existing runtime stats without creating an empty entry when planID has not registered any root stats.

func (*RuntimeStatsColl) GetRootWriteCPUWork

func (e *RuntimeStatsColl) GetRootWriteCPUWork(planID int) (float64, bool)

GetRootWriteCPUWork returns a scalar snapshot, distinguishing missing evidence from zero work.

func (*RuntimeStatsColl) GetStmtCopRuntimeStats

func (e *RuntimeStatsColl) GetStmtCopRuntimeStats() StmtCopRuntimeStats

GetStmtCopRuntimeStats gets execStat for a executor.

func (*RuntimeStatsColl) GetTiFlashExecutionUnits

func (e *RuntimeStatsColl) GetTiFlashExecutionUnits(planID int) (TiFlashExecutionUnits, bool)

GetTiFlashExecutionUnits returns an immutable value snapshot. Missing summaries remain distinct from observed zero, even though both contribute zero units.

func (*RuntimeStatsColl) InvalidateCopResponseSummaries

func (e *RuntimeStatsColl) InvalidateCopResponseSummaries(planIDs []int)

InvalidateCopResponseSummaries marks every summary slot in one malformed response vector unusable. The caller records the response expectations first, so missing vectors can remain partial without being classified as malformed.

func (*RuntimeStatsColl) RecordAnalyzeScanBytes

func (e *RuntimeStatsColl) RecordAnalyzeScanBytes(planID int, scanBytes float64)

RecordAnalyzeScanBytes adds one logical Analyze request's scan-byte estimate.

func (*RuntimeStatsColl) RecordCopStats

func (e *RuntimeStatsColl) RecordCopStats(
	planID int,
	storeType kv.StoreType,
	scan *util.ScanDetail,
	time util.TimeDetail,
	readPoolTaskDetails *util.PoolTaskDetails,
	summary *tipb.ExecutorExecutionSummary,
) int

RecordCopStats records a specific cop task's execution details.

func (*RuntimeStatsColl) RecordExpectedCopResponseSummaries

func (e *RuntimeStatsColl) RecordExpectedCopResponseSummaries(planIDs []int)

RecordExpectedCopResponseSummaries records the summary slots owned by one consumed TiKV response. It must run before validating the returned summary slice so missing or mismatched summaries remain observable.

func (*RuntimeStatsColl) RecordOneCopTask

func (e *RuntimeStatsColl) RecordOneCopTask(planID int, storeType kv.StoreType, summary *tipb.ExecutorExecutionSummary) int

RecordOneCopTask records a specific cop tasks's execution summary.

func (*RuntimeStatsColl) RecordTiFlashExecutionSummaries

func (e *RuntimeStatsColl) RecordTiFlashExecutionSummaries(planIDs []int, summaries []*tipb.ExecutorExecutionSummary)

RecordTiFlashExecutionSummaries accepts one consumed MPP response or one direct task report. Callers own response/task deduplication and the reporting route. IDs outside this gather cannot contribute work to another plan.

func (*RuntimeStatsColl) RegisterStats

func (e *RuntimeStatsColl) RegisterStats(planID int, info RuntimeStats)

RegisterStats register execStat for a executor.

type RuntimeStatsWithCommit

type RuntimeStatsWithCommit struct {
	Commit         *util.CommitDetails
	LockKeys       *util.LockKeysDetails
	SharedLockKeys *util.LockKeysDetails
	TxnCnt         int
}

RuntimeStatsWithCommit is the RuntimeStats with commit detail.

func (*RuntimeStatsWithCommit) Clone

Clone implements the RuntimeStats interface.

func (*RuntimeStatsWithCommit) Merge

func (e *RuntimeStatsWithCommit) Merge(rs RuntimeStats)

Merge implements the RuntimeStats interface.

func (*RuntimeStatsWithCommit) MergeCommitDetails

func (e *RuntimeStatsWithCommit) MergeCommitDetails(detail *util.CommitDetails)

MergeCommitDetails merges the commit details.

func (*RuntimeStatsWithCommit) String

func (e *RuntimeStatsWithCommit) String() string

String implements the RuntimeStats interface.

func (*RuntimeStatsWithCommit) Tp

Tp implements the RuntimeStats interface.

type RuntimeStatsWithConcurrencyInfo

type RuntimeStatsWithConcurrencyInfo struct {

	// protect concurrency
	sync.Mutex
	// contains filtered or unexported fields
}

RuntimeStatsWithConcurrencyInfo is the BasicRuntimeStats with ConcurrencyInfo.

func (*RuntimeStatsWithConcurrencyInfo) Clone

Clone implements the RuntimeStats interface.

func (*RuntimeStatsWithConcurrencyInfo) Merge

Merge implements the RuntimeStats interface.

func (*RuntimeStatsWithConcurrencyInfo) SetConcurrencyInfo

func (e *RuntimeStatsWithConcurrencyInfo) SetConcurrencyInfo(infos ...*ConcurrencyInfo)

SetConcurrencyInfo sets the concurrency informations. We must clear the concurrencyInfo first when we call the SetConcurrencyInfo. When the num <= 0, it means the exector operator is not executed parallel.

func (*RuntimeStatsWithConcurrencyInfo) String

String implements the RuntimeStats interface.

func (*RuntimeStatsWithConcurrencyInfo) Tp

Tp implements the RuntimeStats interface.

type StmtCopRuntimeStats

type StmtCopRuntimeStats struct {
	// TiflashNetworkStats stats all mpp tasks' network traffic info, nil if no any mpp tasks' network traffic
	TiflashNetworkStats *TiFlashNetworkTrafficSummary
}

StmtCopRuntimeStats stores the cop runtime stats of the total statement

type StmtExecDetails

type StmtExecDetails struct {
	WriteSQLRespDuration time.Duration
	// contains filtered or unexported fields
}

StmtExecDetails contains stmt level execution detail info.

type SyncExecDetails

type SyncExecDetails struct {
	// contains filtered or unexported fields
}

SyncExecDetails is a synced version of `ExecDetails` and its `P90Summary`

func (*SyncExecDetails) CopTasksDetails

func (s *SyncExecDetails) CopTasksDetails() *CopTasksDetails

CopTasksDetails returns some useful information of cop-tasks during execution.

func (*SyncExecDetails) CopTasksSummary

func (s *SyncExecDetails) CopTasksSummary() *CopTasksSummary

CopTasksSummary returns some summary information of cop-tasks for statement summary.

func (*SyncExecDetails) GetExecDetails

func (s *SyncExecDetails) GetExecDetails() ExecDetails

GetExecDetails returns the exec details inside. It's actually not safe, because the `ExecDetails` still contains some reference, which is not protected after returning outside.

func (*SyncExecDetails) MergeCopExecDetails

func (s *SyncExecDetails) MergeCopExecDetails(details *CopExecDetails, copTime time.Duration)

MergeCopExecDetails merges a CopExecDetails into self.

func (*SyncExecDetails) MergeExecDetails

func (s *SyncExecDetails) MergeExecDetails(commitDetails *util.CommitDetails)

MergeExecDetails merges a single region execution details into self, used to print the information in slow query log.

func (*SyncExecDetails) MergeLockKeysExecDetails

func (s *SyncExecDetails) MergeLockKeysExecDetails(lockKeys *util.LockKeysDetails)

MergeLockKeysExecDetails merges lock keys execution details into self.

func (*SyncExecDetails) MergeReadPoolTaskDetails

func (s *SyncExecDetails) MergeReadPoolTaskDetails(details *util.PoolTaskDetails)

MergeReadPoolTaskDetails merges an aggregate without changing cop-task counts or other execution details.

func (*SyncExecDetails) MergeScanDetail

func (s *SyncExecDetails) MergeScanDetail(scanDetail *util.ScanDetail)

MergeScanDetail merges scan details without changing cop-task counts or timings.

func (*SyncExecDetails) MergeSharedLockKeysExecDetails

func (s *SyncExecDetails) MergeSharedLockKeysExecDetails(lockKeys *util.LockKeysDetails)

MergeSharedLockKeysExecDetails merges shared lock keys execution details into self.

func (*SyncExecDetails) Reset

func (s *SyncExecDetails) Reset()

Reset resets the content inside

type TaskTimeStats

type TaskTimeStats struct {
	AvgTime    time.Duration
	P90Time    time.Duration
	MaxAddress string
	MaxTime    time.Duration
	TotTime    time.Duration
}

TaskTimeStats is used for recording time-related statistical metrics, including dimensions such as average values, percentile values, maximum values, etc. It is suitable for scenarios involving latency statistics, wait time analysis, and similar use cases.

func (TaskTimeStats) FormatFloatFields

func (s TaskTimeStats) FormatFloatFields() (avgStr, p90Str, maxStr string)

FormatFloatFields returns the AvgTime, P90Time and MaxTime in float format.

func (TaskTimeStats) String

func (s TaskTimeStats) String(numCopTasks int, spaceMarkStr, avgStr, p90Str, maxStr, addrStr string) string

String returns the TaskTimeStats fields as a string.

type TiFlashColumnarScanContext

type TiFlashColumnarScanContext struct {
	// contains filtered or unexported fields
}

TiFlashColumnarScanContext is used to express the table scan information in tiflash columnar read path.

func (*TiFlashColumnarScanContext) Clone

Clone implements the deep copy of * TiFlashColumnarScanContext

func (*TiFlashColumnarScanContext) Empty

func (context *TiFlashColumnarScanContext) Empty() bool

Empty check whether TiFlashColumnarScanContext is empty.

func (*TiFlashColumnarScanContext) Merge

Merge make sum to merge the information in TiFlashColumnarScanContext

func (*TiFlashColumnarScanContext) String

func (context *TiFlashColumnarScanContext) String() string

type TiFlashExecutionUnits

type TiFlashExecutionUnits struct {
	Rows                uint64
	JoinedRows          uint64
	HashDistinctEntries uint64
	HashBuildRows       uint64
	UserReadBytes       uint64
	InnerZoneSendBytes  uint64
	InterZoneSendBytes  uint64
	Observed            TiFlashUnitFields
	Missing             TiFlashUnitFields
	Invalid             bool
}

TiFlashExecutionUnits retains raw MPP evidence separately from EXPLAIN's dummy summaries. Missing evidence is best-effort zero; present invalid evidence is not. Streamed summaries may already combine tasks, so Observed never proves coverage.

type TiFlashNetworkTrafficSummary

type TiFlashNetworkTrafficSummary struct {
	// contains filtered or unexported fields
}

TiFlashNetworkTrafficSummary is used to express network traffic in tiflash

func (*TiFlashNetworkTrafficSummary) Clone

Clone implements the deep copy of * TiFlashNetworkTrafficSummary

func (*TiFlashNetworkTrafficSummary) Empty

func (networkTraffic *TiFlashNetworkTrafficSummary) Empty() bool

Empty check whether TiFlashNetworkTrafficSummary is Empty, if no any network traffic, we regard it as empty

func (*TiFlashNetworkTrafficSummary) GetInterZoneTrafficBytes

func (networkTraffic *TiFlashNetworkTrafficSummary) GetInterZoneTrafficBytes() uint64

GetInterZoneTrafficBytes returns the inter zone network traffic bytes involved between tiflash instances.

func (*TiFlashNetworkTrafficSummary) Merge

func (networkTraffic *TiFlashNetworkTrafficSummary) Merge(other TiFlashNetworkTrafficSummary)

Merge make sum to merge the information in TiFlashNetworkTrafficSummary

func (*TiFlashNetworkTrafficSummary) String

func (networkTraffic *TiFlashNetworkTrafficSummary) String() string

String dumps TiFlashNetworkTrafficSummary info as string

func (*TiFlashNetworkTrafficSummary) UpdateTiKVExecDetails

func (networkTraffic *TiFlashNetworkTrafficSummary) UpdateTiKVExecDetails(tikvDetails *util.ExecDetails)

UpdateTiKVExecDetails update tikvDetails with TiFlashNetworkTrafficSummary's values

type TiFlashScanContext

type TiFlashScanContext struct {
	// contains filtered or unexported fields
}

TiFlashScanContext is used to express the table scan information in tiflash

func (*TiFlashScanContext) Clone

func (context *TiFlashScanContext) Clone() TiFlashScanContext

Clone implements the deep copy of * TiFlashshScanContext

func (*TiFlashScanContext) Empty

func (context *TiFlashScanContext) Empty() bool

Empty check whether TiFlashScanContext is Empty, if scan no pack and skip no pack, we regard it as empty

func (*TiFlashScanContext) Merge

func (context *TiFlashScanContext) Merge(other TiFlashScanContext)

Merge make sum to merge the information in TiFlashScanContext

func (*TiFlashScanContext) String

func (context *TiFlashScanContext) String() string

type TiFlashUnitFields

type TiFlashUnitFields uint8

TiFlashUnitFields describes presence in received summaries, not task coverage.

const (
	TiFlashUnitRows TiFlashUnitFields = 1 << iota
	TiFlashUnitHash
	TiFlashUnitScan
	TiFlashUnitNetwork
	TiFlashUnitJoin
)

Presence bits for fields carried by a received execution summary.

type TiFlashWaitSummary

type TiFlashWaitSummary struct {
	// contains filtered or unexported fields
}

TiFlashWaitSummary is used to express all kinds of wait information in tiflash

func (*TiFlashWaitSummary) CanBeIgnored

func (waitSummary *TiFlashWaitSummary) CanBeIgnored() bool

CanBeIgnored check whether TiFlashWaitSummary can be ignored, not all tidb executors have significant tiflash wait summary

func (*TiFlashWaitSummary) Clone

func (waitSummary *TiFlashWaitSummary) Clone() TiFlashWaitSummary

Clone implements the deep copy of * TiFlashWaitSummary

func (*TiFlashWaitSummary) Merge

func (waitSummary *TiFlashWaitSummary) Merge(other TiFlashWaitSummary)

Merge make sum to merge the information in TiFlashWaitSummary

func (*TiFlashWaitSummary) String

func (waitSummary *TiFlashWaitSummary) String() string

String dumps TiFlashWaitSummary info as string

type TiflashStats

type TiflashStats struct {
	// contains filtered or unexported fields
}

TiflashStats contains tiflash execution stats.

type WriteRuntimeStats

type WriteRuntimeStats struct {
	CPUWork float64
}

WriteRuntimeStats records processed DML work for one executor Open lifecycle. The executor owns it until Close registers it; successful finalization consumes it.

func (*WriteRuntimeStats) Clone

func (s *WriteRuntimeStats) Clone() RuntimeStats

Clone implements RuntimeStats.

func (*WriteRuntimeStats) Merge

func (s *WriteRuntimeStats) Merge(other RuntimeStats)

Merge implements RuntimeStats.

func (*WriteRuntimeStats) String

func (*WriteRuntimeStats) String() string

String keeps the typed accounting evidence out of textual execution details.

func (*WriteRuntimeStats) Tp

func (*WriteRuntimeStats) Tp() int

Tp implements RuntimeStats.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL