Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: duration logs for pipelined DML #1405

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions internal/unionstore/pipelined_memdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type PipelinedMemDB struct {

// metrics
flushWaitDuration time.Duration
startTime time.Time
}

const (
Expand Down Expand Up @@ -111,6 +112,7 @@ func NewPipelinedMemDB(bufferBatchGetter BufferBatchGetter, flushFunc FlushFunc)
// keep entryLimit and bufferLimit same with the memdb's default values.
entryLimit: memdb.entrySizeLimit,
flushOption: flushOpt,
startTime: time.Now(),
}
}

Expand Down Expand Up @@ -292,10 +294,11 @@ func (p *PipelinedMemDB) Flush(force bool) (bool, error) {
return false, nil
}
if p.flushingMemDB != nil {
if err := <-p.errCh; err != nil {
if err != nil {
err = p.handleAlreadyExistErr(err)
}
waitStartTime := time.Now()
err := <-p.errCh
p.flushWaitDuration += time.Since(waitStartTime)
if err != nil {
err = p.handleAlreadyExistErr(err)
p.flushingMemDB = nil
return false, err
}
Expand Down Expand Up @@ -523,7 +526,8 @@ func (p *PipelinedMemDB) RevertToCheckpoint(*MemDBCheckpoint) {
// GetFlushMetrics implements MemBuffer interface.
func (p *PipelinedMemDB) GetFlushMetrics() FlushMetrics {
return FlushMetrics{
WaitDuration: p.flushWaitDuration,
WaitDuration: p.flushWaitDuration,
TotalDuration: time.Since(p.startTime),
}
}

Expand Down
3 changes: 2 additions & 1 deletion internal/unionstore/union_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ type MemBuffer interface {
}

type FlushMetrics struct {
WaitDuration time.Duration
WaitDuration time.Duration
TotalDuration time.Duration
}

var (
Expand Down
1 change: 1 addition & 0 deletions txnkv/transaction/pipelined_flush.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ func (c *twoPhaseCommitter) commitFlushedMutations(bo *retry.Backoffer) error {
"[pipelined dml] start to commit transaction",
zap.Int("keys", c.txn.GetMemBuffer().Len()),
zap.Duration("flush_wait_duration", c.txn.GetMemBuffer().GetFlushMetrics().WaitDuration),
zap.Duration("total_duration", c.txn.GetMemBuffer().GetFlushMetrics().TotalDuration),
zap.String("size", units.HumanSize(float64(c.txn.GetMemBuffer().Size()))),
zap.Uint64("startTS", c.startTS),
)
Expand Down
Loading