-
Notifications
You must be signed in to change notification settings - Fork 2.2k
receive/multitsdb: add cuckoo filter on metric names #7787
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
Merged
fpetkovski
merged 8 commits into
thanos-io:main
from
niaurys:add_cuckoo_filter_on_metric_names
Oct 2, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1cd8d90
receive/multitsdb: add cuckoo filter on metric names
niaurys bc3a182
add enable-feature flag to Receiver docs, fix newEndpointRef typo
niaurys a4298bb
add test cases for testFilter
niaurys 068c92c
avoid copy in CuckooFilterMetricNameFilter
niaurys f3493a1
use matchers in store filter
niaurys d2b6089
fix TSDB pruning
niaurys a659d10
address PR comments, use options in tsbd initializations
niaurys 701d312
rebase on main
niaurys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Copyright (c) The Thanos Authors. | ||
| // Licensed under the Apache License 2.0. | ||
|
|
||
| package filter | ||
|
|
||
| import ( | ||
| "sync" | ||
| "unsafe" | ||
|
|
||
| "github.com/prometheus/prometheus/model/labels" | ||
| cuckoo "github.com/seiflotfy/cuckoofilter" | ||
| ) | ||
|
|
||
| type CuckooMetricNameStoreFilter struct { | ||
| filter *cuckoo.Filter | ||
| mtx sync.RWMutex | ||
| } | ||
|
|
||
| func NewCuckooMetricNameStoreFilter(capacity uint) *CuckooMetricNameStoreFilter { | ||
| return &CuckooMetricNameStoreFilter{ | ||
| filter: cuckoo.NewFilter(capacity), | ||
| } | ||
| } | ||
|
|
||
| func (f *CuckooMetricNameStoreFilter) Matches(matchers []*labels.Matcher) bool { | ||
| f.mtx.RLock() | ||
| defer f.mtx.RUnlock() | ||
|
|
||
| for _, m := range matchers { | ||
| if m.Type == labels.MatchEqual && m.Name == labels.MetricName { | ||
| return f.filter.Lookup([]byte(m.Value)) | ||
| } | ||
| } | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| func (f *CuckooMetricNameStoreFilter) ResetAndSet(values ...string) { | ||
| f.mtx.Lock() | ||
| defer f.mtx.Unlock() | ||
| f.filter.Reset() | ||
| for _, value := range values { | ||
| f.filter.Insert(unsafe.Slice(unsafe.StringData(value), len(value))) | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Copyright (c) The Thanos Authors. | ||
| // Licensed under the Apache License 2.0. | ||
|
|
||
| package filter | ||
|
|
||
| import "github.com/prometheus/prometheus/model/labels" | ||
|
|
||
| type StoreFilter interface { | ||
| // Matches returns true if the filter matches the given matchers. | ||
| Matches(matchers []*labels.Matcher) bool | ||
|
|
||
| // ResetAndSet resets the filter and sets it to the given values. | ||
| ResetAndSet(values ...string) | ||
| } | ||
|
|
||
| type AllowAllStoreFilter struct{} | ||
|
|
||
| func (f AllowAllStoreFilter) Matches(matchers []*labels.Matcher) bool { | ||
| return true | ||
| } | ||
|
|
||
| func (f AllowAllStoreFilter) ResetAndSet(values ...string) {} |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.