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 tailer matching by using the index. #3090

Merged
merged 2 commits into from
Jan 7, 2021

Conversation

cyriltovena
Copy link
Contributor

❯ benchcmp  before.txt after
benchmark                              old ns/op     new ns/op     delta
Benchmark_instance_addNewTailer-16     537731        1479          -99.72%

benchmark                              old allocs     new allocs     delta
Benchmark_instance_addNewTailer-16     244            3              -98.77%

benchmark                              old bytes     new bytes     delta
Benchmark_instance_addNewTailer-16     22098         121           -99.45%

Signed-off-by: Cyril Tovena cyril.tovena@gmail.com

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated

```
❯ benchcmp  before.txt after
benchmark                              old ns/op     new ns/op     delta
Benchmark_instance_addNewTailer-16     537731        1479          -99.72%

benchmark                              old allocs     new allocs     delta
Benchmark_instance_addNewTailer-16     244            3              -98.77%

benchmark                              old bytes     new bytes     delta
Benchmark_instance_addNewTailer-16     22098         121           -99.45%
```

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
@codecov-io
Copy link

codecov-io commented Dec 17, 2020

Codecov Report

Merging #3090 (e0c3afd) into master (e9001d8) will increase coverage by 0.04%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3090      +/-   ##
==========================================
+ Coverage   62.86%   62.91%   +0.04%     
==========================================
  Files         186      186              
  Lines       15949    15951       +2     
==========================================
+ Hits        10026    10035       +9     
+ Misses       4996     4986      -10     
- Partials      927      930       +3     
Impacted Files Coverage Δ
pkg/ingester/ingester.go 47.03% <0.00%> (-0.16%) ⬇️
pkg/ingester/instance.go 58.42% <0.00%> (-0.45%) ⬇️
pkg/ingester/stream.go 70.27% <ø> (+0.47%) ⬆️
pkg/ingester/tailer.go 43.80% <ø> (+2.47%) ⬆️
pkg/querier/queryrange/downstreamer.go 95.29% <0.00%> (-2.36%) ⬇️
pkg/promtail/targets/file/filetarget.go 64.33% <0.00%> (-2.10%) ⬇️
pkg/promtail/positions/positions.go 58.51% <0.00%> (+11.70%) ⬆️

return false
for _, l := range lbs {
for _, matcher := range t.matchers {
if l.Name == matcher.Name && !matcher.Matches(l.Value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This would work only if matchers has all the label names from lbs.
E.g if lbs is foo=bar, env=prod and matchers is app=bazz, it would return true because the condition here would be false for all the iterations and we return true at the end.
What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Nice catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep I'll add a test making sure we don't do this one again.

Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

I think @sandeepsukhani's suggestion needs to be addressed then LGTM

return false
for _, l := range lbs {
for _, matcher := range t.matchers {
if l.Name == matcher.Name && !matcher.Matches(l.Value) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
@cyriltovena cyriltovena merged commit cdf4a73 into grafana:master Jan 7, 2021
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.

4 participants