Fix DDL rate limit unit, and improve log (#19504)

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
This commit is contained in:
bigsheeper 2022-09-28 20:58:54 +08:00 committed by GitHub
parent 9dcee37e1c
commit 5405dedd2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 3 deletions

View File

@ -403,8 +403,8 @@ quotaAndLimits:
dql:
enabled: false
searchRate:
max: # vps, default no limit
min: # vps, default 0
max: # vps (vectors per second), default no limit
min: # vps (vectors per second), default 0
queryRate:
max: # qps, default no limit
min: # qps, default 0

View File

@ -124,7 +124,7 @@ func (rl *rateLimiter) registerLimiters() {
}
log.Info("RateLimiter register for rateType",
zap.String("rateType", internalpb.RateType_name[rt]),
zap.Float64("rate", r))
zap.String("rate", ratelimitutil.Limit(r).String()))
limit := ratelimitutil.Limit(r)
if limit < 0 {
limit = ratelimitutil.Inf

View File

@ -35,6 +35,9 @@ const (
defaultLowWaterLevel = float64(0.8)
// defaultHighWaterLevel is the default memory low water level.
defaultHighWaterLevel = float64(0.9)
// secondsPerMinute is used to convert minutes to seconds.
secondsPerMinute = 60.0
)
// quotaConfig is configuration for quota and limitations.
@ -164,6 +167,7 @@ func (p *quotaConfig) initDDLCollectionRate() {
return
}
p.DDLCollectionRate = p.Base.ParseFloatWithDefault("quotaAndLimits.ddl.collectionRate", defaultMax)
p.DDLCollectionRate /= secondsPerMinute
// [0 ~ Inf)
if p.DDLCollectionRate < 0 {
p.DDLCollectionRate = defaultMax
@ -176,6 +180,7 @@ func (p *quotaConfig) initDDLPartitionRate() {
return
}
p.DDLPartitionRate = p.Base.ParseFloatWithDefault("quotaAndLimits.ddl.partitionRate", defaultMax)
p.DDLPartitionRate /= secondsPerMinute
// [0 ~ Inf)
if p.DDLPartitionRate < 0 {
p.DDLPartitionRate = defaultMax
@ -188,6 +193,7 @@ func (p *quotaConfig) initDDLIndexRate() {
return
}
p.DDLIndexRate = p.Base.ParseFloatWithDefault("quotaAndLimits.ddl.indexRate", defaultMax)
p.DDLIndexRate /= secondsPerMinute
// [0 ~ Inf)
if p.DDLIndexRate < 0 {
p.DDLIndexRate = defaultMax
@ -200,6 +206,7 @@ func (p *quotaConfig) initDDLFlushRate() {
return
}
p.DDLFlushRate = p.Base.ParseFloatWithDefault("quotaAndLimits.ddl.flushRate", defaultMax)
p.DDLFlushRate /= secondsPerMinute
// [0 ~ Inf)
if p.DDLFlushRate < 0 {
p.DDLFlushRate = defaultMax
@ -212,6 +219,7 @@ func (p *quotaConfig) initDDLCompactionRate() {
return
}
p.DDLCompactionRate = p.Base.ParseFloatWithDefault("quotaAndLimits.ddl.compactionRate", defaultMax)
p.DDLCompactionRate /= secondsPerMinute
// [0 ~ Inf)
if p.DDLCompactionRate < 0 {
p.DDLCompactionRate = defaultMax

View File

@ -17,6 +17,7 @@
package ratelimitutil
import (
"fmt"
"math"
"sync"
"time"
@ -132,6 +133,14 @@ func (lim *Limiter) advance(now time.Time) (newNow time.Time, newLast time.Time,
return now, last, tokens
}
// String returns string of Limit.
func (limit Limit) String() string {
if limit == Inf {
return "+inf"
}
return fmt.Sprintf("%.4f", limit)
}
// tokensFromDuration is a unit conversion function from a time duration to the number of tokens
// which could be accumulated during that duration at a rate of limit tokens per second.
func (limit Limit) tokensFromDuration(d time.Duration) float64 {