From 12b87b20882fcf72fe190da2fa91e1c231bbb3c5 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 24 Jun 2020 19:36:55 +0300 Subject: [PATCH] app/vmselect/netstorage: reset big result values every 10 seconds instead of after processing every time series This should reduce GC pressure when processing time series with big number of rows --- app/vmselect/netstorage/netstorage.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/vmselect/netstorage/netstorage.go b/app/vmselect/netstorage/netstorage.go index 5ba2f7a875..f69c0a1964 100644 --- a/app/vmselect/netstorage/netstorage.go +++ b/app/vmselect/netstorage/netstorage.go @@ -13,6 +13,7 @@ import ( "github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil" "github.com/VictoriaMetrics/VictoriaMetrics/lib/decimal" "github.com/VictoriaMetrics/VictoriaMetrics/lib/encoding" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/fasttime" "github.com/VictoriaMetrics/VictoriaMetrics/lib/handshake" "github.com/VictoriaMetrics/VictoriaMetrics/lib/logger" "github.com/VictoriaMetrics/VictoriaMetrics/lib/netutil" @@ -85,6 +86,7 @@ func init() { func timeseriesWorker(workerID uint) { var rs Result + var rsLastResetTime uint64 for tsw := range timeseriesWorkCh { rss := tsw.rss if time.Until(rss.deadline.Deadline) < 0 { @@ -100,9 +102,11 @@ func timeseriesWorker(workerID uint) { } tsw.rowsProcessed = len(rs.Values) tsw.doneCh <- nil - if cap(rs.Values) > 1024*1024 && 4*len(rs.Values) < cap(rs.Values) { + currentTime := fasttime.UnixTimestamp() + if cap(rs.Values) > 1024*1024 && 4*len(rs.Values) < cap(rs.Values) && currentTime-rsLastResetTime > 10 { // Reset rs in order to preseve memory usage after processing big time series with millions of rows. rs = Result{} + rsLastResetTime = currentTime } } }