Skip to content

Commit

Permalink
update opt
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangxinmeng1 committed Jun 19, 2024
1 parent 5434788 commit ae16652
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions pkg/vm/engine/tae/db/checkpoint/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,9 @@ func WithReserveWALEntryCount(count uint64) Option {
r.options.reservedWALEntryCount = count
}
}

func WithStartupLatancy(latency time.Duration) Option {
return func(r *runner) {
r.options.startupLatency = latency
}
}
9 changes: 7 additions & 2 deletions pkg/vm/engine/tae/db/checkpoint/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ type runner struct {
checkpointBlockRows int
checkpointSize int

startupLatency time.Duration

reservedWALEntryCount uint64
}

Expand Down Expand Up @@ -768,8 +770,8 @@ func (r *runner) tryScheduleCheckpoint(endts types.TS) {
logutil.Infof("Checkpoint is disable")
return
}
if time.Since(r.openTime) < time.Minute*5 {
logutil.Infof("Checkpoint is disable. TN has been running for %v", time.Since(r.openTime))
if time.Since(r.openTime) < r.options.startupLatency {
logutil.Infof("Checkpoint is disable. TN has been running for %v, startup latency %v", time.Since(r.openTime), r.options.startupLatency)
return
}
entry := r.MaxCheckpoint()
Expand Down Expand Up @@ -859,6 +861,9 @@ func (r *runner) fillDefaults() {
if r.options.checkpointSize <= 0 {
r.options.checkpointSize = logtail.DefaultCheckpointSize
}
if r.options.startupLatency <= 0 {
r.options.startupLatency = time.Minute * 5
}
}

func (r *runner) onWaitWaitableItems(items ...any) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/vm/engine/tae/db/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ func Open(ctx context.Context, dirname string, opts *options.Options) (db *DB, e
checkpoint.WithMinIncrementalInterval(opts.CheckpointCfg.IncrementalInterval),
checkpoint.WithGlobalMinCount(int(opts.CheckpointCfg.GlobalMinCount)),
checkpoint.WithGlobalVersionInterval(opts.CheckpointCfg.GlobalVersionInterval),
checkpoint.WithReserveWALEntryCount(opts.CheckpointCfg.ReservedWALEntryCount))
checkpoint.WithReserveWALEntryCount(opts.CheckpointCfg.ReservedWALEntryCount),
checkpoint.WithStartupLatancy(opts.CheckpointCfg.StartupLatency))

now := time.Now()
checkpointed, ckpLSN, valid, err := db.BGCheckpointRunner.Replay(dataFactory)
Expand Down
1 change: 1 addition & 0 deletions pkg/vm/engine/tae/options/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type CheckpointCfg struct {
GCCheckpointInterval time.Duration
DisableGCCheckpoint bool
ReservedWALEntryCount uint64
StartupLatency time.Duration

// only for test
// it is used to control the block rows of the checkpoint
Expand Down
4 changes: 4 additions & 0 deletions pkg/vm/engine/tae/testutils/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func WithQuickScanAndCKPOpts2(in *options.Options, factor int) (opts *options.Op
opts.CheckpointCfg.MinCount = int64(factor)
opts.CheckpointCfg.IncrementalInterval *= time.Duration(factor)
opts.CheckpointCfg.BlockRows = 10
opts.CheckpointCfg.StartupLatency = time.Millisecond
opts.Ctx = context.Background()
return opts
}
Expand All @@ -54,6 +55,7 @@ func WithQuickScanAndCKPOpts(in *options.Options) (opts *options.Options) {
opts.CheckpointCfg.GCCheckpointInterval = time.Millisecond * 10
opts.CheckpointCfg.BlockRows = 10
opts.CheckpointCfg.GlobalVersionInterval = time.Millisecond * 10
opts.CheckpointCfg.StartupLatency = time.Millisecond
opts.GCCfg = new(options.GCCfg)
opts.GCCfg.ScanGCInterval = time.Millisecond * 10
opts.GCCfg.GCTTL = time.Millisecond * 1
Expand All @@ -76,6 +78,7 @@ func WithQuickScanAndCKPAndGCOpts(in *options.Options) (opts *options.Options) {
opts.CheckpointCfg.IncrementalInterval = time.Millisecond * 20
opts.CheckpointCfg.GlobalMinCount = 1
opts.CheckpointCfg.BlockRows = 10
opts.CheckpointCfg.StartupLatency = time.Millisecond

opts.GCCfg = new(options.GCCfg)
// ScanGCInterval does not need to be too fast, because manual gc will be performed in the case
Expand All @@ -100,6 +103,7 @@ func WithOpts(in *options.Options, factor float64) (opts *options.Options) {
opts.CheckpointCfg.IncrementalInterval = time.Second * 2 * time.Duration(factor)
opts.CheckpointCfg.GlobalMinCount = 10
opts.CheckpointCfg.BlockRows = 10
opts.CheckpointCfg.StartupLatency = time.Millisecond
opts.Ctx = context.Background()
return opts
}
Expand Down

0 comments on commit ae16652

Please sign in to comment.