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

MQE: improve runtime of mixed metrics tests #10678

Merged
merged 4 commits into from
Feb 19, 2025
Merged

Conversation

charleskorn
Copy link
Contributor

What this PR does

This PR makes some improvements to the mixed metrics tests (aka the gauntlet), with the aim of preserving coverage while dramatically reducing how long they take to run.

On my machine, running all of the tests in engine_test.go took 3m35s before these changes, and now takes 45s.

I've tried to build up these changes incrementally, I suggest reviewing each commit separately.

Which issue(s) this PR fixes or relates to

(none)

Checklist

  • [n/a] Tests updated.
  • [n/a] Documentation added.
  • [n/a] CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • [n/a] about-versioning.md updated with experimental features.

Comment on lines -2850 to 2852
// Generate combinations of 2, 3, and 4 labels. (e.g., "a,b", "e,f", "c,d,e", "a,b,c,d", "c,d,e,f" etc)
// Generate combinations of 2 labels. (e.g., "a,b", "e,f" etc)
labelCombinations = append(labelCombinations, testutils.Combinations(labelsToUse, 2)...)
labelCombinations = append(labelCombinations, testutils.Combinations(labelsToUse, 3)...)
labelCombinations = append(labelCombinations, testutils.Combinations(labelsToUse, 4)...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rationale: these functions all operate a series at a time, and any issue working with multiple series is likely to be surfaced running with two series.

Copy link
Contributor

Choose a reason for hiding this comment

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

that's fair for non aggregations

@@ -2981,8 +2977,6 @@ func TestCompareVariousMixedMetricsVectorSelectors(t *testing.T) {
for _, function := range []string{"rate", "increase", "changes", "resets", "deriv", "irate", "idelta", "delta", "deriv", "stddev_over_time", "stdvar_over_time"} {
expressions = append(expressions, fmt.Sprintf(`%s(series{label=~"(%s)"}[45s])`, function, labelRegex))
expressions = append(expressions, fmt.Sprintf(`%s(series{label=~"(%s)"}[1m])`, function, labelRegex))
expressions = append(expressions, fmt.Sprintf(`sum(%s(series{label=~"(%s)"}[2m15s]))`, function, labelRegex))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rationale: we already extensively test sum in TestCompareVariousMixedMetricsAggregations.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to keep these. They test reusing pools that have been used by the range-vector function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need both sum test cases?

Don't forget we also have TestConcurrentQueries that should cover pooled slices being reused as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

one is probably sufficient. I'd suggest keeping this one (2m15s).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I've restored that in c4b2c57.

Comment on lines -2972 to -2975
// Generate combinations of 2, 3, and 4 labels. (e.g., "a,b", "e,f", "c,d,e", "a,b,c,d", "c,d,e,f" etc)
// Generate combinations of 2 labels. (e.g., "a,b", "e,f" etc)
labelCombinations = append(labelCombinations, testutils.Combinations(labelsToUse, 2)...)
labelCombinations = append(labelCombinations, testutils.Combinations(labelsToUse, 3)...)
labelCombinations = append(labelCombinations, testutils.Combinations(labelsToUse, 4)...)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rationale: these functions all operate a series at a time, and any issue working with multiple series is likely to be surfaced running with two series.

Copy link
Contributor

@jhesketh jhesketh left a comment

Choose a reason for hiding this comment

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

Thanks for that. I'm in support of most of these changes, but I would like to keep the range vector tests being passed through an aggregation personally.

@charleskorn charleskorn marked this pull request as ready for review February 19, 2025 02:10
@charleskorn charleskorn requested a review from a team as a code owner February 19, 2025 02:10
Copy link
Contributor

@jhesketh jhesketh left a comment

Choose a reason for hiding this comment

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

Great, thank you :-)

@charleskorn charleskorn merged commit faec99e into main Feb 19, 2025
28 checks passed
@charleskorn charleskorn deleted the charleskorn/mqe-gauntlet branch February 19, 2025 04:24
ying-jeanne pushed a commit that referenced this pull request Feb 19, 2025
* Make gauntlet tests ~3x faster by not using `t.Run()`

* Don't bother running functions that operate over single series at a time over multiple series at a time

* Don't run `sum` over functions that operate over range vector selectors, and only run with two series rather than up to four

* Restore one `sum` over range vector function test case
ying-jeanne pushed a commit that referenced this pull request Feb 19, 2025
* Make gauntlet tests ~3x faster by not using `t.Run()`

* Don't bother running functions that operate over single series at a time over multiple series at a time

* Don't run `sum` over functions that operate over range vector selectors, and only run with two series rather than up to four

* Restore one `sum` over range vector function test case
ying-jeanne pushed a commit that referenced this pull request Feb 20, 2025
* Make gauntlet tests ~3x faster by not using `t.Run()`

* Don't bother running functions that operate over single series at a time over multiple series at a time

* Don't run `sum` over functions that operate over range vector selectors, and only run with two series rather than up to four

* Restore one `sum` over range vector function test case
ying-jeanne pushed a commit that referenced this pull request Feb 20, 2025
* Make gauntlet tests ~3x faster by not using `t.Run()`

* Don't bother running functions that operate over single series at a time over multiple series at a time

* Don't run `sum` over functions that operate over range vector selectors, and only run with two series rather than up to four

* Restore one `sum` over range vector function test case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants