mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/promql: reduce memory allocations when searching for time series pairs with identical labelsets in q1 op q2
queries
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3641
This commit is contained in:
parent
27afe7bc38
commit
207a62a3c2
1 changed files with 5 additions and 2 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/storage"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/storage"
|
||||||
"github.com/VictoriaMetrics/metricsql"
|
"github.com/VictoriaMetrics/metricsql"
|
||||||
|
@ -248,7 +249,8 @@ func groupJoin(singleTimeseriesSide string, be *metricsql.BinaryOpExpr, rvsLeft,
|
||||||
bb.B = marshalMetricTagsSorted(bb.B[:0], &tsCopy.MetricName)
|
bb.B = marshalMetricTagsSorted(bb.B[:0], &tsCopy.MetricName)
|
||||||
pair, ok := m[string(bb.B)]
|
pair, ok := m[string(bb.B)]
|
||||||
if !ok {
|
if !ok {
|
||||||
m[string(bb.B)] = &tsPair{
|
k := bytesutil.InternBytes(bb.B)
|
||||||
|
m[k] = &tsPair{
|
||||||
left: &tsCopy,
|
left: &tsCopy,
|
||||||
right: tsRight,
|
right: tsRight,
|
||||||
}
|
}
|
||||||
|
@ -504,7 +506,8 @@ func createTimeseriesMapByTagSet(be *metricsql.BinaryOpExpr, left, right []*time
|
||||||
logger.Panicf("BUG: unexpected binary op modifier %q", groupOp)
|
logger.Panicf("BUG: unexpected binary op modifier %q", groupOp)
|
||||||
}
|
}
|
||||||
bb.B = marshalMetricTagsSorted(bb.B[:0], mn)
|
bb.B = marshalMetricTagsSorted(bb.B[:0], mn)
|
||||||
m[string(bb.B)] = append(m[string(bb.B)], ts)
|
k := bytesutil.InternBytes(bb.B)
|
||||||
|
m[k] = append(m[k], ts)
|
||||||
}
|
}
|
||||||
storage.PutMetricName(mn)
|
storage.PutMetricName(mn)
|
||||||
bbPool.Put(bb)
|
bbPool.Put(bb)
|
||||||
|
|
Loading…
Reference in a new issue