Skip to content

Commit 0c5e2f1

Browse files
Update benchmark charts (#159)
Also include trace size in the charts.
1 parent fd112e0 commit 0c5e2f1

File tree

4 files changed

+196
-119
lines changed

4 files changed

+196
-119
lines changed

benchmarks/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ bench-stat: bench-stat-cli
6767

6868
.PHONY: update-charts
6969
update-charts:
70-
UPDATE_BENCH_HTML=1 go test -run TestMetricsSize\|TestMetricsMultipart -bench \(alizeNative\|Pdata\)
70+
UPDATE_BENCH_HTML=1 go test -run TestMetricsSize\|Multipart -bench \(alizeNative\|Pdata\) -benchtime=5s

benchmarks/size_test.go

Lines changed: 94 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -22,78 +22,10 @@ import (
2222
"github.com/splunk/stef/benchmarks/generators"
2323
"github.com/splunk/stef/benchmarks/testutils"
2424
"github.com/splunk/stef/go/otel/oteltef"
25-
converters "github.com/splunk/stef/go/pdata/traces"
25+
"github.com/splunk/stef/go/pdata/traces"
2626
"github.com/splunk/stef/go/pkg"
2727
)
2828

29-
func TestTracesMultipart(t *testing.T) {
30-
u := ptrace.ProtoUnmarshaler{}
31-
32-
fileNames := []string{"testdata/astronomy-oteltraces.zst", "testdata/hipstershop-oteltraces.zst"}
33-
34-
for _, fileName := range fileNames {
35-
fmt.Println("======= " + fileName)
36-
37-
var otlpParts [][]byte
38-
traces, err := testutils.ReadMultipartOTLPFileGeneric(
39-
fileName, func(data []byte) (any, error) {
40-
otlpParts = append(otlpParts, data)
41-
return u.UnmarshalTraces(data)
42-
},
43-
)
44-
require.NoError(t, err)
45-
46-
compressions := []pkg.Compression{pkg.CompressionNone, pkg.CompressionZstd}
47-
sorteds := []bool{false, true}
48-
49-
for _, sorted := range sorteds {
50-
if sorted {
51-
fmt.Println("Sorted")
52-
} else {
53-
fmt.Println("Unsorted")
54-
}
55-
56-
for _, compression := range compressions {
57-
58-
outputBuf := &pkg.MemChunkWriter{}
59-
writer, err := oteltef.NewSpansWriter(outputBuf, pkg.WriterOptions{Compression: compression})
60-
require.NoError(t, err)
61-
62-
converter := converters.OtlpToStefUnsorted{Sorted: sorted}
63-
64-
otlpSize := 0
65-
for i := 0; i < len(traces); i++ {
66-
err = converter.Convert(traces[i].(ptrace.Traces), writer)
67-
require.NoError(t, err)
68-
69-
err = writer.Flush()
70-
require.NoError(t, err)
71-
72-
if compression == pkg.CompressionNone {
73-
otlpSize += len(otlpParts[i])
74-
} else {
75-
otlpZstd := testutils.CompressZstd(otlpParts[i])
76-
otlpSize += len(otlpZstd)
77-
}
78-
}
79-
80-
stefSize := len(outputBuf.Bytes())
81-
82-
if compression == pkg.CompressionZstd {
83-
fmt.Println("zstd")
84-
} else {
85-
fmt.Println("none")
86-
}
87-
fmt.Printf("Traces OTLP: %8d\n", otlpSize)
88-
fmt.Printf("Traces STEF: %8d\n", stefSize)
89-
fmt.Printf(
90-
"Ratio: %8.2f\n", float64(otlpSize)/float64(stefSize),
91-
)
92-
}
93-
}
94-
}
95-
}
96-
9729
func replaceExt(fname string, ext string) string {
9830
idx := strings.Index(fname, ".")
9931
if idx > 0 {
@@ -270,7 +202,7 @@ func TestMetricsMultipart(t *testing.T) {
270202

271203
compressions := []string{"none", "zstd"}
272204

273-
chart.BeginSection("Size Benchmarks - Many Batches, Multipart")
205+
chart.BeginSection("Size - Many Batches, Multipart Metrics")
274206

275207
for _, compression := range compressions {
276208
for _, dataset := range datasets {
@@ -375,3 +307,95 @@ func stefCompression2str(compression pkg.Compression) any {
375307
}
376308
panic("unknown compression")
377309
}
310+
311+
func TestTracesMultipart(t *testing.T) {
312+
u := ptrace.ProtoUnmarshaler{}
313+
314+
fileNames := []string{"astronomy-oteltraces", "hipstershop-oteltraces"}
315+
316+
chart.BeginSection("Size - Many Batches, Multipart Traces")
317+
318+
for _, fileName := range fileNames {
319+
fmt.Println("======= " + fileName)
320+
321+
var otlpParts [][]byte
322+
traceData, err := testutils.ReadMultipartOTLPFileGeneric(
323+
"testdata/"+fileName+".zst", func(data []byte) (any, error) {
324+
otlpParts = append(otlpParts, data)
325+
return u.UnmarshalTraces(data)
326+
},
327+
)
328+
require.NoError(t, err)
329+
330+
compressions := []pkg.Compression{pkg.CompressionNone, pkg.CompressionZstd}
331+
sorteds := []bool{false, true}
332+
333+
for _, compression := range compressions {
334+
var compressionStr string
335+
if compression == pkg.CompressionZstd {
336+
compressionStr = "zstd"
337+
} else {
338+
compressionStr = "none"
339+
}
340+
fmt.Println(compressionStr)
341+
342+
chart.BeginChart("Dataset: "+fileName, t)
343+
344+
otlpSize := 0
345+
for i := 0; i < len(traceData); i++ {
346+
if compression == pkg.CompressionNone {
347+
otlpSize += len(otlpParts[i])
348+
} else {
349+
otlpZstd := testutils.CompressZstd(otlpParts[i])
350+
otlpSize += len(otlpZstd)
351+
}
352+
}
353+
354+
chart.Record(
355+
nil, "OTLP", "Size in bytes, compression="+compressionStr,
356+
float64(otlpSize),
357+
)
358+
359+
for _, sorted := range sorteds {
360+
var sortedStr string
361+
if sorted {
362+
sortedStr = "Sorted"
363+
} else {
364+
sortedStr = "Unsorted"
365+
}
366+
fmt.Println(sortedStr)
367+
368+
outputBuf := &pkg.MemChunkWriter{}
369+
writer, err := oteltef.NewSpansWriter(outputBuf, pkg.WriterOptions{Compression: compression})
370+
require.NoError(t, err)
371+
372+
converter := traces.OtlpToStefUnsorted{Sorted: sorted}
373+
374+
for i := 0; i < len(traceData); i++ {
375+
err = converter.Convert(traceData[i].(ptrace.Traces), writer)
376+
require.NoError(t, err)
377+
378+
err = writer.Flush()
379+
require.NoError(t, err)
380+
}
381+
382+
stefSize := len(outputBuf.Bytes())
383+
384+
fmt.Printf("Traces OTLP: %8d\n", otlpSize)
385+
fmt.Printf("Traces STEF: %8d\n", stefSize)
386+
fmt.Printf(
387+
"Ratio: %8.2f\n", float64(otlpSize)/float64(stefSize),
388+
)
389+
390+
chart.Record(
391+
nil, "STEF "+sortedStr, "Size in bytes, compression="+compressionStr,
392+
float64(stefSize),
393+
)
394+
}
395+
chart.EndChart(
396+
"Bytes",
397+
charts.WithColorsOpts(opts.Colors{"#87BB62"}),
398+
)
399+
}
400+
}
401+
}

0 commit comments

Comments
 (0)