Skip to content
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

Pre-render prometheus labels #3587

Merged
merged 1 commit into from
Nov 11, 2021

Conversation

binarin
Copy link
Contributor

@binarin binarin commented Oct 18, 2021

Proposed Changes

Pre-render labels for prometheus exported. Character escaping is not needed, as AMQP object names are quite restricted in what characters they can have.

Doing it this way removes not only CPU overhead, but also a lot of garbage collection overhead (as for every output line labels were converted from a proplist to a list of records before rendering).

This makes per-object metrics twice as fast, time to produce ~630k metrics (10k queues/10k consumer/10k producers) went from ~6 to ~3 seconds from this change.

Depends on deadtrickster/prometheus.erl#137

This also pulls an performance optimization deadtrickster/prometheus.erl#136 - across all those changes on my test machine I saw scraping time dropping 40 times for the aforementioned 630k metrics.

Testing was performed by running 2 instances of perftest with the following arguments (just with a slightly modified queue pattern each time):

--queue-pattern 'perf-test-%d' \
  --queue-pattern-from 1 --queue-pattern-to 5000 \
  --producers 1 --consumers 1 --rate 1

2 instances because perftest was running out of memory, and running two instances was easier for me than learning how to tune java memory settings.

The timing of following urls are of special interest for testing:

http://localhost:15692/metrics/per-object
http://localhost:15692/metrics/detailed?family=queue_coarse_metrics&family=queue_consumer_count
http://localhost:15692/metrics/detailed?family=queue_metrics

Types of Changes

  • Bug fix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)
  • Build system and/or CI

Checklist

@binarin binarin marked this pull request as draft October 18, 2021 14:58
@michaelklishin
Copy link
Member

Oh, that's a nice improvement indeed!

@HoloRin
Copy link
Contributor

HoloRin commented Oct 21, 2021

@pjk25 self reminder to fixup the bazel commit

@HoloRin
Copy link
Contributor

HoloRin commented Nov 4, 2021

@binarin git_repository refers to an external repository that has it's own bazel files. github_bazel_erlang_lib is a helper we have to import a non-bazel repo into bazel-land.

@HoloRin
Copy link
Contributor

HoloRin commented Nov 4, 2021

@Mergifyio rebase

@mergify
Copy link

mergify bot commented Nov 4, 2021

rebase

✅ Branch has been successfully rebased

@binarin binarin force-pushed the prometheus-label-pre-render-optimization branch from e11fb80 to 6641c5a Compare November 4, 2021 11:06
@HoloRin
Copy link
Contributor

HoloRin commented Nov 4, 2021

@binarin I think this is looking good now

@binarin binarin marked this pull request as ready for review November 8, 2021 20:45
This makes per-object metrics twice as fast.

Depends on deadtrickster/prometheus.erl#137
@binarin binarin force-pushed the prometheus-label-pre-render-optimization branch from f6c317d to 8598c51 Compare November 9, 2021 12:05
Copy link
Member

@michaelklishin michaelklishin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm 20-50% reduction in response latency (the number of samples is small but the results are consistent).

@michaelklishin michaelklishin merged commit 1b7a8f8 into master Nov 11, 2021
@michaelklishin michaelklishin deleted the prometheus-label-pre-render-optimization branch November 11, 2021 10:00
michaelklishin added a commit that referenced this pull request Nov 11, 2021
…timization

Pre-render prometheus labels

(cherry picked from commit 1b7a8f8)

Conflicts:
	rabbitmq-components.mk
	workspace_helpers.bzl
@michaelklishin
Copy link
Member

Backported to v3.9.x manually for 3.9.9.

@michaelklishin michaelklishin added this to the 3.9.9 milestone Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants