Updates based on @otoolp's PR comments

pull/4308/head
Paul Dix 2015-10-04 15:43:18 -04:00
parent c6f2f9cec2
commit bb398daf75
4 changed files with 40 additions and 42 deletions

View File

@ -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),

View File

@ -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,
}

View File

@ -45,12 +45,12 @@ const (
DefaultPartitionSizeThreshold = 50 * 1024 * 1024 // 50MB
// Default WAL settings for the TSM1 WAL
DefaultFlushMemorySizeThreshold = 5 * 1024 * 1024 // 5MB
DefaultMaxMemorySizeThreshold = 100 * 1024 * 1024 // 100MB
DefaultIndexCompactionAge = time.Minute
DefaultIndexMinimumCompactionInterval = time.Minute
DefaultIndexCompactionFileCount = 5
DefaultIndexCompactionFullAge = time.Minute
DefaultFlushMemorySizeThreshold = 5 * 1024 * 1024 // 5MB
DefaultMaxMemorySizeThreshold = 100 * 1024 * 1024 // 100MB
DefaultIndexCompactionAge = 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.
@ -104,18 +104,18 @@ func NewConfig() Config {
WALFlushInterval: toml.Duration(DefaultWALFlushInterval),
WALPartitionFlushDelay: toml.Duration(DefaultWALPartitionFlushDelay),
WALLoggingEnabled: true,
WALReadySeriesSize: DefaultReadySeriesSize,
WALCompactionThreshold: DefaultCompactionThreshold,
WALMaxSeriesSize: DefaultMaxSeriesSize,
WALFlushColdInterval: toml.Duration(DefaultFlushColdInterval),
WALPartitionSizeThreshold: DefaultPartitionSizeThreshold,
WALFlushMemorySizeThreshold: DefaultFlushMemorySizeThreshold,
WALMaxMemorySizeThreshold: DefaultMaxMemorySizeThreshold,
IndexCompactionAge: DefaultIndexCompactionAge,
IndexCompactionFileCount: DefaultIndexCompactionFileCount,
IndexCompactionFullAge: DefaultIndexCompactionFullAge,
IndexMinimumCompactionInterval: DefaultIndexMinimumCompactionInterval,
WALLoggingEnabled: true,
WALReadySeriesSize: DefaultReadySeriesSize,
WALCompactionThreshold: DefaultCompactionThreshold,
WALMaxSeriesSize: DefaultMaxSeriesSize,
WALFlushColdInterval: toml.Duration(DefaultFlushColdInterval),
WALPartitionSizeThreshold: DefaultPartitionSizeThreshold,
WALFlushMemorySizeThreshold: DefaultFlushMemorySizeThreshold,
WALMaxMemorySizeThreshold: DefaultMaxMemorySizeThreshold,
IndexCompactionAge: DefaultIndexCompactionAge,
IndexMinCompactionFileCount: DefaultIndexMinCompactionFileCount,
IndexCompactionFullAge: DefaultIndexCompactionFullAge,
IndexMinCompactionInterval: DefaultIndexMinCompactionInterval,
QueryLogEnabled: true,
}

View File

@ -98,14 +98,14 @@ type Engine struct {
WAL *Log
RotateFileSize uint32
SkipCompaction bool
CompactionAge time.Duration
CompactionFileCount int
IndexCompactionFullAge time.Duration
IndexMinimumCompactionInterval time.Duration
MaxPointsPerBlock int
RotateBlockSize int
RotateFileSize uint32
SkipCompaction bool
CompactionAge time.Duration
MinCompactionFileCount int
IndexCompactionFullAge time.Duration
IndexMinCompactionInterval time.Duration
MaxPointsPerBlock int
RotateBlockSize int
// filesLock is only for modifying and accessing the files slice
filesLock sync.RWMutex
@ -140,15 +140,15 @@ func NewEngine(path string, walPath string, opt tsdb.EngineOptions) tsdb.Engine
logger: log.New(os.Stderr, "[tsm1] ", log.LstdFlags),
// TODO: this is the function where we can inject a check against the in memory collisions
HashSeriesField: hashSeriesField,
WAL: w,
RotateFileSize: DefaultRotateFileSize,
CompactionAge: opt.Config.IndexCompactionAge,
CompactionFileCount: opt.Config.IndexCompactionFileCount,
IndexCompactionFullAge: opt.Config.IndexCompactionFullAge,
IndexMinimumCompactionInterval: opt.Config.IndexMinimumCompactionInterval,
MaxPointsPerBlock: DefaultMaxPointsPerBlock,
RotateBlockSize: DefaultRotateBlockSize,
HashSeriesField: hashSeriesField,
WAL: w,
RotateFileSize: DefaultRotateFileSize,
CompactionAge: opt.Config.IndexCompactionAge,
MinCompactionFileCount: opt.Config.IndexMinCompactionFileCount,
IndexCompactionFullAge: opt.Config.IndexCompactionFullAge,
IndexMinCompactionInterval: opt.Config.IndexMinCompactionInterval,
MaxPointsPerBlock: DefaultMaxPointsPerBlock,
RotateBlockSize: DefaultRotateBlockSize,
}
e.WAL.Index = e
@ -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 {