From 1c54a3abff0aaf392cd50ea6ee92c77363b7341d Mon Sep 17 00:00:00 2001 From: Tigran Najaryan Date: Tue, 23 Sep 2025 20:55:10 -0400 Subject: [PATCH] Update benchmark charts Also include trace size in the charts. --- benchmarks/makefile | 2 +- benchmarks/size_test.go | 164 +++++++++++++++----------- docs/benchmarks.html | 139 +++++++++++++++------- go/pdata/traces/otlp2stef_unsorted.go | 10 +- 4 files changed, 196 insertions(+), 119 deletions(-) diff --git a/benchmarks/makefile b/benchmarks/makefile index dcd11104..31cc4494 100644 --- a/benchmarks/makefile +++ b/benchmarks/makefile @@ -67,4 +67,4 @@ bench-stat: bench-stat-cli .PHONY: update-charts update-charts: - UPDATE_BENCH_HTML=1 go test -run TestMetricsSize\|TestMetricsMultipart -bench \(alizeNative\|Pdata\) + UPDATE_BENCH_HTML=1 go test -run TestMetricsSize\|Multipart -bench \(alizeNative\|Pdata\) -benchtime=5s diff --git a/benchmarks/size_test.go b/benchmarks/size_test.go index b30ffe17..0c5845c7 100644 --- a/benchmarks/size_test.go +++ b/benchmarks/size_test.go @@ -22,78 +22,10 @@ import ( "github.com/splunk/stef/benchmarks/generators" "github.com/splunk/stef/benchmarks/testutils" "github.com/splunk/stef/go/otel/oteltef" - converters "github.com/splunk/stef/go/pdata/traces" + "github.com/splunk/stef/go/pdata/traces" "github.com/splunk/stef/go/pkg" ) -func TestTracesMultipart(t *testing.T) { - u := ptrace.ProtoUnmarshaler{} - - fileNames := []string{"testdata/astronomy-oteltraces.zst", "testdata/hipstershop-oteltraces.zst"} - - for _, fileName := range fileNames { - fmt.Println("======= " + fileName) - - var otlpParts [][]byte - traces, err := testutils.ReadMultipartOTLPFileGeneric( - fileName, func(data []byte) (any, error) { - otlpParts = append(otlpParts, data) - return u.UnmarshalTraces(data) - }, - ) - require.NoError(t, err) - - compressions := []pkg.Compression{pkg.CompressionNone, pkg.CompressionZstd} - sorteds := []bool{false, true} - - for _, sorted := range sorteds { - if sorted { - fmt.Println("Sorted") - } else { - fmt.Println("Unsorted") - } - - for _, compression := range compressions { - - outputBuf := &pkg.MemChunkWriter{} - writer, err := oteltef.NewSpansWriter(outputBuf, pkg.WriterOptions{Compression: compression}) - require.NoError(t, err) - - converter := converters.OtlpToStefUnsorted{Sorted: sorted} - - otlpSize := 0 - for i := 0; i < len(traces); i++ { - err = converter.Convert(traces[i].(ptrace.Traces), writer) - require.NoError(t, err) - - err = writer.Flush() - require.NoError(t, err) - - if compression == pkg.CompressionNone { - otlpSize += len(otlpParts[i]) - } else { - otlpZstd := testutils.CompressZstd(otlpParts[i]) - otlpSize += len(otlpZstd) - } - } - - stefSize := len(outputBuf.Bytes()) - - if compression == pkg.CompressionZstd { - fmt.Println("zstd") - } else { - fmt.Println("none") - } - fmt.Printf("Traces OTLP: %8d\n", otlpSize) - fmt.Printf("Traces STEF: %8d\n", stefSize) - fmt.Printf( - "Ratio: %8.2f\n", float64(otlpSize)/float64(stefSize), - ) - } - } - } -} - func replaceExt(fname string, ext string) string { idx := strings.Index(fname, ".") if idx > 0 { @@ -270,7 +202,7 @@ func TestMetricsMultipart(t *testing.T) { compressions := []string{"none", "zstd"} - chart.BeginSection("Size Benchmarks - Many Batches, Multipart") + chart.BeginSection("Size - Many Batches, Multipart Metrics") for _, compression := range compressions { for _, dataset := range datasets { @@ -375,3 +307,95 @@ func stefCompression2str(compression pkg.Compression) any { } panic("unknown compression") } + +func TestTracesMultipart(t *testing.T) { + u := ptrace.ProtoUnmarshaler{} + + fileNames := []string{"astronomy-oteltraces", "hipstershop-oteltraces"} + + chart.BeginSection("Size - Many Batches, Multipart Traces") + + for _, fileName := range fileNames { + fmt.Println("======= " + fileName) + + var otlpParts [][]byte + traceData, err := testutils.ReadMultipartOTLPFileGeneric( + "testdata/"+fileName+".zst", func(data []byte) (any, error) { + otlpParts = append(otlpParts, data) + return u.UnmarshalTraces(data) + }, + ) + require.NoError(t, err) + + compressions := []pkg.Compression{pkg.CompressionNone, pkg.CompressionZstd} + sorteds := []bool{false, true} + + for _, compression := range compressions { + var compressionStr string + if compression == pkg.CompressionZstd { + compressionStr = "zstd" + } else { + compressionStr = "none" + } + fmt.Println(compressionStr) + + chart.BeginChart("Dataset: "+fileName, t) + + otlpSize := 0 + for i := 0; i < len(traceData); i++ { + if compression == pkg.CompressionNone { + otlpSize += len(otlpParts[i]) + } else { + otlpZstd := testutils.CompressZstd(otlpParts[i]) + otlpSize += len(otlpZstd) + } + } + + chart.Record( + nil, "OTLP", "Size in bytes, compression="+compressionStr, + float64(otlpSize), + ) + + for _, sorted := range sorteds { + var sortedStr string + if sorted { + sortedStr = "Sorted" + } else { + sortedStr = "Unsorted" + } + fmt.Println(sortedStr) + + outputBuf := &pkg.MemChunkWriter{} + writer, err := oteltef.NewSpansWriter(outputBuf, pkg.WriterOptions{Compression: compression}) + require.NoError(t, err) + + converter := traces.OtlpToStefUnsorted{Sorted: sorted} + + for i := 0; i < len(traceData); i++ { + err = converter.Convert(traceData[i].(ptrace.Traces), writer) + require.NoError(t, err) + + err = writer.Flush() + require.NoError(t, err) + } + + stefSize := len(outputBuf.Bytes()) + + fmt.Printf("Traces OTLP: %8d\n", otlpSize) + fmt.Printf("Traces STEF: %8d\n", stefSize) + fmt.Printf( + "Ratio: %8.2f\n", float64(otlpSize)/float64(stefSize), + ) + + chart.Record( + nil, "STEF "+sortedStr, "Size in bytes, compression="+compressionStr, + float64(stefSize), + ) + } + chart.EndChart( + "Bytes", + charts.WithColorsOpts(opts.Colors{"#87BB62"}), + ) + } + } +} diff --git a/docs/benchmarks.html b/docs/benchmarks.html index d25dba97..1a64102f 100644 --- a/docs/benchmarks.html +++ b/docs/benchmarks.html @@ -9,137 +9,186 @@

Size Benchmarks - One Large Batch

-
+
-
+
-
+
-

Size Benchmarks - Many Batches, Multipart

+

Size - Many Batches, Multipart Metrics

-
+
-
+
-
+
-
+
+

Size - Many Batches, Multipart Traces

+
+
+
+ + + +
+
+
+ + + +
+
+
+ + + +
+
+
+ + +

Speed Benchmarks

-
+
-
+
-
+
-
+
\ No newline at end of file diff --git a/go/pdata/traces/otlp2stef_unsorted.go b/go/pdata/traces/otlp2stef_unsorted.go index 17a9ab3a..fc4e6d9c 100644 --- a/go/pdata/traces/otlp2stef_unsorted.go +++ b/go/pdata/traces/otlp2stef_unsorted.go @@ -79,7 +79,7 @@ func (d *OtlpToStefUnsorted) Convert(src ptrace.Traces, writer *oteltef.SpansWri for k := 0; k < smm.Spans().Len(); k++ { m := smm.Spans().At(k) - span2span(m, writer.Record.Span(), otlp2stef) + span2span(m, writer.Record.Span(), otlp2stef, d.Sorted) if err := writer.Write(); err != nil { return err } @@ -117,7 +117,7 @@ func sortSpans(spans ptrace.SpanSlice) { ) } -func span2span(src ptrace.Span, dst *oteltef.Span, otlp2tef *otlptools.Otlp2Stef) { +func span2span(src ptrace.Span, dst *oteltef.Span, otlp2tef *otlptools.Otlp2Stef, sorted bool) { dst.SetTraceID(pkg.Bytes(src.TraceID().String())) dst.SetSpanID(pkg.Bytes(src.SpanID().String())) dst.SetParentSpanID(pkg.Bytes(src.ParentSpanID().String())) @@ -127,7 +127,11 @@ func span2span(src ptrace.Span, dst *oteltef.Span, otlp2tef *otlptools.Otlp2Stef dst.SetEndTimeUnixNano(uint64(src.EndTimestamp())) dst.SetKind(uint64(src.Kind())) dst.SetTraceState(src.TraceState().AsRaw()) - otlp2tef.MapUnsorted(src.Attributes(), dst.Attributes()) + if sorted { + otlp2tef.MapSorted(src.Attributes(), dst.Attributes()) + } else { + otlp2tef.MapUnsorted(src.Attributes(), dst.Attributes()) + } dst.SetDroppedAttributesCount(uint64(src.DroppedAttributesCount())) dst.Status().SetCode(uint64(src.Status().Code()))