MCPcopy
hub / github.com/prometheus/prometheus / BenchmarkSampleSend

Function BenchmarkSampleSend

storage/remote/queue_manager_test.go:1314–1349  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1312 | tee ${bench}.txt
1313*/
1314func 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.
1352func BenchmarkStoreSeries(b *testing.B) {

Callers

nothing calls this directly

Calls 12

GenerateRecordsFunction · 0.92
NewNopWriteClientFunction · 0.85
testDefaultQueueConfigFunction · 0.85
newTestQueueManagerFunction · 0.85
DurationMethod · 0.80
RunMethod · 0.65
StoreSeriesMethod · 0.65
AppendMethod · 0.65
UpdateSeriesSegmentMethod · 0.65
SeriesResetMethod · 0.65
StartMethod · 0.45
StopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…