Skip to content

Commit

Permalink
perf: use gomaxprocs as batcher count
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Jan 14, 2024
1 parent b15bdd7 commit 3eea5d3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/chstorage/inserter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package chstorage

import (
"context"
"runtime"

"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/otel"
Expand Down Expand Up @@ -107,9 +108,10 @@ func NewInserter(c ClickhouseClient, opts InserterOptions) (*Inserter, error) {
}

if !opts.Sync {
inserter.metricBatches = make(chan pmetric.Metrics, 8)
jobs := runtime.GOMAXPROCS(0)
inserter.metricBatches = make(chan pmetric.Metrics, jobs)
ctx := context.Background()
for i := 0; i < 8; i++ {
for i := 0; i < jobs; i++ {
go func() {
if err := inserter.saveMetricBatches(ctx); err != nil {
panic(err)
Expand Down

0 comments on commit 3eea5d3

Please sign in to comment.