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.

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>

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.

Reply via email to