Skip to content

Commit c197ab2

Browse files
authored
[chore] Attempt to make benchmarks more resilient (#14227)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Attempt to make the benchmarks more resilient by increasing their walltimes to the microsecond range <!-- Issue number if applicable --> #### Link to tracking issue Updates #14111
1 parent a9f386e commit c197ab2

File tree

2 files changed

+28
-35
lines changed

2 files changed

+28
-35
lines changed

config/confighttp/compressor_test.go

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func BenchmarkCompression(b *testing.B) {
3535
function: benchmarkCompressionNoConcurrency,
3636
},
3737
}
38-
payload := make([]byte, 10<<20)
38+
payload := make([]byte, 10<<22)
3939
buffer := bytes.Buffer{}
4040
buffer.Grow(len(payload))
4141

@@ -55,38 +55,31 @@ func BenchmarkCompression(b *testing.B) {
5555

5656
func benchmarkCompression(b *testing.B, _ configcompression.Type, buf *bytes.Buffer, payload []byte) {
5757
// Concurrency Enabled
58-
59-
b.Run("compress", func(b *testing.B) {
60-
stringReader := strings.NewReader(string(payload))
61-
stringReadCloser := io.NopCloser(stringReader)
62-
var enc io.Writer
63-
b.ResetTimer()
64-
b.ReportAllocs()
65-
b.SetBytes(int64(len(payload)))
66-
for b.Loop() {
67-
enc, _ = zstd.NewWriter(nil, zstd.WithEncoderConcurrency(5))
68-
enc.(writeCloserReset).Reset(buf)
69-
_, copyErr := io.Copy(enc, stringReadCloser)
70-
require.NoError(b, copyErr)
71-
}
72-
})
58+
stringReader := strings.NewReader(string(payload))
59+
stringReadCloser := io.NopCloser(stringReader)
60+
var enc io.Writer
61+
b.ResetTimer()
62+
b.ReportAllocs()
63+
b.SetBytes(int64(len(payload)))
64+
for b.Loop() {
65+
enc, _ = zstd.NewWriter(nil, zstd.WithEncoderConcurrency(5))
66+
enc.(writeCloserReset).Reset(buf)
67+
_, copyErr := io.Copy(enc, stringReadCloser)
68+
require.NoError(b, copyErr)
69+
}
7370
}
7471

7572
func benchmarkCompressionNoConcurrency(b *testing.B, _ configcompression.Type, buf *bytes.Buffer, payload []byte) {
76-
// Concurrency Disabled
77-
78-
b.Run("compress", func(b *testing.B) {
79-
stringReader := strings.NewReader(string(payload))
80-
stringReadCloser := io.NopCloser(stringReader)
81-
var enc io.Writer
82-
b.ResetTimer()
83-
b.ReportAllocs()
84-
b.SetBytes(int64(len(payload)))
85-
for b.Loop() {
86-
enc, _ = zstd.NewWriter(nil, zstd.WithEncoderConcurrency(1))
87-
enc.(writeCloserReset).Reset(buf)
88-
_, copyErr := io.Copy(enc, stringReadCloser)
89-
require.NoError(b, copyErr)
90-
}
91-
})
73+
stringReader := strings.NewReader(string(payload))
74+
stringReadCloser := io.NopCloser(stringReader)
75+
var enc io.Writer
76+
b.ResetTimer()
77+
b.ReportAllocs()
78+
b.SetBytes(int64(len(payload)))
79+
for b.Loop() {
80+
enc, _ = zstd.NewWriter(nil, zstd.WithEncoderConcurrency(1))
81+
enc.(writeCloserReset).Reset(buf)
82+
_, copyErr := io.Copy(enc, stringReadCloser)
83+
require.NoError(b, copyErr)
84+
}
9285
}

processor/batchprocessor/batch_processor_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ func BenchmarkTraceSizeSpanCount(b *testing.B) {
716716
}
717717
}
718718

719-
func BenchmarkBatchMetricProcessor(b *testing.B) {
719+
func BenchmarkBatchMetricProcessor2k(b *testing.B) {
720720
b.StopTimer()
721721
cfg := &Config{
722722
Timeout: 100 * time.Millisecond,
@@ -725,7 +725,7 @@ func BenchmarkBatchMetricProcessor(b *testing.B) {
725725
runMetricsProcessorBenchmark(b, cfg)
726726
}
727727

728-
func BenchmarkMultiBatchMetricProcessor(b *testing.B) {
728+
func BenchmarkMultiBatchMetricProcessor2k(b *testing.B) {
729729
b.StopTimer()
730730
cfg := &Config{
731731
Timeout: 100 * time.Millisecond,
@@ -742,7 +742,7 @@ func runMetricsProcessorBenchmark(b *testing.B, cfg *Config) {
742742
require.NoError(b, err)
743743
require.NoError(b, metrics.Start(ctx, componenttest.NewNopHost()))
744744

745-
const metricsPerRequest = 1000
745+
const metricsPerRequest = 150_000
746746
b.StartTimer()
747747
b.RunParallel(func(pb *testing.PB) {
748748
for pb.Next() {

0 commit comments

Comments
 (0)