mirror of
https://github.com/prometheus/prometheus
synced 2025-01-27 01:44:00 +00:00
feat: add microbenchmarks for OM CT parsing (#14933)
* test: benchmark OM CT parsing Signed-off-by: Manik Rana <manikrana54@gmail.com> * refac: move OM ct benchmark to promparse_test Signed-off-by: Manik Rana <manikrana54@gmail.com> * chore: stricter comparison Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com> Signed-off-by: Manik Rana <Manikrana54@gmail.com> * feat: use richer OM test data Signed-off-by: Manik Rana <manikrana54@gmail.com> * refac: move parse-ct test outside of inner loop Signed-off-by: Manik Rana <manikrana54@gmail.com> * refac: separate benchmarks for om and prom parsers Signed-off-by: Manik Rana <manikrana54@gmail.com> * chore: remove unused code Signed-off-by: Manik Rana <manikrana54@gmail.com> * chore: remove more unused code Signed-off-by: Manik Rana <manikrana54@gmail.com> * refac: rename to BenchmarkOMParseCreatedTimestamp Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com> Signed-off-by: Manik Rana <Manikrana54@gmail.com> --------- Signed-off-by: Manik Rana <manikrana54@gmail.com> Signed-off-by: Manik Rana <Manikrana54@gmail.com> Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com> Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
This commit is contained in:
parent
bcd9ce1d43
commit
98cd80b2e2
64
model/textparse/omtestdata.txt
Normal file
64
model/textparse/omtestdata.txt
Normal file
@ -0,0 +1,64 @@
|
||||
# HELP go_build_info Build information about the main Go module.
|
||||
# TYPE go_build_info gauge
|
||||
go_build_info{checksum="",path="",version=""} 1.0
|
||||
# HELP promhttp_metric_handler_errors Total number of internal errors encountered by the promhttp metric handler.
|
||||
# TYPE promhttp_metric_handler_errors counter
|
||||
promhttp_metric_handler_errors_total{cause="encoding"} 0.0
|
||||
promhttp_metric_handler_errors_created{cause="encoding"} 1.726839813016397e+09
|
||||
promhttp_metric_handler_errors_total{cause="gathering"} 0.0
|
||||
promhttp_metric_handler_errors_created{cause="gathering"} 1.726839813016395e+09
|
||||
# HELP rpc_durations_histogram_seconds RPC latency distributions.
|
||||
# TYPE rpc_durations_histogram_seconds histogram
|
||||
rpc_durations_histogram_seconds_bucket{le="-0.00099"} 0
|
||||
rpc_durations_histogram_seconds_bucket{le="-0.00089"} 0
|
||||
rpc_durations_histogram_seconds_bucket{le="-0.0007899999999999999"} 0
|
||||
rpc_durations_histogram_seconds_bucket{le="-0.0006899999999999999"} 0
|
||||
rpc_durations_histogram_seconds_bucket{le="-0.0005899999999999998"} 0
|
||||
rpc_durations_histogram_seconds_bucket{le="-0.0004899999999999998"} 0
|
||||
rpc_durations_histogram_seconds_bucket{le="-0.0003899999999999998"} 0
|
||||
rpc_durations_histogram_seconds_bucket{le="-0.0002899999999999998"} 3 # {dummyID="17783"} -0.0003825067330956884 1.7268398142239082e+09
|
||||
rpc_durations_histogram_seconds_bucket{le="-0.0001899999999999998"} 5 # {dummyID="84741"} -0.00020178290006788965 1.726839814829977e+09
|
||||
rpc_durations_histogram_seconds_bucket{le="-8.999999999999979e-05"} 5
|
||||
rpc_durations_histogram_seconds_bucket{le="1.0000000000000216e-05"} 8 # {dummyID="19206"} -4.6156147425468016e-05 1.7268398151337721e+09
|
||||
rpc_durations_histogram_seconds_bucket{le="0.00011000000000000022"} 9 # {dummyID="3974"} 9.528436760156754e-05 1.726839814526797e+09
|
||||
rpc_durations_histogram_seconds_bucket{le="0.00021000000000000023"} 11 # {dummyID="29640"} 0.00017459624183458996 1.7268398139220061e+09
|
||||
rpc_durations_histogram_seconds_bucket{le="0.0003100000000000002"} 15 # {dummyID="9818"} 0.0002791130914009552 1.7268398149821382e+09
|
||||
rpc_durations_histogram_seconds_bucket{le="0.0004100000000000002"} 15
|
||||
rpc_durations_histogram_seconds_bucket{le="0.0005100000000000003"} 15
|
||||
rpc_durations_histogram_seconds_bucket{le="0.0006100000000000003"} 15
|
||||
rpc_durations_histogram_seconds_bucket{le="0.0007100000000000003"} 15
|
||||
rpc_durations_histogram_seconds_bucket{le="0.0008100000000000004"} 15
|
||||
rpc_durations_histogram_seconds_bucket{le="0.0009100000000000004"} 15
|
||||
rpc_durations_histogram_seconds_bucket{le="+Inf"} 15
|
||||
rpc_durations_histogram_seconds_sum -8.452185437166741e-05
|
||||
rpc_durations_histogram_seconds_count 15
|
||||
rpc_durations_histogram_seconds_created 1.726839813016302e+09
|
||||
# HELP rpc_durations_seconds RPC latency distributions.
|
||||
# TYPE rpc_durations_seconds summary
|
||||
rpc_durations_seconds{service="exponential",quantile="0.5"} 7.689368882420941e-07
|
||||
rpc_durations_seconds{service="exponential",quantile="0.9"} 1.6537614174305048e-06
|
||||
rpc_durations_seconds{service="exponential",quantile="0.99"} 2.0965499063061924e-06
|
||||
rpc_durations_seconds_sum{service="exponential"} 2.0318666372575776e-05
|
||||
rpc_durations_seconds_count{service="exponential"} 22
|
||||
rpc_durations_seconds_created{service="exponential"} 1.7268398130168908e+09
|
||||
rpc_durations_seconds{service="normal",quantile="0.5"} -5.066758674917046e-06
|
||||
rpc_durations_seconds{service="normal",quantile="0.9"} 0.0002935723711788224
|
||||
rpc_durations_seconds{service="normal",quantile="0.99"} 0.0003023094636293776
|
||||
rpc_durations_seconds_sum{service="normal"} -8.452185437166741e-05
|
||||
rpc_durations_seconds_count{service="normal"} 15
|
||||
rpc_durations_seconds_created{service="normal"} 1.726839813016714e+09
|
||||
rpc_durations_seconds{service="uniform",quantile="0.5"} 9.005014931474918e-05
|
||||
rpc_durations_seconds{service="uniform",quantile="0.9"} 0.00017801230208182325
|
||||
rpc_durations_seconds{service="uniform",quantile="0.99"} 0.00018641524538180192
|
||||
rpc_durations_seconds_sum{service="uniform"} 0.0011666095700533677
|
||||
rpc_durations_seconds_count{service="uniform"} 11
|
||||
rpc_durations_seconds_created{service="uniform"} 1.72683981301684e+09
|
||||
# HELP rpc_requests Total number of RPC requests received.
|
||||
# TYPE rpc_requests counter
|
||||
rpc_requests_total{service="exponential"} 22.0
|
||||
rpc_requests_created{service="exponential"} 1.726839813016893e+09
|
||||
rpc_requests_total{service="normal"} 15.0
|
||||
rpc_requests_created{service="normal"} 1.726839813016717e+09
|
||||
rpc_requests_total{service="uniform"} 11.0
|
||||
rpc_requests_created{service="uniform"} 1.7268398130168471e+09
|
||||
# EOF
|
@ -16,6 +16,7 @@ package textparse
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus/common/model"
|
||||
@ -992,3 +993,46 @@ go_gc_duration_seconds_created`)
|
||||
require.Equal(t, "go_gc_duration_seconds", string(copyParser.l.b[copyParser.offsets[0]:copyParser.offsets[1]]))
|
||||
require.False(t, copyParser.skipCTSeries)
|
||||
}
|
||||
|
||||
func BenchmarkOMParseCreatedTimestamp(b *testing.B) {
|
||||
for parserName, parser := range map[string]func([]byte, *labels.SymbolTable) Parser{
|
||||
"openmetrics": func(b []byte, st *labels.SymbolTable) Parser {
|
||||
return NewOpenMetricsParser(b, st)
|
||||
},
|
||||
"openmetrics-skip-ct": func(b []byte, st *labels.SymbolTable) Parser {
|
||||
return NewOpenMetricsParser(b, st, WithOMParserCTSeriesSkipped())
|
||||
},
|
||||
} {
|
||||
f, err := os.Open("omtestdata.txt")
|
||||
require.NoError(b, err)
|
||||
defer f.Close()
|
||||
|
||||
buf, err := io.ReadAll(f)
|
||||
require.NoError(b, err)
|
||||
|
||||
b.Run(parserName+"/parse-ct/"+"omtestdata.txt", func(b *testing.B) {
|
||||
b.SetBytes(int64(len(buf) / promtestdataSampleCount))
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
|
||||
st := labels.NewSymbolTable()
|
||||
for i := 0; i < b.N; i += promtestdataSampleCount {
|
||||
p := parser(buf, st)
|
||||
|
||||
Outer:
|
||||
for i < b.N {
|
||||
t, err := p.Next()
|
||||
switch t {
|
||||
case EntryInvalid:
|
||||
if errors.Is(err, io.EOF) {
|
||||
break Outer
|
||||
}
|
||||
b.Fatal(err)
|
||||
case EntrySeries:
|
||||
p.CreatedTimestamp()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ const (
|
||||
promtestdataSampleCount = 410
|
||||
)
|
||||
|
||||
func BenchmarkParse(b *testing.B) {
|
||||
func BenchmarkPromParse(b *testing.B) {
|
||||
for parserName, parser := range map[string]func([]byte, *labels.SymbolTable) Parser{
|
||||
"prometheus": NewPromParser,
|
||||
"openmetrics": func(b []byte, st *labels.SymbolTable) Parser {
|
||||
|
Loading…
Reference in New Issue
Block a user