On Wed, 11 May 2022 at 10:06, Augustin Husson <[email protected]>
wrote:

> Dear Prometheus developers,
>
> I'm currently working on trying to optimize the synchronization of the
> targets in the Prometheus Discovery. (Issue is here
> <https://github.com/prometheus/prometheus/issues/8014>)
>
> And after a couple of investigations and tests on a real environment, we
> figured out that actually the usage of the method Set of the
> labels.Builder
> <https://github.com/prometheus/prometheus/blob/main/model/labels/labels.go#L388>
> cost a lot, and more generally the global usage of labels.Builder cost.
>
> In this PR <https://github.com/prometheus/prometheus/pull/10662> that is
> supposed to fix the issue mentioned above, I started to replace the usage
> of labels.Builder by a map and it immediately optimized the code. The
> reason is because it reduces the complexity of the different methods. Like
> for the method Set, we moved from o(n2) to o(n).
>
> So my question is: Would it be ok to change the internal implementation of
> labels.Builder by using a map instead of multiple different slices ? It
> won't change the API exposed, just the internal implementation.
>

A large part of the performance gains of Prometheus 2.x is attributed to it
not using maps, so I would be extremely cautious about changing it for the
sake of SD which is not the hot path. n is generally small for ingestion,
so complexity alone can be misleading.

When I last looked at the SD code the main performance issue looked to be
that it had not been converted to using labels.Builder yet, and the
continuous conversions from a map was what the main problem looked to be.
Along with other low hanging fruit.

I believe it will help to optimize smoothly (for example) the method
> relabel.Process
> <https://github.com/prometheus/prometheus/blob/main/model/relabel/relabel.go#L193>
>

This isn't on a hot path these days, as it's only run the first time we see
a given sample.

Brian


>
> Cheers,
> Augustin.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prometheus Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-developers/CAOJizGe0AxLGw5G9BM1Z6Menamq%3DxTMHzFXjj73fTqM5%2BZgz5A%40mail.gmail.com
> <https://groups.google.com/d/msgid/prometheus-developers/CAOJizGe0AxLGw5G9BM1Z6Menamq%3DxTMHzFXjj73fTqM5%2BZgz5A%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Brian Brazil
www.robustperception.io

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-developers/CAHJKeLqfcDUm7pMr890h2cXv6xdSwvibh_93jc0nvSKqMzfoGw%40mail.gmail.com.

Reply via email to