Below are the benchmark results (tested locally) comparing the performance of the current LabelSet.String() and the proposed solution (included in this PR)
// Benchmark Results for LabelSet's String() method
// ---------------------------------------------------------------------------------------------------------
// Existing LabelSet's String() -> (sorting of `<labelName>="<labelValue>"`)
// goos: linux
// goarch: amd64
// pkg: github.com/prometheus/common/model
// cpu: 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz
// BenchmarkLabelSetStringMethod-8 717866 1647 ns/op
// ---------------------------------------------------------------------------------------------------------
// This PR -> (Alphabetical sorting of LabelSet by labelName)
// goos: linux
// goarch: amd64
// pkg: github.com/prometheus/common/model
// cpu: 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz
// BenchmarkLabelSetStringMethod-8 732376 1532 ns/op
Reviewers, please share your input on these changes or alternative approaches. I'll address them in the next commits.
Fixes: https://github.com/prometheus/common/issues/543
Below are the benchmark results (tested locally) comparing the performance of the current LabelSet.String() and the proposed solution (included in this PR)
Reviewers, please share your input on these changes or alternative approaches. I'll address them in the next commits.