jmx_exporter icon indicating copy to clipboard operation
jmx_exporter copied to clipboard

Improve performance of duplicate sample lookup

Open amuraru opened this issue 2 years ago • 2 comments

Maintain a lookup index for sample keys (name, labels) and use that to check for duplicate sample during scraping instead of O(n) list of samples

Also guard non-trivial computation behind Logger level check

amuraru avatar Jul 03 '22 18:07 amuraru

Please also remove the old findExisting() method as it's not used anymore.

Good catch. Fixed.

amuraru avatar Jul 11 '22 07:07 amuraru

@fstab - kind reminder to review this PR. thanks

amuraru avatar Aug 14 '22 11:08 amuraru

This improvement has proved to be very valuable for us. We work with a large system with kafka and kafka streams and the amount of metrics are quite large. When we upgraded from 0.16.1 to 0.17.3 there was a significant drop in performance while using 15sec scraping. The response times were quite high and it simply unusable with 15sec scraping. During our profiling we saw that most of the time spent was on findExisting() function. After applying the above fix 15sec scraping is again usable. I hope this gets merged to trunk and added to the next release.

boytunp avatar Dec 20 '22 12:12 boytunp

@fstab I know you are busy, but I feel this should be prioritized. On a real Kafka broker, this change decreased collection time by ~40%.

Before the change...

     time_namelookup:  0.004212s
        time_connect:  0.004593s
     time_appconnect:  0.058974s
    time_pretransfer:  0.059085s
       time_redirect:  0.000000s
  time_starttransfer:  27.566052s
                     ----------
          time_total:  27.618721s

After the change...

     time_namelookup:  0.006547s
        time_connect:  0.007784s
     time_appconnect:  0.062182s
    time_pretransfer:  0.062339s
       time_redirect:  0.000000s
  time_starttransfer:  17.136378s
                     ----------
          time_total:  17.226715s

dhoard avatar Feb 24 '23 13:02 dhoard

Thanks a lot, and sorry for the long delay.

fstab avatar Mar 07 '23 15:03 fstab