execdetails

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

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

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

Documentation

Index

Constants

View Source
const (
	// CopTimeStr represents the sum of cop-task time spend in TiDB distSQL.
	CopTimeStr = "Cop_time"
	// ProcessTimeStr represents the sum of process time of all the coprocessor tasks.
	ProcessTimeStr = "Process_time"
	// WaitTimeStr means the time of all coprocessor wait.
	WaitTimeStr = "Wait_time"
	// BackoffTimeStr means the time of all back-off.
	BackoffTimeStr = "Backoff_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"
	// 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"
	// WaitPrewriteBinlogTimeStr means the time of waiting prewrite binlog finished when transaction committing.
	WaitPrewriteBinlogTimeStr = "Wait_prewrite_binlog_time"
	// CommitTimeStr means the time of commit.
	CommitTimeStr = "Commit_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"
	// 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"
	// 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"
)
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
	// 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
)
View Source
const MaxDetailsNumsForOneQuery = 1000

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

Variables

View Source
var StmtExecDetailKey = stmtExecDetailKeyType{}

StmtExecDetailKey used to carry StmtExecDetail info in context.Context.

Functions

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 MergeTiFlashRUConsumption

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

MergeTiFlashRUConsumption merge execution summaries from selectResponse into ruDetails.

Types

type BasicRuntimeStats

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

BasicRuntimeStats is the basic runtime stats.

func (*BasicRuntimeStats) Clone

func (e *BasicRuntimeStats) Clone() RuntimeStats

Clone implements the RuntimeStats interface.

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) 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 CopRuntimeStats

type CopRuntimeStats struct {
	sync.Mutex
	// contains filtered or unexported fields
}

CopRuntimeStats collects cop tasks' execution info.

func (*CopRuntimeStats) GetActRows

func (crs *CopRuntimeStats) GetActRows() (totalRows int64)

GetActRows return total rows of CopRuntimeStats.

func (*CopRuntimeStats) GetTasks

func (crs *CopRuntimeStats) GetTasks() (totalTasks int32)

GetTasks return total tasks of CopRuntimeStats

func (*CopRuntimeStats) MergeBasicStats

func (crs *CopRuntimeStats) MergeBasicStats() (procTimes Percentile[Duration], totalTime time.Duration, totalTasks, totalLoops, totalThreads int32, totalTiFlashScanContext TiFlashScanContext)

MergeBasicStats traverses basicCopRuntimeStats in the CopRuntimeStats and collects some useful information.

func (*CopRuntimeStats) RecordOneCopTask

func (crs *CopRuntimeStats) RecordOneCopTask(address string, summary *tipb.ExecutorExecutionSummary)

RecordOneCopTask records a specific cop tasks's execution detail.

func (*CopRuntimeStats) String

func (crs *CopRuntimeStats) String() string

type CopTasksDetails

type CopTasksDetails struct {
	NumCopTasks int

	AvgProcessTime    time.Duration
	P90ProcessTime    time.Duration
	MaxProcessAddress string
	MaxProcessTime    time.Duration

	AvgWaitTime    time.Duration
	P90WaitTime    time.Duration
	MaxWaitAddress string
	MaxWaitTime    time.Duration

	MaxBackoffTime    map[string]time.Duration
	MaxBackoffAddress map[string]string
	AvgBackoffTime    map[string]time.Duration
	P90BackoffTime    map[string]time.Duration
	TotBackoffTime    map[string]time.Duration
	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 DetailsNeedP90

type DetailsNeedP90 struct {
	BackoffSleep  map[string]time.Duration
	BackoffTimes  map[string]int
	CalleeAddress string
	TimeDetail    util.TimeDetail
}

DetailsNeedP90 contains execution detail information which need calculate P90.

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 {
	DetailsNeedP90
	CommitDetail     *util.CommitDetails
	LockKeysDetail   *util.LockKeysDetails
	ScanDetail       *util.ScanDetail
	CopTime          time.Duration
	BackoffTime      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 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 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(detail *DetailsNeedP90)

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 is a wrapper of util.RUDetails, which implements the RuntimeStats interface.

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 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) GetBasicRuntimeStats

func (e *RuntimeStatsColl) GetBasicRuntimeStats(planID int) *BasicRuntimeStats

GetBasicRuntimeStats gets basicRuntimeStats for a executor.

func (*RuntimeStatsColl) GetCopStats

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

GetCopStats gets the CopRuntimeStats specified by planID.

func (*RuntimeStatsColl) GetOrCreateCopStats

func (e *RuntimeStatsColl) GetOrCreateCopStats(planID int, storeType string) *CopRuntimeStats

GetOrCreateCopStats gets the CopRuntimeStats specified by planID, if not exists a new one will be created.

func (*RuntimeStatsColl) GetRootStats

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

GetRootStats gets execStat for a executor.

func (*RuntimeStatsColl) RecordOneCopTask

func (e *RuntimeStatsColl) RecordOneCopTask(planID int, storeType string, address string, summary *tipb.ExecutorExecutionSummary) int

RecordOneCopTask records a specific cop tasks's execution detail.

func (*RuntimeStatsColl) RecordScanDetail

func (e *RuntimeStatsColl) RecordScanDetail(planID int, storeType string, detail *util.ScanDetail)

RecordScanDetail records a specific cop tasks's cop detail.

func (*RuntimeStatsColl) RecordTimeDetail

func (e *RuntimeStatsColl) RecordTimeDetail(planID int, storeType string, detail *util.TimeDetail)

RecordTimeDetail records a specific cop tasks's time detail.

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
	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 StmtExecDetails

type StmtExecDetails struct {
	WriteSQLRespDuration time.Duration
}

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) 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) MergeExecDetails

func (s *SyncExecDetails) MergeExecDetails(details *ExecDetails, 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) Reset

func (s *SyncExecDetails) Reset()

Reset resets the content inside

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

Jump to

Keyboard shortcuts

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