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

Function runPRW2HandleFromScratch

pkg/util/push/push_test.go:250–259  ·  view source on GitHub ↗

runPRW2HandleFromScratch simulates handlePRW2 without using the sync.Pool.

(ctx context.Context, body []byte, contentLength int, overrides *validation.Overrides, userID string)

Source from the content-addressed store, hash-verified

248
249// runPRW2HandleFromScratch simulates handlePRW2 without using the sync.Pool.
250func runPRW2HandleFromScratch(ctx context.Context, body []byte, contentLength int, overrides *validation.Overrides, userID string) error {
251 var req cortexpb.PreallocWriteRequestV2
252 defer cortexpb.ReuseWriteRequestV2(&req)
253
254 if err := util.ParseProtoReader(ctx, bytes.NewReader(body), contentLength, benchMaxRecvMsgSize, &req, util.RawSnappy); err != nil {
255 return err
256 }
257 _, err := convertV2RequestToV1(&req, overrides.EnableTypeAndUnitLabels(userID))
258 return err
259}
260
261// Benchmark_HandlePRW2_PoolVsScratch compares two allocation strategies for the PRW2 parse path.
262// - pool: req := cortexpb.PreallocWriteRequestV2FromPool() + defer ReuseWriteRequestV2(req)

Callers 1

Calls 4

ReuseWriteRequestV2Function · 0.92
ParseProtoReaderFunction · 0.92
convertV2RequestToV1Function · 0.85

Tested by

no test coverage detected