mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Create per-series iterators only once per selector, rather than recreating it for each time step.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
This commit is contained in:
parent
993618adea
commit
fde6ebb17d
|
@ -1830,7 +1830,12 @@ func (ev *evaluator) evalTimestampFunctionOverVectorSelector(vs *parser.VectorSe
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ev.error(errWithWarnings{fmt.Errorf("expanding series: %w", err), ws})
|
ev.error(errWithWarnings{fmt.Errorf("expanding series: %w", err), ws})
|
||||||
}
|
}
|
||||||
it := storage.NewMemoizedEmptyIterator(durationMilliseconds(ev.lookbackDelta))
|
|
||||||
|
seriesIterators := make([]*storage.MemoizedSeriesIterator, len(vs.Series))
|
||||||
|
for i, s := range vs.Series {
|
||||||
|
it := s.Iterator(nil)
|
||||||
|
seriesIterators[i] = storage.NewMemoizedIterator(it, durationMilliseconds(ev.lookbackDelta))
|
||||||
|
}
|
||||||
|
|
||||||
return ev.rangeEval(nil, func(v []parser.Value, _ [][]EvalSeriesHelper, enh *EvalNodeHelper) (Vector, storage.Warnings) {
|
return ev.rangeEval(nil, func(v []parser.Value, _ [][]EvalSeriesHelper, enh *EvalNodeHelper) (Vector, storage.Warnings) {
|
||||||
if vs.Timestamp != nil {
|
if vs.Timestamp != nil {
|
||||||
|
@ -1838,12 +1843,10 @@ func (ev *evaluator) evalTimestampFunctionOverVectorSelector(vs *parser.VectorSe
|
||||||
// needs to be adjusted for every point.
|
// needs to be adjusted for every point.
|
||||||
vs.Offset = time.Duration(enh.Ts-*vs.Timestamp) * time.Millisecond
|
vs.Offset = time.Duration(enh.Ts-*vs.Timestamp) * time.Millisecond
|
||||||
}
|
}
|
||||||
vec := make(Vector, 0, len(vs.Series))
|
|
||||||
var chkIter chunkenc.Iterator
|
|
||||||
for _, s := range vs.Series {
|
|
||||||
chkIter = s.Iterator(chkIter)
|
|
||||||
it.Reset(chkIter)
|
|
||||||
|
|
||||||
|
vec := make(Vector, 0, len(vs.Series))
|
||||||
|
for i, s := range vs.Series {
|
||||||
|
it := seriesIterators[i]
|
||||||
t, f, h, ok := ev.vectorSelectorSingle(it, vs, enh.Ts)
|
t, f, h, ok := ev.vectorSelectorSingle(it, vs, enh.Ts)
|
||||||
if ok {
|
if ok {
|
||||||
vec = append(vec, Sample{
|
vec = append(vec, Sample{
|
||||||
|
|
Loading…
Reference in a new issue