From 5ece938f3ce128c4772e459a0ff79d5c8d187616 Mon Sep 17 00:00:00 2001 From: Karsten Jeschkies Date: Wed, 17 Nov 2021 16:07:07 +0100 Subject: [PATCH] Run all benchmarks. (#4742) * Run all benchmarks. * Start debugging memchunk benchmark. * Do not iterate when closed. * Pass default tenant config. * Set default limits. * Fix two more benchmarks. * Enable cron trigger again. --- .drone/drone.jsonnet | 4 ++-- .drone/drone.yml | 6 +++--- pkg/chunkenc/memchunk.go | 4 ++++ pkg/ingester/checkpoint_test.go | 8 ++------ pkg/ingester/instance_test.go | 2 +- pkg/ingester/stream_test.go | 2 +- pkg/iter/entry_iterator.go | 2 -- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.drone/drone.jsonnet b/.drone/drone.jsonnet index 515640942a..3b75600d5f 100644 --- a/.drone/drone.jsonnet +++ b/.drone/drone.jsonnet @@ -337,13 +337,13 @@ local manifest(apps) = pipeline('manifest') { }, node: { type: 'no-parallel' }, steps: [ - run('LogQL', ['go test -mod=vendor -bench=Benchmark -benchtime 20x -timeout 120m ./pkg/logql/']) + run('All', ['go test -mod=vendor -bench=Benchmark -benchtime 20x -timeout 120m ./pkg/...']), ], trigger: { event: { include: ['cron'], }, - cron+: { + cron: { include: ['loki-bench'], }, }, diff --git a/.drone/drone.yml b/.drone/drone.yml index 4e82dbc22c..f566ce02a1 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -66,9 +66,9 @@ node: type: no-parallel steps: - commands: - - go test -mod=vendor -bench=Benchmark -benchtime 20x -timeout 120m ./pkg/logql/ + - go test -mod=vendor -bench=Benchmark -benchtime 20x -timeout 120m ./pkg/... image: grafana/loki-build-image:0.18.0 - name: LogQL + name: All trigger: cron: include: @@ -1004,6 +1004,6 @@ kind: secret name: deploy_config --- kind: signature -hmac: f6b69b7568765a77ee58c8db118be08c1db77953b9facb117c7849bcbc94d4f1 +hmac: 3d6580e7a97cbdc40b5185fdb0a9e2011fb92ad9ff3bc393a577b1306abc8bc4 ... diff --git a/pkg/chunkenc/memchunk.go b/pkg/chunkenc/memchunk.go index 4c5b00defe..ea1fbabebe 100644 --- a/pkg/chunkenc/memchunk.go +++ b/pkg/chunkenc/memchunk.go @@ -1129,6 +1129,10 @@ func newBufferedIterator(ctx context.Context, pool ReaderPool, b []byte) *buffer } func (si *bufferedIterator) Next() bool { + if si.closed { + return false + } + if !si.closed && si.reader == nil { // initialize reader now, hopefully reusing one of the previous readers si.reader = si.pool.GetReader(bytes.NewBuffer(si.origBytes)) diff --git a/pkg/ingester/checkpoint_test.go b/pkg/ingester/checkpoint_test.go index 072cc9f083..1ce248b750 100644 --- a/pkg/ingester/checkpoint_test.go +++ b/pkg/ingester/checkpoint_test.go @@ -500,16 +500,12 @@ func Benchmark_SeriesIterator(b *testing.B) { streams := buildStreams() instances := make([]*instance, 10) - limits, err := validation.NewOverrides(validation.Limits{ - MaxLocalStreamsPerUser: 1000, - IngestionRateMB: 1e4, - IngestionBurstSizeMB: 1e4, - }, nil) + limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(b, err) limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) for i := range instances { - inst := newInstance(defaultConfig(), fmt.Sprintf("instance %d", i), limiter, nil, noopWAL{}, NilMetrics, nil, nil) + inst := newInstance(defaultConfig(), fmt.Sprintf("instance %d", i), limiter, runtime.DefaultTenantConfigs(), noopWAL{}, NilMetrics, nil, nil) require.NoError(b, inst.Push(context.Background(), &logproto.PushRequest{ diff --git a/pkg/ingester/instance_test.go b/pkg/ingester/instance_test.go index 6970b037c5..23a10d2d43 100644 --- a/pkg/ingester/instance_test.go +++ b/pkg/ingester/instance_test.go @@ -296,7 +296,7 @@ func Benchmark_PushInstance(b *testing.B) { require.NoError(b, err) limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) - i := newInstance(&Config{}, "test", limiter, loki_runtime.DefaultTenantConfigs(), noopWAL{}, NilMetrics, &OnceSwitch{}, nil) + i := newInstance(&Config{IndexShards: 1}, "test", limiter, loki_runtime.DefaultTenantConfigs(), noopWAL{}, NilMetrics, &OnceSwitch{}, nil) ctx := context.Background() for n := 0; n < b.N; n++ { diff --git a/pkg/ingester/stream_test.go b/pkg/ingester/stream_test.go index dbfb5cf043..cb79f025c5 100644 --- a/pkg/ingester/stream_test.go +++ b/pkg/ingester/stream_test.go @@ -406,7 +406,7 @@ func Benchmark_PushStream(b *testing.B) { require.NoError(b, err) limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) - s := newStream(&Config{}, limiter, "fake", model.Fingerprint(0), ls, true, NilMetrics) + s := newStream(&Config{MaxChunkAge: 24 * time.Hour}, limiter, "fake", model.Fingerprint(0), ls, true, NilMetrics) t, err := newTailer("foo", `{namespace="loki-dev"}`, &fakeTailServer{}) require.NoError(b, err) diff --git a/pkg/iter/entry_iterator.go b/pkg/iter/entry_iterator.go index 8c3899bb70..f875cf32b3 100644 --- a/pkg/iter/entry_iterator.go +++ b/pkg/iter/entry_iterator.go @@ -379,7 +379,6 @@ func (i *queryClientIterator) Close() error { type nonOverlappingIterator struct { labels string - i int iterators []EntryIterator curr EntryIterator } @@ -403,7 +402,6 @@ func (i *nonOverlappingIterator) Next() bool { if i.curr != nil { i.curr.Close() } - i.i++ i.curr, i.iterators = i.iterators[0], i.iterators[1:] }