From 3e53daa9d4cf588a843eaba36d7d9291c2d0bb15 Mon Sep 17 00:00:00 2001 From: bwplotka Date: Tue, 4 Nov 2025 13:29:48 +0000 Subject: [PATCH] kill hist bench cleanup for now Signed-off-by: bwplotka --- tsdb/chunkenc/benchmark_test.go | 108 ++------------------------------ 1 file changed, 4 insertions(+), 104 deletions(-) diff --git a/tsdb/chunkenc/benchmark_test.go b/tsdb/chunkenc/benchmark_test.go index 0bdcd8f2db..bc54197a58 100644 --- a/tsdb/chunkenc/benchmark_test.go +++ b/tsdb/chunkenc/benchmark_test.go @@ -7,17 +7,15 @@ import ( "testing" "github.com/stretchr/testify/require" - - "github.com/prometheus/prometheus/model/histogram" ) /* export bench=chunkenc && go test \ - -run '^$' -bench '^BenchmarkChunkEnc' \ + -run '^$' -bench '^BenchmarkChunk' \ -benchtime 5s -count 6 -cpu 2 -timeout 999m \ | tee ${bench}.txt */ -func BenchmarkChunkEnc(b *testing.B) { +func BenchmarkChunk(b *testing.B) { r := rand.New(rand.NewSource(1)) for _, data := range []struct { @@ -47,13 +45,13 @@ func BenchmarkChunkEnc(b *testing.B) { } { b.Run("data="+data.name, func(b *testing.B) { b.Run("format=XOR", func(b *testing.B) { - benchmarkChunkEnc(b, data.deltas, func() Chunk { return NewXORChunk() }) + benchmarkChunk(b, data.deltas, func() Chunk { return NewXORChunk() }) }) }) } } -func benchmarkChunkEnc(b *testing.B, deltas func() (int64, float64), newChunk func() Chunk) { +func benchmarkChunk(b *testing.B, deltas func() (int64, float64), newChunk func() Chunk) { var ( t = int64(1234123324) v = 1243535.123 @@ -128,101 +126,3 @@ func benchmarkChunkEnc(b *testing.B, deltas func() (int64, float64), newChunk fu } }) } - -/* - export bench=histchunkenc && go test \ - -run '^$' -bench '^BenchmarkHistogramChunkEnc' \ - -benchtime 5s -count 6 -cpu 2 -timeout 999m \ - | tee ${bench}.txt -*/ -func BenchmarkHistogramChunkEnc(b *testing.B) { - // Create a histogram with a bunch of spans and buckets. - const ( - numSpans = 1000 - spanLength = 10 - ) - h := &histogram.Histogram{ - Schema: 0, - Count: 100, - Sum: 1000, - ZeroThreshold: 0.001, - ZeroCount: 5, - } - for range numSpans { - h.PositiveSpans = append(h.PositiveSpans, histogram.Span{Offset: 5, Length: spanLength}) - h.NegativeSpans = append(h.NegativeSpans, histogram.Span{Offset: 5, Length: spanLength}) - for j := range spanLength { - h.PositiveBuckets = append(h.PositiveBuckets, int64(j)) - h.NegativeBuckets = append(h.NegativeBuckets, int64(j)) - } - } - - // Measure encoding efficiency. - b.Run("op=Append", func(b *testing.B) { - b.ReportAllocs() - - for b.Loop() { - c := Chunk(NewHistogramChunk()) - - a, err := c.Appender() - if err != nil { - b.Fatalf("get appender: %s", err) - } - var stop bool - for i := int64(0); !stop; i++ { - _, stop, _, err = a.AppendHistogram(nil, i, h, true) - if err != nil { - b.Fatal(err) - } - } - b.ReportMetric(float64(len(c.Bytes())), "B/chunk") - } - }) - - // Create a chunk for decoding and compact benchmarks. - c := Chunk(NewHistogramChunk()) - a, err := c.Appender() - if err != nil { - b.Fatalf("get appender: %s", err) - } - var stop bool - for i := int64(0); !stop; i++ { - _, stop, _, err = a.AppendHistogram(nil, i, h, true) - if err != nil { - b.Fatal(err) - } - } - - // Measure decoding efficiency. - b.Run("op=Iterate", func(b *testing.B) { - b.ReportAllocs() - - var ( - sink *histogram.Histogram - it Iterator - ) - for i := 0; b.Loop(); { - b.ReportMetric(float64(len(c.Bytes())), "B/chunk") - - it := c.Iterator(it) - for it.Next() == ValFloat { - _, got := it.AtHistogram(h) - sink = got - i++ - } - if err := it.Err(); err != nil && !errors.Is(err, io.EOF) { - require.NoError(b, err) - } - _ = sink - } - }) - - // Measure size before and after compaction and it's efficiency. - b.Run("op=Compact", func(b *testing.B) { - for b.Loop() { - b.ReportMetric(float64(len(c.Bytes())), "B/chunk") - c.Compact() - b.ReportMetric(float64(len(c.Bytes())), "B/compacted_chunk") - } - }) -}