Skip to content

Openmetrics text parser performance #401

Closed

Description

@ahmed-mez

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!

Activity

  1. brian-brazil commented on May 6, 2019

    @brian-brazil
    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.

  2. ahmed-mez commented on May 6, 2019

    @ahmed-mez
    ContributorAuthor

    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!

  3. ahmed-mez commented on May 17, 2019

    @ahmed-mez
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions