*: improve latency when streaming series from Prometheus#3146
Merged
bwplotka merged 1 commit intothanos-io:masterfrom Sep 15, 2020
Merged
*: improve latency when streaming series from Prometheus#3146bwplotka merged 1 commit intothanos-io:masterfrom
bwplotka merged 1 commit intothanos-io:masterfrom
Conversation
8242808 to
6389103
Compare
ae9dbe4 to
74efa25
Compare
Contributor
Author
|
|
I've found that when requesting many series (in the order of ten thousands), the Thanos sidecar spends half of its time computing the number of received series. To calculate the number of series, it needs to build a label-based identifier for each chunked series and compare it with the previous identifier. Eventually this number is only used for logging and tracing so it doesn't feel like it's worth the penalty. This change adds an histogram metric, `thanos_sidecar_prometheus_store_received_frames`, which tracks the number of frames per request received from the Prometheus remote read API (buckets: 10, 100, 1000, 10000, 100000). It can be used to evaluate whether expensive Series requests are being performed. Signed-off-by: Simon Pasquier <spasquie@redhat.com>
74efa25 to
f2ab444
Compare
Contributor
Author
|
@bwplotka friendly ping :) |
bwplotka
approved these changes
Sep 15, 2020
Member
|
Thanks, amazingly spotted ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
I've found that when requesting many series (in the order of ten
thousands), the Thanos sidecar spends half of its time computing the
number of received series. To calculate the number of series, it needs
to build a label-based identifier for each chunked series and compare it
with the previous identifier. Eventually this number is only used for
logging and tracing so it doesn't feel like it's worth the penalty.
This change adds an histogram metric,
thanos_sidecar_prometheus_store_received_frames, which tracks the numberof frames per request received from the Prometheus remote read API
(buckets: 10, 100, 1000, 10000, 100000). It can be used to evaluate
whether expensive Series requests are performed.
Verification
CPU profile before this PR (half of the time is spent in
prompb.(*Label).String)CPU profile after this PR
CPU graph showing the 50% improvement (the patched version of the Thanos sidecar has been deployed around 15:50)
https://snapshot.raintank.io/dashboard/snapshot/mufpH3k2yRJUYLM284SXESwVLG0Ns14i?orgId=2