prometheus/model/labels
Bryan Boreham 8b863c42dd
Optimise relabeling by re-using memory (#11147)
* model/relabel: Add benchmark

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* model/relabel: re-use Builder across relabels

Saves memory allocations.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* labels.Builder: allow re-use of result slice

This reduces memory allocations where the caller has a suitable slice available.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* model/relabel: re-use source values slice

To reduce memory allocations.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Unwind one change causing test failures

Restore original behaviour in PopulateLabels, where we must not overwrite the input set.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* relabel: simplify values optimisation

Use a stack-based array for up to 16 source labels, which will be the
vast majority of cases.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* lint

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2022-08-19 15:27:52 +05:30
..
labels.go Optimise relabeling by re-using memory (#11147) 2022-08-19 15:27:52 +05:30
labels_test.go Optimise relabeling by re-using memory (#11147) 2022-08-19 15:27:52 +05:30
matcher.go Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
matcher_test.go Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
regexp.go Allow downstream projects to use faster regexp (#10251) 2022-02-08 11:03:20 +01:00
regexp_test.go Allow downstream projects to use faster regexp (#10251) 2022-02-08 11:03:20 +01:00
test_utils.go refactor (package model): move from github.com/pkg/errors to 'errors' and 'fmt' packages (#10747) 2022-06-27 21:29:19 +02:00