Revert "Prometheus: Reduce allocations parsing exemplars" (#66367)

Revert "Prometheus: Reduce allocations parsing exemplars (#58959)"

This reverts commit a1f2d0e20582e3773ac623c5e0d55300fdbdc620.
This commit is contained in:
Gábor Farkas
2023-04-12 14:45:21 +02:00
committed by GitHub
parent cca109eb77
commit d830591cdc
2 changed files with 3 additions and 5 deletions

View File

@ -41,7 +41,6 @@ func BenchmarkExemplarJson(b *testing.B) {
tCtx, err := setup(true)
require.NoError(b, err)
b.ResetTimer()
b.ReportAllocs()
for n := 0; n < b.N; n++ {
res := http.Response{
StatusCode: 200,

View File

@ -228,8 +228,8 @@ func readArrayData(iter *jsoniter.Iterator) backend.DataResponse {
}
// For consistent ordering read values to an array not a map
func readLabelsAsPairs(iter *jsoniter.Iterator, pairs [][2]string) [][2]string {
pairs = pairs[:0]
func readLabelsAsPairs(iter *jsoniter.Iterator) [][2]string {
pairs := make([][2]string, 0, 10)
for k := iter.ReadObject(); k != ""; k = iter.ReadObject() {
pairs = append(pairs, [2]string{k, iter.ReadString()})
}
@ -270,7 +270,7 @@ func readLabelsOrExemplars(iter *jsoniter.Iterator) (*data.Frame, [][2]string) {
case "labels":
max := 0
for _, pair := range readLabelsAsPairs(iter, pairs) {
for _, pair := range readLabelsAsPairs(iter) {
k := pair[0]
v := pair[1]
f, ok := lookup[k]
@ -305,7 +305,6 @@ func readLabelsOrExemplars(iter *jsoniter.Iterator) (*data.Frame, [][2]string) {
}
default:
v := fmt.Sprintf("%v", iter.Read())
pairs = pairs[:0]
pairs = append(pairs, [2]string{l1Field, v})
}
}