Updates based on @otoolp's PR comments
parent
c6f2f9cec2
commit
bb398daf75
|
@ -84,8 +84,6 @@ func NewServer(c *Config, buildInfo *BuildInfo) (*Server, error) {
|
|||
tsdbStore := tsdb.NewStore(c.Data.Dir)
|
||||
tsdbStore.EngineOptions.Config = c.Data
|
||||
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
||||
s := &Server{
|
||||
buildInfo: *buildInfo,
|
||||
err: make(chan error),
|
||||
|
|
|
@ -83,7 +83,7 @@ func NewHandler(requireAuthentication, loggingEnabled, writeTrace bool, statMap
|
|||
mux: pat.New(),
|
||||
requireAuthentication: requireAuthentication,
|
||||
Logger: log.New(os.Stderr, "[http] ", log.LstdFlags),
|
||||
loggingEnabled: false,
|
||||
loggingEnabled: loggingEnabled,
|
||||
WriteTrace: writeTrace,
|
||||
statMap: statMap,
|
||||
}
|
||||
|
|
|
@ -48,9 +48,9 @@ const (
|
|||
DefaultFlushMemorySizeThreshold = 5 * 1024 * 1024 // 5MB
|
||||
DefaultMaxMemorySizeThreshold = 100 * 1024 * 1024 // 100MB
|
||||
DefaultIndexCompactionAge = time.Minute
|
||||
DefaultIndexMinimumCompactionInterval = time.Minute
|
||||
DefaultIndexCompactionFileCount = 5
|
||||
DefaultIndexCompactionFullAge = time.Minute
|
||||
DefaultIndexMinCompactionInterval = time.Minute
|
||||
DefaultIndexMinCompactionFileCount = 5
|
||||
DefaultIndexCompactionFullAge = 5 * time.Minute
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
|
@ -83,11 +83,11 @@ type Config struct {
|
|||
|
||||
// IndexMinimumCompactionInterval specifies the minimum amount of time that must
|
||||
// pass after a compaction before another compaction is run
|
||||
IndexMinimumCompactionInterval time.Duration `toml:"index-minimum-compaction-interval"`
|
||||
IndexMinCompactionInterval time.Duration `toml:"index-min-compaction-interval"`
|
||||
|
||||
// IndexCompactionFileCount specifies the minimum number of data files that
|
||||
// must be eligible for compaction before actually running one
|
||||
IndexCompactionFileCount int `toml:"index-compaction-file-count"`
|
||||
IndexMinCompactionFileCount int `toml:"index-compaction-min-file-count"`
|
||||
|
||||
// IndexCompactionFullAge specifies how long after the last write was received
|
||||
// in the WAL that a full compaction should be performed.
|
||||
|
@ -113,9 +113,9 @@ func NewConfig() Config {
|
|||
WALFlushMemorySizeThreshold: DefaultFlushMemorySizeThreshold,
|
||||
WALMaxMemorySizeThreshold: DefaultMaxMemorySizeThreshold,
|
||||
IndexCompactionAge: DefaultIndexCompactionAge,
|
||||
IndexCompactionFileCount: DefaultIndexCompactionFileCount,
|
||||
IndexMinCompactionFileCount: DefaultIndexMinCompactionFileCount,
|
||||
IndexCompactionFullAge: DefaultIndexCompactionFullAge,
|
||||
IndexMinimumCompactionInterval: DefaultIndexMinimumCompactionInterval,
|
||||
IndexMinCompactionInterval: DefaultIndexMinCompactionInterval,
|
||||
|
||||
QueryLogEnabled: true,
|
||||
}
|
||||
|
|
|
@ -101,9 +101,9 @@ type Engine struct {
|
|||
RotateFileSize uint32
|
||||
SkipCompaction bool
|
||||
CompactionAge time.Duration
|
||||
CompactionFileCount int
|
||||
MinCompactionFileCount int
|
||||
IndexCompactionFullAge time.Duration
|
||||
IndexMinimumCompactionInterval time.Duration
|
||||
IndexMinCompactionInterval time.Duration
|
||||
MaxPointsPerBlock int
|
||||
RotateBlockSize int
|
||||
|
||||
|
@ -144,9 +144,9 @@ func NewEngine(path string, walPath string, opt tsdb.EngineOptions) tsdb.Engine
|
|||
WAL: w,
|
||||
RotateFileSize: DefaultRotateFileSize,
|
||||
CompactionAge: opt.Config.IndexCompactionAge,
|
||||
CompactionFileCount: opt.Config.IndexCompactionFileCount,
|
||||
MinCompactionFileCount: opt.Config.IndexMinCompactionFileCount,
|
||||
IndexCompactionFullAge: opt.Config.IndexCompactionFullAge,
|
||||
IndexMinimumCompactionInterval: opt.Config.IndexMinimumCompactionInterval,
|
||||
IndexMinCompactionInterval: opt.Config.IndexMinCompactionInterval,
|
||||
MaxPointsPerBlock: DefaultMaxPointsPerBlock,
|
||||
RotateBlockSize: DefaultRotateBlockSize,
|
||||
}
|
||||
|
@ -762,10 +762,10 @@ func (e *Engine) shouldCompact() bool {
|
|||
since := time.Since(e.lastCompactionTime)
|
||||
deletesPending := len(e.deletes) > 0
|
||||
e.filesLock.RUnlock()
|
||||
if running || since < e.IndexMinimumCompactionInterval || deletesPending {
|
||||
if running || since < e.IndexMinCompactionInterval || deletesPending {
|
||||
return false
|
||||
}
|
||||
return len(e.filesToCompact()) >= e.CompactionFileCount
|
||||
return len(e.filesToCompact()) >= e.MinCompactionFileCount
|
||||
}
|
||||
|
||||
func (e *Engine) filesToCompact() dataFiles {
|
||||
|
|
Loading…
Reference in New Issue