-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
perf(issues): getting users seen counts from cache rather than directly from Snuba #69556
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
Conversation
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.
I'm wondering if we should also clear the cache explicitly when we hit the threshold, and maybe if a user modifies the snooze?
src/sentry/features/temporary.py
Outdated
@@ -80,6 +80,7 @@ def register_temporary_features(manager: FeatureManager): | |||
manager.add("organizations:grouping-suppress-unnecessary-secondary-hash", OrganizationFeature, FeatureHandlerStrategy.INTERNAL) | |||
manager.add("organizations:grouping-title-ui", OrganizationFeature, FeatureHandlerStrategy.REMOTE) | |||
manager.add("organizations:grouping-tree-ui", OrganizationFeature, FeatureHandlerStrategy.REMOTE) | |||
manager.add("organizations:groupsnooze-cached-counts", OrganizationFeature, FeatureHandlerStrategy.OPTION) |
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.
🥳
src/sentry/models/groupsnooze.py
Outdated
@@ -88,13 +91,7 @@ def is_valid(self, group=None, test_rates=False, use_pending_data=False): | |||
if self.user_window: | |||
if not self.test_user_rates(): |
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.
Ahh I was confused, I guess we also need caching like this here, but that could be a follow up
Is modifying a snooze actually modifying existing GroupSnooze or does it rather delete and recreate? In either case what's being kept in cache is the count of events seen since last time checked, so that's independent of GroupSnooze params. |
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.
lgtm, this approach makes sense
src/sentry/models/groupsnooze.py
Outdated
|
||
if cache.get(cache_key, float("inf")) < threshold - 1: | ||
# if we've seen less than that many events, we can't possibly have seen enough users | ||
cache.incr(cache_key) |
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.
I think that we should also look at the post incr
value that is returned, and if that's above threshold-1
then we query. This just avoids a few race conditions where two processes fetch the same value, both increment, and one ends up over the threshold
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.
good callout, I've changed it to increase and get value from that before the if check
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.
I think this is good to go, just needs a couple tests
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
This most basic is an optimization to not go to Snuba for every new event in the issue.
While the number of events seen since the last time we checked unique users count is less than then number of users needed to reach the threshold, we can be sure that the threshold was not reached.
Caveat: when the cached count is just one away from triggering, we'll still call Snuba on every new event in issue until new user is seen.