tsdb: Cleanup compaction throughput code

pull/10166/head
Jacob Marble 2018-08-07 10:14:10 -07:00
parent 3c94ab188b
commit 786d637780
1 changed files with 6 additions and 14 deletions

View File

@ -233,31 +233,23 @@ func (s *Store) loadShards() error {
compactionSettings := []zapcore.Field{zap.Int("max_concurrent_compactions", lim)}
throughput := int(s.EngineOptions.Config.CompactThroughput)
throughputBurst := int(s.EngineOptions.Config.CompactThroughputBurst)
compactionSettings = append(
compactionSettings,
zap.Int("throughput_bytes_per_second", throughput),
zap.Int("throughput_bytes_per_second_burst", throughputBurst),
)
if throughput > 0 {
if throughputBurst < throughput {
throughputBurst = throughput
}
s.Logger.Info(
"Compaction throughput enabled",
zap.String("throughput_bytes_per_second", fmt.Sprintf("%d%%", throughput)),
zap.String("throughput_bytes_per_second_burst", fmt.Sprintf("%d%%", throughputBurst)),
)
s.EngineOptions.CompactionThroughputLimiter = limiter.NewRate(
throughput,
throughputBurst,
compactionSettings = append(
compactionSettings,
zap.Int("throughput_bytes_per_second", throughput),
zap.Int("throughput_bytes_per_second_burst", throughputBurst),
)
s.EngineOptions.CompactionThroughputLimiter = limiter.NewRate(throughput, throughputBurst)
} else {
compactionSettings = append(
compactionSettings,
zap.String("throughput_bytes_per_second", "unlimited"),
zap.String("throughput_bytes_per_second_burst", "unlimited"),
)
s.Logger.Info("Compaction throughput limit disabled")
}
s.Logger.Info("Compaction settings", compactionSettings...)