Skip to content

Commit

Permalink
print duration of purge
Browse files Browse the repository at this point in the history
Signed-off-by: longjiquan <[email protected]>
  • Loading branch information
longjiquan committed Mar 5, 2024
1 parent ff8bc73 commit ea861e3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/proxy/connection/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ func (s *connectionManager) purgeIfNumOfClientsExceed() {
return
}

log.Info("number of client infos exceed limit, purge the oldest",
begin := time.Now()

log := log.With(
zap.Int64("num", int64(s.clientInfos.Len())),
zap.Int64("limit", paramtable.Get().ProxyCfg.MaxConnectionNum.GetAsInt64()))

log.Info("number of client infos exceed limit, ready to purge the oldest")

diffNum := int64(s.clientInfos.Len()) - paramtable.Get().ProxyCfg.MaxConnectionNum.GetAsInt64()
q := newPriorityQueueWithCap(int(diffNum + 1))
s.clientInfos.Range(func(identifier int64, info clientInfo) bool {
Expand All @@ -86,6 +90,10 @@ func (s *connectionManager) purgeIfNumOfClientsExceed() {
log.Info("remove client info", info.GetLogger()...)
}
}

log.Info("purge client infos done",
zap.Duration("cost", time.Since(begin)),
zap.Int64("num after purge", int64(s.clientInfos.Len())))
}

func (s *connectionManager) Register(ctx context.Context, identifier int64, info *commonpb.ClientInfo) {
Expand Down

0 comments on commit ea861e3

Please sign in to comment.