mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
fix rwv2 build write request benchmark, also change how the memory usage
is reported for these benchmarks to more accurately reflect what's actually allocated Signed-off-by: Callum Styan <callumstyan@gmail.com>
This commit is contained in:
parent
b8d1336d42
commit
51f09fa6f4
|
@ -1859,13 +1859,6 @@ func BenchmarkBuildWriteRequest(b *testing.B) {
|
||||||
}
|
}
|
||||||
pBuf := proto.NewBuffer(nil)
|
pBuf := proto.NewBuffer(nil)
|
||||||
|
|
||||||
// Warmup buffers
|
|
||||||
for i := 0; i < 10; i++ {
|
|
||||||
populateTimeSeries(batch, seriesBuff, true, true)
|
|
||||||
buildWriteRequest(noopLogger, seriesBuff, nil, pBuf, &buff, nil, "snappy")
|
|
||||||
}
|
|
||||||
|
|
||||||
b.ResetTimer()
|
|
||||||
totalSize := 0
|
totalSize := 0
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
populateTimeSeries(batch, seriesBuff, true, true)
|
populateTimeSeries(batch, seriesBuff, true, true)
|
||||||
|
@ -1897,45 +1890,43 @@ func BenchmarkBuildWriteRequest(b *testing.B) {
|
||||||
|
|
||||||
func BenchmarkBuildV2WriteRequest(b *testing.B) {
|
func BenchmarkBuildV2WriteRequest(b *testing.B) {
|
||||||
noopLogger := log.NewNopLogger()
|
noopLogger := log.NewNopLogger()
|
||||||
type testcase struct {
|
bench := func(b *testing.B, batch []timeSeries) {
|
||||||
batch []timeSeries
|
|
||||||
}
|
|
||||||
testCases := []testcase{
|
|
||||||
{createDummyTimeSeries(2)},
|
|
||||||
{createDummyTimeSeries(10)},
|
|
||||||
{createDummyTimeSeries(100)},
|
|
||||||
}
|
|
||||||
for _, tc := range testCases {
|
|
||||||
symbolTable := writev2.NewSymbolTable()
|
symbolTable := writev2.NewSymbolTable()
|
||||||
buff := make([]byte, 0)
|
buff := make([]byte, 0)
|
||||||
seriesBuff := make([]writev2.TimeSeries, len(tc.batch))
|
seriesBuff := make([]writev2.TimeSeries, len(batch))
|
||||||
for i := range seriesBuff {
|
for i := range seriesBuff {
|
||||||
seriesBuff[i].Samples = []writev2.Sample{{}}
|
seriesBuff[i].Samples = []writev2.Sample{{}}
|
||||||
seriesBuff[i].Exemplars = []writev2.Exemplar{{}}
|
seriesBuff[i].Exemplars = []writev2.Exemplar{{}}
|
||||||
}
|
}
|
||||||
pBuf := []byte{}
|
pBuf := []byte{}
|
||||||
|
|
||||||
// Warmup buffers
|
|
||||||
for i := 0; i < 10; i++ {
|
|
||||||
populateV2TimeSeries(&symbolTable, tc.batch, seriesBuff, true, true)
|
|
||||||
buildV2WriteRequest(noopLogger, seriesBuff, symbolTable.Symbols(), &pBuf, &buff, nil, "snappy")
|
|
||||||
}
|
|
||||||
|
|
||||||
b.Run(fmt.Sprintf("%d-instances", len(tc.batch)), func(b *testing.B) {
|
|
||||||
totalSize := 0
|
totalSize := 0
|
||||||
for j := 0; j < b.N; j++ {
|
for i := 0; i < b.N; i++ {
|
||||||
populateV2TimeSeries(&symbolTable, tc.batch, seriesBuff, true, true)
|
populateV2TimeSeries(&symbolTable, batch, seriesBuff, true, true)
|
||||||
b.ResetTimer()
|
|
||||||
req, _, _, err := buildV2WriteRequest(noopLogger, seriesBuff, symbolTable.Symbols(), &pBuf, &buff, nil, "snappy")
|
req, _, _, err := buildV2WriteRequest(noopLogger, seriesBuff, symbolTable.Symbols(), &pBuf, &buff, nil, "snappy")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
symbolTable.Reset()
|
|
||||||
totalSize += len(req)
|
totalSize += len(req)
|
||||||
b.ReportMetric(float64(totalSize)/float64(b.N), "compressedSize/op")
|
b.ReportMetric(float64(totalSize)/float64(b.N), "compressedSize/op")
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
twoBatch := createDummyTimeSeries(2)
|
||||||
|
tenBatch := createDummyTimeSeries(10)
|
||||||
|
hundredBatch := createDummyTimeSeries(100)
|
||||||
|
|
||||||
|
b.Run("2 instances", func(b *testing.B) {
|
||||||
|
bench(b, twoBatch)
|
||||||
|
})
|
||||||
|
|
||||||
|
b.Run("10 instances", func(b *testing.B) {
|
||||||
|
bench(b, tenBatch)
|
||||||
|
})
|
||||||
|
|
||||||
|
b.Run("1k instances", func(b *testing.B) {
|
||||||
|
bench(b, hundredBatch)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDropOldTimeSeries(t *testing.T) {
|
func TestDropOldTimeSeries(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue