MCPcopy Create free account
hub / github.com/cortexproject/cortex / Benchmark_HandlePRW2_PoolVsScratch

Function Benchmark_HandlePRW2_PoolVsScratch

pkg/util/push/push_test.go:264–291  ·  view source on GitHub ↗

Benchmark_HandlePRW2_PoolVsScratch compares two allocation strategies for the PRW2 parse path. - pool: req := cortexpb.PreallocWriteRequestV2FromPool() + defer ReuseWriteRequestV2(req) - scratch: var req cortexpb.PreallocWriteRequestV2 + defer ReuseWriteRequestV2(&req)

(b *testing.B)

Source from the content-addressed store, hash-verified

262// - pool: req := cortexpb.PreallocWriteRequestV2FromPool() + defer ReuseWriteRequestV2(req)
263// - scratch: var req cortexpb.PreallocWriteRequestV2 + defer ReuseWriteRequestV2(&req)
264func Benchmark_HandlePRW2_PoolVsScratch(b *testing.B) {
265 var limits validation.Limits
266 flagext.DefaultValues(&limits)
267 overrides := validation.NewOverrides(limits, nil)
268
269 userID := "bench-user"
270 seriesNum := 100
271 ctx := user.InjectOrgID(context.Background(), userID)
272
273 for _, symCount := range []int{32, 128, 512, 2048, 4096} {
274 body, contentLength := makeEncodedPRW2Body(b, seriesNum, symCount)
275 name := fmt.Sprintf("symbols=%d", symCount)
276
277 b.Run("pool/"+name, func(b *testing.B) {
278 b.ReportAllocs()
279 for b.Loop() {
280 require.NoError(b, runPRW2HandleFromPool(ctx, body, contentLength, overrides, userID))
281 }
282 })
283
284 b.Run("scratch/"+name, func(b *testing.B) {
285 b.ReportAllocs()
286 for b.Loop() {
287 require.NoError(b, runPRW2HandleFromScratch(ctx, body, contentLength, overrides, userID))
288 }
289 })
290 }
291}
292
293func Test_convertV2RequestToV1_WithEnableTypeAndUnitLabels(t *testing.T) {
294 symbols := []string{"", "__name__", "test_metric1", "b", "c", "baz", "qux", "d", "e", "foo", "bar", "f", "g", "h", "i", "Test gauge for test purposes", "Maybe op/sec who knows (:", "Test counter for test purposes", "__type__", "exist type", "__unit__", "exist unit"}

Callers

nothing calls this directly

Calls 7

DefaultValuesFunction · 0.92
NewOverridesFunction · 0.92
makeEncodedPRW2BodyFunction · 0.85
runPRW2HandleFromPoolFunction · 0.85
runPRW2HandleFromScratchFunction · 0.85
LoopMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected