tidb: github.com/pingcap/tidb/util/execdetails Index | Files

package execdetails

import "github.com/pingcap/tidb/util/execdetails"

Index

Package Files

execdetails.go pd_interceptor.go

Constants

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"
    // CommitBackoffTimeStr means the time of commit backoff.
    CommitBackoffTimeStr = "Commit_backoff_time"
    // BackoffTypesStr means the backoff type.
    BackoffTypesStr = "Backoff_types"
    // 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"
    // 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"
)
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 TpIndexLookUpRunTimeStats
    TpIndexLookUpRunTimeStats
    // TpSlowQueryRuntimeStat is the tp for TpSlowQueryRuntimeStat
    TpSlowQueryRuntimeStat
    // TpHashAggRuntimeStat is the tp for HashAggRuntimeStat
    TpHashAggRuntimeStat
    // TpIndexMergeRunTimeStats is the tp for TpIndexMergeRunTimeStats
    TpIndexMergeRunTimeStats
    // TpBasicCopRunTimeStats is the tp for TpBasicCopRunTimeStats
    TpBasicCopRunTimeStats
)

Variables

var (
    // CommitDetailCtxKey presents CommitDetail info key in context.
    CommitDetailCtxKey = commitDetailCtxKeyType{}

    // LockKeysDetailCtxKey presents LockKeysDetail info key in context.
    LockKeysDetailCtxKey = lockKeysDetailCtxKeyType{}
)
var StmtExecDetailKey = stmtExecDetailKeyType{}

StmtExecDetailKey used to carry StmtExecDetail info in context.Context.

func FormatDuration Uses

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

type BasicRuntimeStats Uses

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

BasicRuntimeStats is the basic runtime stats.

func (*BasicRuntimeStats) Clone Uses

func (e *BasicRuntimeStats) Clone() RuntimeStats

Clone implements the RuntimeStats interface.

func (*BasicRuntimeStats) GetActRows Uses

func (e *BasicRuntimeStats) GetActRows() int64

GetActRows return total rows of BasicRuntimeStats.

func (*BasicRuntimeStats) GetTime Uses

func (e *BasicRuntimeStats) GetTime() int64

GetTime get the int64 total time

func (*BasicRuntimeStats) Merge Uses

func (e *BasicRuntimeStats) Merge(rs RuntimeStats)

Merge implements the RuntimeStats interface.

func (*BasicRuntimeStats) Record Uses

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

Record records executor's execution.

func (*BasicRuntimeStats) SetRowNum Uses

func (e *BasicRuntimeStats) SetRowNum(rowNum int64)

SetRowNum sets the row num.

func (*BasicRuntimeStats) String Uses

func (e *BasicRuntimeStats) String() string

String implements the RuntimeStats interface.

func (*BasicRuntimeStats) Tp Uses

func (e *BasicRuntimeStats) Tp() int

Tp implements the RuntimeStats interface.

type CommitDetails Uses

type CommitDetails struct {
    GetCommitTsTime        time.Duration
    PrewriteTime           time.Duration
    WaitPrewriteBinlogTime time.Duration
    CommitTime             time.Duration
    LocalLatchTime         time.Duration
    CommitBackoffTime      int64
    Mu                     struct {
        sync.Mutex
        BackoffTypes []fmt.Stringer
    }
    ResolveLockTime   int64
    WriteKeys         int
    WriteSize         int
    PrewriteRegionNum int32
    TxnRetry          int
}

CommitDetails contains commit detail information.

func (*CommitDetails) Clone Uses

func (cd *CommitDetails) Clone() *CommitDetails

Clone returns a deep copy of itself.

func (*CommitDetails) Merge Uses

func (cd *CommitDetails) Merge(other *CommitDetails)

Merge merges commit details into itself.

type ConcurrencyInfo Uses

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

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

func NewConcurrencyInfo Uses

func NewConcurrencyInfo(name string, num int) *ConcurrencyInfo

NewConcurrencyInfo creates new executor's concurrencyInfo.

type CopRuntimeStats Uses

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

CopRuntimeStats collects cop tasks' execution info.

func (*CopRuntimeStats) GetActRows Uses

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

GetActRows return total rows of CopRuntimeStats.

func (*CopRuntimeStats) RecordOneCopTask Uses

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

RecordOneCopTask records a specific cop tasks's execution detail.

func (*CopRuntimeStats) String Uses

func (crs *CopRuntimeStats) String() string

type ExecDetails Uses

type ExecDetails struct {
    CalleeAddress    string
    CopTime          time.Duration
    BackoffTime      time.Duration
    LockKeysDuration time.Duration
    BackoffSleep     map[string]time.Duration
    BackoffTimes     map[string]int
    RequestCount     int
    CommitDetail     *CommitDetails
    LockKeysDetail   *LockKeysDetails
    ScanDetail       *ScanDetail
    TimeDetail       TimeDetail
}

ExecDetails contains execution detail information.

func (ExecDetails) String Uses

func (d ExecDetails) String() string

String implements the fmt.Stringer interface.

func (ExecDetails) ToZapFields Uses

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

ToZapFields wraps the ExecDetails as zap.Fields.

type InterceptedPDClient Uses

type InterceptedPDClient struct {
    pd.Client
}

InterceptedPDClient is a PD's wrapper client to record stmt detail.

func (InterceptedPDClient) GetPrevRegion Uses

func (m InterceptedPDClient) GetPrevRegion(ctx context.Context, key []byte) (*pd.Region, error)

GetPrevRegion implements pd.Client#GetPrevRegion.

func (InterceptedPDClient) GetRegion Uses

func (m InterceptedPDClient) GetRegion(ctx context.Context, key []byte) (*pd.Region, error)

GetRegion implements pd.Client#GetRegion.

func (InterceptedPDClient) GetRegionByID Uses

func (m InterceptedPDClient) GetRegionByID(ctx context.Context, regionID uint64) (*pd.Region, error)

GetRegionByID implements pd.Client#GetRegionByID.

func (InterceptedPDClient) GetStore Uses

func (m InterceptedPDClient) GetStore(ctx context.Context, storeID uint64) (*metapb.Store, error)

GetStore implements pd.Client#GetStore.

func (InterceptedPDClient) GetTS Uses

func (m InterceptedPDClient) GetTS(ctx context.Context) (int64, int64, error)

GetTS implements pd.Client#GetTS.

func (InterceptedPDClient) GetTSAsync Uses

func (m InterceptedPDClient) GetTSAsync(ctx context.Context) pd.TSFuture

GetTSAsync implements pd.Client#GetTSAsync.

func (InterceptedPDClient) ScanRegions Uses

func (m InterceptedPDClient) ScanRegions(ctx context.Context, key, endKey []byte, limit int) ([]*pd.Region, error)

ScanRegions implements pd.Client#ScanRegions.

type LockKeysDetails Uses

type LockKeysDetails struct {
    TotalTime       time.Duration
    RegionNum       int32
    LockKeys        int32
    ResolveLockTime int64
    BackoffTime     int64
    Mu              struct {
        sync.Mutex
        BackoffTypes []fmt.Stringer
    }
    LockRPCTime  int64
    LockRPCCount int64
    RetryCount   int
}

LockKeysDetails contains pessimistic lock keys detail information.

func (*LockKeysDetails) Clone Uses

func (ld *LockKeysDetails) Clone() *LockKeysDetails

Clone returns a deep copy of itself.

func (*LockKeysDetails) Merge Uses

func (ld *LockKeysDetails) Merge(lockKey *LockKeysDetails)

Merge merges lock keys execution details into self.

type RootRuntimeStats Uses

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

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

func (*RootRuntimeStats) GetActRows Uses

func (e *RootRuntimeStats) GetActRows() int64

GetActRows return total rows of RootRuntimeStats.

func (*RootRuntimeStats) String Uses

func (e *RootRuntimeStats) String() string

String implements the RuntimeStats interface.

type RuntimeStats Uses

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

RuntimeStats is used to express the executor runtime information.

type RuntimeStatsColl Uses

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

RuntimeStatsColl collects executors's execution info.

func NewRuntimeStatsColl Uses

func NewRuntimeStatsColl() *RuntimeStatsColl

NewRuntimeStatsColl creates new executor collector.

func (*RuntimeStatsColl) ExistsCopStats Uses

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

ExistsCopStats checks if the planID exists in the copStats collection.

func (*RuntimeStatsColl) ExistsRootStats Uses

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

ExistsRootStats checks if the planID exists in the rootStats collection.

func (*RuntimeStatsColl) GetCopStats Uses

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

GetCopStats gets the CopRuntimeStats specified by planID.

func (*RuntimeStatsColl) GetOrCreateCopStats Uses

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 Uses

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

GetRootStats gets execStat for a executor.

func (*RuntimeStatsColl) RecordOneCopTask Uses

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

RecordOneCopTask records a specific cop tasks's execution detail.

func (*RuntimeStatsColl) RecordScanDetail Uses

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

RecordScanDetail records a specific cop tasks's cop detail.

func (*RuntimeStatsColl) RegisterStats Uses

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

RegisterStats register execStat for a executor.

type RuntimeStatsWithCommit Uses

type RuntimeStatsWithCommit struct {
    Commit   *CommitDetails
    LockKeys *LockKeysDetails
}

RuntimeStatsWithCommit is the RuntimeStats with commit detail.

func (*RuntimeStatsWithCommit) Clone Uses

func (e *RuntimeStatsWithCommit) Clone() RuntimeStats

Clone implements the RuntimeStats interface.

func (*RuntimeStatsWithCommit) Merge Uses

func (e *RuntimeStatsWithCommit) Merge(rs RuntimeStats)

Merge implements the RuntimeStats interface.

func (*RuntimeStatsWithCommit) String Uses

func (e *RuntimeStatsWithCommit) String() string

String implements the RuntimeStats interface.

func (*RuntimeStatsWithCommit) Tp Uses

func (e *RuntimeStatsWithCommit) Tp() int

Tp implements the RuntimeStats interface.

type RuntimeStatsWithConcurrencyInfo Uses

type RuntimeStatsWithConcurrencyInfo struct {
    // protect concurrency
    sync.Mutex
    // contains filtered or unexported fields
}

RuntimeStatsWithConcurrencyInfo is the BasicRuntimeStats with ConcurrencyInfo.

func (*RuntimeStatsWithConcurrencyInfo) Clone Uses

func (e *RuntimeStatsWithConcurrencyInfo) Clone() RuntimeStats

Clone implements the RuntimeStats interface.

func (*RuntimeStatsWithConcurrencyInfo) Merge Uses

func (e *RuntimeStatsWithConcurrencyInfo) Merge(rs RuntimeStats)

Merge implements the RuntimeStats interface.

func (*RuntimeStatsWithConcurrencyInfo) SetConcurrencyInfo Uses

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 Uses

func (e *RuntimeStatsWithConcurrencyInfo) String() string

String implements the RuntimeStats interface.

func (*RuntimeStatsWithConcurrencyInfo) Tp Uses

func (e *RuntimeStatsWithConcurrencyInfo) Tp() int

Tp implements the RuntimeStats interface.

type ScanDetail Uses

type ScanDetail struct {
    // TotalKeys is the approximate number of MVCC keys meet during scanning. It includes
    // deleted versions, but does not include RocksDB tombstone keys.
    TotalKeys int64
    // ProcessedKeys is the number of user keys scanned from the storage.
    // It does not include deleted version or RocksDB tombstone keys.
    // For Coprocessor requests, it includes keys that has been filtered out by Selection.
    ProcessedKeys int64
    // RocksdbDeleteSkippedCount is the total number of deletes and single deletes skipped over during
    // iteration, i.e. how many RocksDB tombstones are skipped.
    RocksdbDeleteSkippedCount uint64
    // RocksdbKeySkippedCount it the total number of internal keys skipped over during iteration.
    RocksdbKeySkippedCount uint64
    // RocksdbBlockCacheHitCount is the total number of RocksDB block cache hits.
    RocksdbBlockCacheHitCount uint64
    // RocksdbBlockReadCount is the total number of block reads (with IO).
    RocksdbBlockReadCount uint64
    // RocksdbBlockReadByte is the total number of bytes from block reads.
    RocksdbBlockReadByte uint64
}

ScanDetail contains coprocessor scan detail information.

func (*ScanDetail) Merge Uses

func (sd *ScanDetail) Merge(scanDetail *ScanDetail)

Merge merges scan detail execution details into self.

func (*ScanDetail) MergeFromScanDetailV2 Uses

func (sd *ScanDetail) MergeFromScanDetailV2(scanDetail *kvrpcpb.ScanDetailV2)

MergeFromScanDetailV2 merges scan detail from pb into itself.

func (*ScanDetail) String Uses

func (sd *ScanDetail) String() string

String implements the fmt.Stringer interface.

type StmtExecDetails Uses

type StmtExecDetails struct {
    BackoffCount         int64
    BackoffDuration      int64
    WaitKVRespDuration   int64
    WaitPDRespDuration   int64
    WriteSQLRespDuration time.Duration
}

StmtExecDetails contains stmt level execution detail info.

type TimeDetail Uses

type TimeDetail struct {
    // WaitWallTimeMs is the off-cpu wall time which is elapsed in TiKV side. Usually this includes queue waiting time and
    // other kind of waitings in series.
    ProcessTime time.Duration
    // Off-cpu and on-cpu wall time elapsed to actually process the request payload. It does not
    // include `wait_wall_time`.
    // This field is very close to the CPU time in most cases. Some wait time spend in RocksDB
    // cannot be excluded for now, like Mutex wait time, which is included in this field, so that
    // this field is called wall time instead of CPU time.
    WaitTime time.Duration
}

TimeDetail contains coprocessor time detail information.

func (*TimeDetail) MergeFromTimeDetail Uses

func (td *TimeDetail) MergeFromTimeDetail(timeDetail *kvrpcpb.TimeDetail)

MergeFromTimeDetail merges time detail from pb into itself.

func (*TimeDetail) String Uses

func (td *TimeDetail) String() string

String implements the fmt.Stringer interface.

Package execdetails imports 16 packages (graph) and is imported by 96 packages. Updated 2021-01-25. Refresh now. Tools for package owners.