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

Improve labels computation during LogQL pipeline #6110

Merged
merged 2 commits into from
May 24, 2022

Conversation

cyriltovena
Copy link
Contributor

This does two things:

  • Introduce a buffer for computing labels and the buffer is only copied if we never seen that label set before.
  • Add a Map function to the label builders used for label_format and line_format that avoids slice allocations and sorting.
❯ benchstat before.txt after.txt
name                                 old time/op    new time/op    delta
_Pipeline/pipeline_bytes-16            10.6µs ± 0%     6.9µs ± 1%  -34.85%  (p=0.008 n=5+5)
_Pipeline/pipeline_string-16           10.6µs ± 0%     6.9µs ± 0%  -35.16%  (p=0.008 n=5+5)
_Pipeline/line_extractor_bytes-16      10.6µs ± 0%     6.9µs ± 1%  -34.98%  (p=0.008 n=5+5)
_Pipeline/line_extractor_string-16     10.7µs ± 1%     6.9µs ± 0%  -35.27%  (p=0.016 n=5+4)
_Pipeline/label_extractor_bytes-16     10.7µs ± 1%     7.1µs ± 4%  -33.97%  (p=0.008 n=5+5)
_Pipeline/label_extractor_string-16    10.8µs ± 1%     7.0µs ± 0%  -34.90%  (p=0.016 n=5+4)

name                                 old alloc/op   new alloc/op   delta
_Pipeline/pipeline_bytes-16            9.46kB ± 0%    3.26kB ± 0%  -65.58%  (p=0.008 n=5+5)
_Pipeline/pipeline_string-16           9.46kB ± 0%    3.26kB ± 0%  -65.57%  (p=0.008 n=5+5)
_Pipeline/line_extractor_bytes-16      9.46kB ± 0%    3.26kB ± 0%  -65.58%  (p=0.008 n=5+5)
_Pipeline/line_extractor_string-16     9.46kB ± 0%    3.26kB ± 0%  -65.58%  (p=0.008 n=5+5)
_Pipeline/label_extractor_bytes-16     9.46kB ± 0%    3.26kB ± 0%  -65.58%  (p=0.008 n=5+5)
_Pipeline/label_extractor_string-16    9.46kB ± 0%    3.26kB ± 0%  -65.58%  (p=0.008 n=5+5)

name                                 old allocs/op  new allocs/op  delta
_Pipeline/pipeline_bytes-16              44.0 ± 0%      33.0 ± 0%  -25.00%  (p=0.008 n=5+5)
_Pipeline/pipeline_string-16             44.0 ± 0%      33.0 ± 0%  -25.00%  (p=0.008 n=5+5)
_Pipeline/line_extractor_bytes-16        44.0 ± 0%      33.0 ± 0%  -25.00%  (p=0.008 n=5+5)
_Pipeline/line_extractor_string-16       44.0 ± 0%      33.0 ± 0%  -25.00%  (p=0.008 n=5+5)
_Pipeline/label_extractor_bytes-16       44.0 ± 0%      33.0 ± 0%  -25.00%  (p=0.008 n=5+5)
_Pipeline/label_extractor_string-16      44.0 ± 0%      33.0 ± 0%  -25.00%  (p=0.008 n=5+5)

@cyriltovena cyriltovena requested a review from a team as a code owner May 6, 2022 08:15
dannykopping
dannykopping previously approved these changes May 6, 2022
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

LGTM, looks like a big improvement!

@dannykopping dannykopping self-requested a review May 6, 2022 08:26
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

Looks like some tests are failing

@dannykopping dannykopping dismissed their stale review May 6, 2022 08:26

Saw tests were failing

@cyriltovena
Copy link
Contributor Author

Interestingly they do not fail when run one by one. Checking...

@cyriltovena
Copy link
Contributor Author

Yeah there;s a bug in fact :)

@cyriltovena
Copy link
Contributor Author

Fixed, same benchmark result.

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants