Performance regression in text-format export on 1.4.0+ (original) (raw)

It seems like the adding of support for UTF-8 characters has considerably increased processing time in the io.prometheus.metrics.expositionformats.PrometheusTextFormatWriter.writeNameAndLabels method due to it now calling io.prometheus.metrics.model.snapshots.PrometheusNaming.isValidLegacyMetricName.

I ran a local test with 1000 metrics exported. Average time per export on version 1.3.10 was 0.9-1.1 ms, while on version 1.4.1 I got an average of 2.7-2.9 ms.

I'm not sure which avenues make sense to avoid this regression and I'm not sure how relevant it is. I just found this while evaluating a move from the old simpleclient to the new client-java and that drew my attention, as the text format export is now slower than in simpleclient.

I have attached the flamegraph I captured on both versions.

flamegraph-v141.html
flamegraph-v1310.html