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

perf: Improve Detected labels API #12816

Merged
merged 16 commits into from May 15, 2024
Merged

perf: Improve Detected labels API #12816

merged 16 commits into from May 15, 2024

Conversation

shantanualsi
Copy link
Contributor

@shantanualsi shantanualsi commented Apr 29, 2024

What this PR does / why we need it:

  • Remove usage of regex to improve performance
  • Enable query splitting for detected labels
  • Change detected labels implementation to use hyperloglog

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@shantanualsi shantanualsi changed the title Improve Detected labels API perf: Improve Detected labels API May 7, 2024
@shantanualsi shantanualsi marked this pull request as ready for review May 8, 2024 10:24
@shantanualsi shantanualsi requested a review from a team as a code owner May 8, 2024 10:24
Copy link
Collaborator

@trevorwhitney trevorwhitney left a comment

Choose a reason for hiding this comment

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

looks good, just a few small things.

return false
_, err := strconv.ParseFloat(v, 64)
if err != nil {
_, err = uuid.Parse(v)
Copy link
Collaborator

Choose a reason for hiding this comment

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

much cleaner than the regex pattern

}
detectedLabels = append(detectedLabels, &logproto.DetectedLabel{
Label: k,
Cardinality: v.Estimate(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, good call here, we hopefully don't care about this but if there's only 1 split we'll need the estimate here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry didn't get the issue.. even if there's a 1 split, the estimate will be populated here right?

pkg/ingester/ingester_test.go Outdated Show resolved Hide resolved
var result []*logproto.DetectedLabel

for _, dl := range resp.Response.DetectedLabels {
if dl.Cardinality > 2 && dl.Cardinality < 50 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still get confused by our middlewares, so just to make sure, this is happening after we MergeLabels right? I wouldn't want to omit results based on partial cardinality of a subquery.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes confirmed again this is executed after MergeLabels. The line res, err := rt.Do(ctx, req) is before everything else in this function

pkg/storage/detected/labels.go Outdated Show resolved Hide resolved
@trevorwhitney trevorwhitney merged commit e7fdeb9 into main May 15, 2024
58 checks passed
@trevorwhitney trevorwhitney deleted the improve-detected-labels branch May 15, 2024 15:56
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.

None yet

2 participants