From aa3e46a02da7faa9a13086732e6fd77bee12329d Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 9 Nov 2020 10:54:24 +0200 Subject: [PATCH] lib/promscrape: further reduce memory usage for per-scrape target labels by making a copy of actually used labels Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/825 --- lib/promscrape/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/promscrape/config.go b/lib/promscrape/config.go index 4d9cff2079..4961397e98 100644 --- a/lib/promscrape/config.go +++ b/lib/promscrape/config.go @@ -643,10 +643,10 @@ func appendScrapeWork(dst []ScrapeWork, swc *scrapeWorkConfig, target string, ex promrelabel.SortLabels(originalLabels) labels = promrelabel.ApplyRelabelConfigs(labels, 0, swc.relabelConfigs, false) labels = promrelabel.RemoveMetaLabels(labels[:0], labels) - // Remove references to already deleted labels, so GC could clean strings for label name and label value. + // Remove references to already deleted labels, so GC could clean strings for label name and label value past len(labels). // This should reduce memory usage when relabeling creates big number of temporary labels with long names and/or values. // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/825 for details. - promrelabel.CleanLabels(labels[len(labels):cap(labels)]) + labels = append([]prompbmarshal.Label{}, labels...) if len(labels) == 0 { // Drop target without labels.