Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.5] Adjustable TSI Compaction Threshold #9672

Merged
merged 1 commit into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions etc/config.sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@
# to cache snapshotting.
# max-concurrent-compactions = 0

# The threshold, in bytes, when an index write-ahead log file will compact
# into an index file. Lower sizes will cause log files to be compacted more
# quickly and result in lower heap usage at the expense of write throughput.
# Higher sizes will be compacted less frequently, store more series in-memory,
# and provide higher write throughput.
# Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k).
# Values without a size suffix are in bytes.
# max-index-log-file-size = "1m"

# The maximum series allowed per database before writes are dropped. This limit can prevent
# high cardinality issues at the database level. This limit can be disabled by setting it to
# 0.
Expand Down
12 changes: 12 additions & 0 deletions tsdb/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const (
// DefaultMaxConcurrentCompactions is the maximum number of concurrent full and level compactions
// that can run at one time. A value of 0 results in 50% of runtime.GOMAXPROCS(0) used at runtime.
DefaultMaxConcurrentCompactions = 0

// DefaultMaxIndexLogFileSize is the default threshold, in bytes, when an index
// write-ahead log file will compact into an index file.
DefaultMaxIndexLogFileSize = 1 * 1024 * 1024 // 1MB
)

// Config holds the configuration for the tsbd package.
Expand Down Expand Up @@ -94,6 +98,12 @@ type Config struct {
// not affected by this limit. A value of 0 limits compactions to runtime.GOMAXPROCS(0).
MaxConcurrentCompactions int `toml:"max-concurrent-compactions"`

// MaxIndexLogFileSize is the threshold, in bytes, when an index write-ahead log file will
// compact into an index file. Lower sizes will cause log files to be compacted more quickly
// and result in lower heap usage at the expense of write throughput. Higher sizes will
// be compacted less frequently, store more series in-memory, and provide higher write throughput.
MaxIndexLogFileSize toml.Size `toml:"max-index-log-file-size"`

TraceLoggingEnabled bool `toml:"trace-logging-enabled"`
}

Expand All @@ -114,6 +124,8 @@ func NewConfig() Config {
MaxValuesPerTag: DefaultMaxValuesPerTag,
MaxConcurrentCompactions: DefaultMaxConcurrentCompactions,

MaxIndexLogFileSize: toml.Size(DefaultMaxIndexLogFileSize),

TraceLoggingEnabled: false,
}
}
Expand Down
6 changes: 3 additions & 3 deletions tsdb/index/tsi1/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func init() {
DefaultPartitionN = uint64(i)
}

tsdb.RegisterIndex(IndexName, func(_ uint64, db, path string, _ *tsdb.SeriesIDSet, sfile *tsdb.SeriesFile, _ tsdb.EngineOptions) tsdb.Index {
idx := NewIndex(sfile, db, WithPath(path))
tsdb.RegisterIndex(IndexName, func(_ uint64, db, path string, _ *tsdb.SeriesIDSet, sfile *tsdb.SeriesFile, opt tsdb.EngineOptions) tsdb.Index {
idx := NewIndex(sfile, db, WithPath(path), WithMaximumLogFileSize(int64(opt.Config.MaxIndexLogFileSize)))
return idx
})
}
Expand Down Expand Up @@ -111,7 +111,7 @@ type Index struct {
// NewIndex returns a new instance of Index.
func NewIndex(sfile *tsdb.SeriesFile, database string, options ...IndexOption) *Index {
idx := &Index{
maxLogFileSize: DefaultMaxLogFileSize,
maxLogFileSize: tsdb.DefaultMaxIndexLogFileSize,
logger: zap.NewNop(),
version: Version,
sfile: sfile,
Expand Down
5 changes: 1 addition & 4 deletions tsdb/index/tsi1/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ import (
// Version is the current version of the TSI index.
const Version = 1

// DefaultMaxLogFileSize is the default compaction threshold.
const DefaultMaxLogFileSize = 5 * 1024 * 1024

// File extensions.
const (
LogFileExt = ".tsl"
Expand Down Expand Up @@ -97,7 +94,7 @@ func NewPartition(sfile *tsdb.SeriesFile, path string) *Partition {
seriesIDSet: tsdb.NewSeriesIDSet(),

// Default compaction thresholds.
MaxLogFileSize: DefaultMaxLogFileSize,
MaxLogFileSize: tsdb.DefaultMaxIndexLogFileSize,

// compactionEnabled: true,
compactionInterrupt: make(chan struct{}),
Expand Down