-
Notifications
You must be signed in to change notification settings - Fork 684
Deduplicate identical series labels and track their memory consumption in QueryLimiter.AddSeries #13806
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
base: main
Are you sure you want to change the base?
Conversation
| duplicated, limitErr := queryLimiter.AddSeries(ls) | ||
| if limitErr != nil { | ||
| return myWarnings, myQueriedBlocks, myStreamingSeriesLabels, indexBytesFetched, false, false, limitErr | ||
| } | ||
|
|
||
| if duplicated { | ||
| continue | ||
| } | ||
|
|
||
| // TODO move this inside AddSeries | ||
| if err := memoryTracker.IncreaseMemoryConsumptionForLabels(ls); err != nil { | ||
| return myWarnings, myQueriedBlocks, myStreamingSeriesLabels, indexBytesFetched, false, false, err | ||
| } | ||
|
|
||
| myStreamingSeriesLabels = append(myStreamingSeriesLabels, ls) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| duplicated, limitErr := queryLimiter.AddSeries(ls) | |
| if limitErr != nil { | |
| return myWarnings, myQueriedBlocks, myStreamingSeriesLabels, indexBytesFetched, false, false, limitErr | |
| } | |
| if duplicated { | |
| continue | |
| } | |
| // TODO move this inside AddSeries | |
| if err := memoryTracker.IncreaseMemoryConsumptionForLabels(ls); err != nil { | |
| return myWarnings, myQueriedBlocks, myStreamingSeriesLabels, indexBytesFetched, false, false, err | |
| } | |
| myStreamingSeriesLabels = append(myStreamingSeriesLabels, ls) | |
| ls, limitErr := queryLimiter.AddSeries(ls) | |
| if limitErr != nil { | |
| return myWarnings, myQueriedBlocks, myStreamingSeriesLabels, indexBytesFetched, false, false, limitErr | |
| } | |
| // TODO move this inside AddSeries | |
| if err := memoryTracker.IncreaseMemoryConsumptionForLabels(ls); err != nil { | |
| return myWarnings, myQueriedBlocks, myStreamingSeriesLabels, indexBytesFetched, false, false, err | |
| } | |
| myStreamingSeriesLabels = append(myStreamingSeriesLabels, ls) |
| defer ql.uniqueSeriesMx.Unlock() | ||
|
|
||
| uniqueSeriesBefore := len(ql.uniqueSeries) | ||
| _, duplicated := ql.uniqueSeries[fingerprint] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| _, duplicated := ql.uniqueSeries[fingerprint] | |
| seriesLabels, duplicated := ql.uniqueSeries[fingerprint] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other thing we should do here: we'll need to handle hash collisions.
| } | ||
|
|
||
| return NewMaxSeriesHitLimitError(uint64(ql.maxSeriesPerQuery)) | ||
| return duplicated, NewMaxSeriesHitLimitError(uint64(ql.maxSeriesPerQuery)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return duplicated, NewMaxSeriesHitLimitError(uint64(ql.maxSeriesPerQuery)) | |
| return seriesLabels, NewMaxSeriesHitLimitError(uint64(ql.maxSeriesPerQuery)) |
| return duplicated, NewMaxSeriesHitLimitError(uint64(ql.maxSeriesPerQuery)) | ||
| } | ||
| return nil | ||
| return duplicated, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return duplicated, nil | |
| return seriesLabels, nil |
https://github.com/grafana/mimir-squad/issues/3280
What this PR does
Which issue(s) this PR fixes or relates to
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]. If changelog entry is not needed, please add thechangelog-not-neededlabel to the PR.about-versioning.mdupdated with experimental features.