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

ratelimits: Fix cardinality explosion in overrideUsageGauge #7548

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

beautifulentropy
Copy link
Member

No description provided.

@beautifulentropy beautifulentropy marked this pull request as ready for review June 13, 2024 21:29
@beautifulentropy beautifulentropy requested a review from a team as a code owner June 13, 2024 21:29
@aarongable aarongable requested review from a team and pgporada and removed request for a team June 13, 2024 21:31
jsha
jsha previously requested changes Jun 13, 2024
for _, entry := range v.Ids {
limit := v.limit
Copy link
Contributor

Choose a reason for hiding this comment

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

Since v.limit doesn't vary from loop to loop, it would make more sense to do this assignment outside the loop. If you move it all the way to the top of the containing loop (L155), you can also replace some other instances of v.limit with just limit (which I believe is the purpose of the assignment, to create a shorthand).

Copy link
Contributor

Choose a reason for hiding this comment

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

The purpose of this assignment is to create a copy-by-value of the limit, so that we can set fields which do vary per-loop (namely the overrideKey) without affecting the v.limit object from the parent loop.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was one of those things that didn't need to be fixed but could certainly lead to some unpleasantness if someone were to refactor it at a later date. So we decided to fix it now.

@beautifulentropy beautifulentropy dismissed jsha’s stale review June 14, 2024 17:34

Second approval from pgporada

@beautifulentropy beautifulentropy merged commit 063db40 into main Jun 14, 2024
12 checks passed
@beautifulentropy beautifulentropy deleted the fix-override-usage-gauge branch June 14, 2024 17:34
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.

None yet

4 participants