8000 Openmetrics text parser performance · Issue #401 · prometheus/client_python · GitHub
[go: up one dir, main page]

Skip to content

Openmetrics text parser performance #401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ahmed-mez opened this issue May 6, 2019 · 3 comments
Closed

Openmetrics text parser performance #401

ahmed-mez opened this issue May 6, 2019 · 3 comments

Comments

@ahmed-mez
Copy link
Contributor
ahmed-mez commented May 6, 2019

Hi,

Since v0.4.0, the prometheus parser trims the _total suffix from counter metric names, this is a breaking change for few projects.

An alternative, would be using the openmetrics.parser instead but unfortunately it's very slow compared to the prometheus parser, as the following logic #282 that optimized the prometheus parser wasn't reused in the new openmetrics.parser.

Implementing the same optimization logic for openmetrics.parser would enhance considerably the parser's performance (~3.3x perf enhancement for the KSM metric example) and would make it close to the prometheus parser. I tried some tests and I got promising results.

Here is some benchmark using timeit:

call (x100000): _parse_sample('simple_metric 1.513767429e+09')

Simple example with prometheus parser: 0.2489180564880371
Simple example with openmetrics parser: 1.1144659519195557
Simple example with the optimized openmetrics parser: 0.5948491096496582
call (x100000): _parse_sample('kube_service_labels{label_app="kube-state-metrics",label_chart="kube-state-metrics-0.5.0",label_heritage="Tiller",label_release="ungaged-panther",namespace="default",service="ungaged-panther-kube-state-metrics"} 1')

KSM metric example with prometheus parser: 1.6796550750732422
KSM metric example openmetrics parser: 6.6183180809021
KSM metric example optimized openmetrics parser: 2.0289480686187744

Would you support optimizing openmetrics.parser ?

Thanks!

@brian-brazil
Copy link
Contributor

I'm okay with optimizing it, but not at the cost of readability as this is the reference implementation.

I did look at using that logic, but it didn't work out as this needed to be a full parser.

@ahmed-mez
Copy link
Contributor Author

Can you please have look at this PR #402
It optimizes the labels parsing logic only, I'll be happy to introduce any requested changes

Thanks!

@ahmed-mez
Copy link
Contributor Author

#402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0