Merge pull request #1331 from influxdata/jmw-max-compactions

fix(tsm1): fix max concurrent compaction logic
pull/10616/head
Jeff Wendling 2018-11-09 10:27:22 -07:00 committed by GitHub
commit a935aced36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import (
"os"
"path/filepath"
"regexp"
"runtime"
"strings"
"sync"
"sync/atomic"
@ -207,6 +208,26 @@ func NewEngine(path string, idx *tsi1.Index, config Config, options ...EngineOpt
int(config.Compaction.Throughput),
int(config.Compaction.ThroughputBurst))
// determine max concurrent compactions informed by the system
maxCompactions := config.Compaction.MaxConcurrent
if maxCompactions == 0 {
maxCompactions = runtime.GOMAXPROCS(0) / 2 // Default to 50% of cores for compactions
// On systems with more cores, cap at 4 to reduce disk utilization.
if maxCompactions > 4 {
maxCompactions = 4
}
if maxCompactions < 1 {
maxCompactions = 1
}
}
// Don't allow more compactions to run than cores.
if maxCompactions > runtime.GOMAXPROCS(0) {
maxCompactions = runtime.GOMAXPROCS(0)
}
logger := zap.NewNop()
stats := &EngineStatistics{}
e := &Engine{
@ -229,8 +250,8 @@ func NewEngine(path string, idx *tsi1.Index, config Config, options ...EngineOpt
enableCompactionsOnOpen: true,
formatFileName: DefaultFormatFileName,
stats: stats,
compactionLimiter: limiter.NewFixed(config.Compaction.MaxConcurrent),
scheduler: newScheduler(stats, config.Compaction.MaxConcurrent),
compactionLimiter: limiter.NewFixed(maxCompactions),
scheduler: newScheduler(stats, maxCompactions),
}
for _, option := range options {