-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
type/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.
Description
Enhancement
In a microbenchmark of AddRecord (with pipelined DML, ART memdb and #53605), UpdateDeltaForTable uses noticeable CPU time.
The primary time consumption is for map iteration, which could be optimized.
ROUTINE ======================== github.com/pingcap/tidb/pkg/sessionctx/variable.(*TransactionContext).UpdateDeltaForTable in /home/eke/code/tidb/pkg/sessionctx/variable/session.go
180ms 1.38s (flat, cum) 5.90% of Total
. . 309:func (tc *TransactionContext) UpdateDeltaForTable(physicalTableID int64, delta int64, count int64, colSize map[int64]int64) {
10ms 10ms 310: tc.tdmLock.Lock()
40ms 40ms 311: defer tc.tdmLock.Unlock()
. . 312: if tc.TableDeltaMap == nil {
. . 313: tc.TableDeltaMap = make(map[int64]TableDelta)
. . 314: }
20ms 30ms 315: item := tc.TableDeltaMap[physicalTableID]
30ms 30ms 316: if item.ColSize == nil && colSize != nil {
. 10ms 317: item.ColSize = make(map[int64]int64, len(colSize))
. . 318: }
. . 319: item.Delta += delta
. . 320: item.Count += count
. . 321: item.TableID = physicalTableID
50ms 990ms 322: for key, val := range colSize {
. 160ms 323: item.ColSize[key] += val
. . 324: }
20ms 90ms 325: tc.TableDeltaMap[physicalTableID] = item
10ms 20ms 326:}
. . 327:
. . 328:// GetKeyInPessimisticLockCache gets a key in pessimistic lock cache.
. . 329:func (tc *TransactionContext) GetKeyInPessimisticLockCache(key kv.Key) (val []byte, ok bool) {
. . 330: if tc.pessimisticLockCache == nil && tc.CurrentStmtPessimisticLockCache == nil {
. . 331: return nil, false
Metadata
Metadata
Assignees
Labels
type/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.