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