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

introduce buffersize for granular control #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ func fillupDefaults(config *Config) {
if config.Influx.BatchSize == 0 {
config.Influx.BatchSize = DefaultIDBBatchSize
}
if config.Influx.BufferSize == 0 {
config.Influx.BufferSize = DefaultIDBBufferSize
}
if config.Influx.HTTPTimeout == 0 {
config.Influx.HTTPTimeout = DefaultIDBTimeout
}
Expand Down
2 changes: 2 additions & 0 deletions defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const (

// DefaultIDBBatchSize to use if user has not provided in the config
DefaultIDBBatchSize = 1024 * 100
// DefaultIDBBufferSize to use if user has not provided in the config
DefaultIDBBufferSize = 1024
//DefaultIDBBatchFreq is 2 seconds
DefaultIDBBatchFreq = 2000
//DefaultIDBAccumulatorFreq is 2 seconds
Expand Down
6 changes: 4 additions & 2 deletions influx.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type InfluxConfig struct {
Recreate bool `json:"recreate"`
Measurement string `json:"measurement"`
BatchSize int `json:"batchsize"`
BufferSize int `json:"buffersize"`
BatchFrequency int `json:"batchfrequency"`
HTTPTimeout int `json:"http-timeout"`
RetentionPolicy string `json:"retention-policy"`
Expand Down Expand Up @@ -206,12 +207,13 @@ func dbBatchWriteM(jctx *JCtx) {
}

batchSize := jctx.config.Influx.BatchSize
batchMCh := make(chan *batchWMData, batchSize/4)
bufferSize := jctx.config.Influx.BufferSize
batchMCh := make(chan *batchWMData, bufferSize)
jctx.influxCtx.batchWMCh = batchMCh

// wake up periodically and perform batch write into InfluxDB
bFreq := jctx.config.Influx.BatchFrequency
jLog(jctx, fmt.Sprintln("batch size:", batchSize, "batch frequency:", bFreq))
jLog(jctx, fmt.Sprintln("batch size:", batchSize, "batch frequency:", bFreq, "buffer size:", bufferSize))

ticker := time.NewTicker(time.Duration(bFreq) * time.Millisecond)
go func() {
Expand Down