feat: improve performance of getMetricAsPrometheusString#542
feat: improve performance of getMetricAsPrometheusString#542SimenB merged 4 commits intosiimon:masterfrom shappir:optimize-get-metric-as-prometheus-string
Conversation
|
Thanks! Do you have any benchmarks before/after? https://github.com/siimon/prom-client/tree/master/benchmarks |
|
This change primarily impacts the performance of metrics that have a large number of rows in the Prometheus metrics output, e.g. histograms with several labels. In our application I saw metric generation time reduced by ~50%. This is not surprising since the number of times string values are copied as result of concatination is the same order as the number of rows. In the benchmark test I got 50% faster and 50% "acceptably slower". Every once in a while I would get one entry or another as slower, but it was inconsistent. |
|
Cool, thanks! |
|
Is this still an issue? Do you need me to do anything? |
|
If it's not too much trouble, a PR against |
|
Created a pr for |
Use Array.prototype.join instead string concatenation for constructing Prometheus metric string. This results in improved performance and reduced memory consumption, especially when there's a large amount of dimensions (labels and label values). In addition uses array iteration methods instead of explicit loops.