zapier / prom-aggregation-gateway

An aggregating push gateway for Prometheus
Mozilla Public License 2.0
116 stars 26 forks source link

Optimize locks and refactor for performance #22

Closed mplachter closed 1 year ago

mplachter commented 1 year ago

Performance + logic refactor

Refactor for performance ns/op and allocs\memory usage

Things done

Before Refactor

pkg: prom-aggregation-gateway
BenchmarkConcurrentAggregate/metric_type_simpleGauge-10                   159729             77811 ns/op           88151 B/op       1323 allocs/op
BenchmarkConcurrentAggregate/metric_type_fullMetrics-10                    83968            142508 ns/op          196592 B/op       3803 allocs/op
BenchmarkConcurrentAggregate/metric_type_multiLabel-10                    260701             46923 ns/op           63507 B/op        603 allocs/op
BenchmarkConcurrentAggregate/metric_type_labelFields-10                   256719             47283 ns/op           62649 B/op        563 allocs/op
BenchmarkConcurrentAggregate/metric_type_reorderedLabels-10               259092             46992 ns/op           63507 B/op        603 allocs/op
PASS
ok      prom-aggregation-gateway        65.196s

After Refactor

pkg: prom-aggregation-gateway
BenchmarkConcurrentAggregate/metric_type_simpleGauge-10                   152410             77365 ns/op           87347 B/op       1313 allocs/op
BenchmarkConcurrentAggregate/metric_type_fullMetrics-10                    84994            140624 ns/op          194174 B/op       3773 allocs/op
BenchmarkConcurrentAggregate/metric_type_multiLabel-10                    216140             47299 ns/op           62705 B/op        593 allocs/op
BenchmarkConcurrentAggregate/metric_type_labelFields-10                   257414             47539 ns/op           61830 B/op        553 allocs/op
BenchmarkConcurrentAggregate/metric_type_reorderedLabels-10               257733             45932 ns/op           62706 B/op        593 allocs/op
done
PASS
ok      prom-aggregation-gateway        62.053s