From c0b7f520366835ea354877d70c23079df21e4263 Mon Sep 17 00:00:00 2001 From: Jiquan Long Date: Thu, 30 Dec 2021 10:29:47 +0800 Subject: [PATCH] Make timeTickInterval of Proxy configurable (#14515) Signed-off-by: dragondriver --- internal/proxy/channels_time_ticker.go | 2 +- internal/proxy/proxy.go | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/internal/proxy/channels_time_ticker.go b/internal/proxy/channels_time_ticker.go index 90761c0639..5c41931f4b 100644 --- a/internal/proxy/channels_time_ticker.go +++ b/internal/proxy/channels_time_ticker.go @@ -111,7 +111,7 @@ func (ticker *channelsTimeTickerImpl) tick() error { } else { if stat.minTs > current { ticker.minTsStatistics[pchan] = stat.minTs - 1 - next := now + Timestamp(sendTimeTickMsgInterval) + next := now + Timestamp(Params.ProxyCfg.TimeTickInterval) if next > stat.maxTs { next = stat.maxTs } diff --git a/internal/proxy/proxy.go b/internal/proxy/proxy.go index 2642859998..2ae6eef16e 100644 --- a/internal/proxy/proxy.go +++ b/internal/proxy/proxy.go @@ -48,8 +48,8 @@ type UniqueID = typeutil.UniqueID // Timestamp is alias of typeutil.Timestamp type Timestamp = typeutil.Timestamp -const sendTimeTickMsgInterval = 200 * time.Millisecond -const channelMgrTickerInterval = 100 * time.Millisecond +// const sendTimeTickMsgInterval = 200 * time.Millisecond +// const channelMgrTickerInterval = 100 * time.Millisecond // make sure Proxy implements types.Proxy var _ types.Proxy = (*Proxy)(nil) @@ -238,8 +238,10 @@ func (node *Proxy) Init() error { } log.Debug("create task scheduler done", zap.String("role", typeutil.ProxyRole)) - log.Debug("create channels time ticker", zap.String("role", typeutil.ProxyRole)) - node.chTicker = newChannelsTimeTicker(node.ctx, channelMgrTickerInterval, []string{}, node.sched.getPChanStatistics, tsoAllocator) + syncTimeTickInterval := Params.ProxyCfg.TimeTickInterval / 2 + log.Debug("create channels time ticker", + zap.String("role", typeutil.ProxyRole), zap.Duration("syncTimeTickInterval", syncTimeTickInterval)) + node.chTicker = newChannelsTimeTicker(node.ctx, Params.ProxyCfg.TimeTickInterval/2, []string{}, node.sched.getPChanStatistics, tsoAllocator) log.Debug("create channels time ticker done", zap.String("role", typeutil.ProxyRole)) log.Debug("create metrics cache manager", zap.String("role", typeutil.ProxyRole)) @@ -262,12 +264,12 @@ func (node *Proxy) sendChannelsTimeTickLoop() { go func() { defer node.wg.Done() - // TODO(dragondriver): read this from config - timer := time.NewTicker(sendTimeTickMsgInterval) + timer := time.NewTicker(Params.ProxyCfg.TimeTickInterval) for { select { case <-node.ctx.Done(): + log.Info("send channels time tick loop exit") return case <-timer.C: stats, ts, err := node.chTicker.getMinTsStatistics()