Recommended CLI invocation(s): * export bench=sampleSend && go test ./storage/remote/... \ -run '^$' -bench '^BenchmarkSampleSend' \ -benchtime 1s -count 6 -cpu 2 -timeout 999m -benchmem \ | tee ${bench}.txt */
(b *testing.B)
| 1312 | | tee ${bench}.txt |
| 1313 | */ |
| 1314 | func BenchmarkSampleSend(b *testing.B) { |
| 1315 | // Send one sample per series, which is the typical remote_write case |
| 1316 | const numSamples = 1 |
| 1317 | const numSeries = 10000 |
| 1318 | |
| 1319 | recs := testwal.GenerateRecords(recCase{Series: numSeries, SamplesPerSeries: numSamples, ExtraLabels: extraLabels}) |
| 1320 | |
| 1321 | c := NewNopWriteClient() |
| 1322 | |
| 1323 | cfg := testDefaultQueueConfig() |
| 1324 | mcfg := config.DefaultMetadataConfig |
| 1325 | cfg.BatchSendDeadline = model.Duration(100 * time.Millisecond) |
| 1326 | cfg.MinShards = 20 |
| 1327 | cfg.MaxShards = 20 |
| 1328 | |
| 1329 | // todo: test with new proto type(s) |
| 1330 | for _, format := range []remoteapi.WriteMessageType{remoteapi.WriteV1MessageType, remoteapi.WriteV2MessageType} { |
| 1331 | b.Run(string(format), func(b *testing.B) { |
| 1332 | m := newTestQueueManager(b, cfg, mcfg, defaultFlushDeadline, c, format) |
| 1333 | m.StoreSeries(recs.Series, 0) |
| 1334 | |
| 1335 | // These should be received by the client. |
| 1336 | m.Start() |
| 1337 | defer m.Stop() |
| 1338 | |
| 1339 | b.ResetTimer() |
| 1340 | for i := 0; b.Loop(); i++ { |
| 1341 | m.Append(recs.Samples) |
| 1342 | m.UpdateSeriesSegment(recs.Series, i+1) // simulate what wlog.Watcher.garbageCollectSeries does |
| 1343 | m.SeriesReset(i + 1) |
| 1344 | } |
| 1345 | // Do not include shutdown |
| 1346 | b.StopTimer() |
| 1347 | }) |
| 1348 | } |
| 1349 | } |
| 1350 | |
| 1351 | // Check how long it takes to add N series, including external labels processing. |
| 1352 | func BenchmarkStoreSeries(b *testing.B) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…