From 7d8f9b0978760c59c363cee96bda4203becbab3c Mon Sep 17 00:00:00 2001 From: LHHDZ Date: Sat, 22 Jul 2023 21:24:46 +0800 Subject: [PATCH] remote-write receiver: reuse 'ref' to optimize multiple samples for same series (#12580) reuse 'ref' to optimize multi samples processing efficiency Signed-off-by: changlin.shi --- storage/remote/write_handler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/remote/write_handler.go b/storage/remote/write_handler.go index ac4caa619b..96d8cbd903 100644 --- a/storage/remote/write_handler.go +++ b/storage/remote/write_handler.go @@ -119,8 +119,9 @@ func (h *writeHandler) write(ctx context.Context, req *prompb.WriteRequest) (err samplesWithInvalidLabels++ continue } + var ref storage.SeriesRef for _, s := range ts.Samples { - _, err = app.Append(0, labels, s.Timestamp, s.Value) + ref, err = app.Append(ref, labels, s.Timestamp, s.Value) if err != nil { unwrappedErr := errors.Unwrap(err) if unwrappedErr == nil {