ref(dynamic-sampling): Use already queried data when computing boosted release platform#115792
Merged
cmanallen merged 3 commits intoMay 20, 2026
Merged
Conversation
shellmayr
approved these changes
May 20, 2026
Member
shellmayr
left a comment
There was a problem hiding this comment.
LGTM - just a ref, should only reduce the calls we make to the DB without behaviour change
obostjancic
approved these changes
May 20, 2026
Member
Author
|
Initial results. The query no longer executes and can not be found in our traces. No defects have been observed (yet) but I'm not anticipating any. |
JonasBa
pushed a commit
that referenced
this pull request
May 21, 2026
…d release platform (#115792) This is our [top query](https://sentry.sentry.io/explore/traces/?aggregateField=%7B%22groupBy%22%3A%22transaction%22%7D&aggregateField=%7B%22yAxes%22%3A%5B%22count%28span.duration%29%22%5D%7D&mode=aggregate&project=1&query=span.description%3A%22SELECT%20%5C%22sentry_project%5C%22.%5C%22id%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22slug%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22name%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22forced_color%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22organization_id%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22public%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22date_added%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22status%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22first_event%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22external_id%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22flags%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22platform%5C%22%20FROM%20%5C%22sentry_project%5C%22%20WHERE%20%5C%22sentry_project%5C%22.%5C%22id%5C%22%20%3D%20%25s%20LIMIT%2021%22&statsPeriod=24h) for a project row (10x second place). But the data already exists in memory at each call site! Let's re-use the already queried project model. You can see that the [transaction](https://sentry.sentry.io/explore/traces/trace/48bd65d7d8054efa87ab06ceed977cd3/?aggregateField=%7B%22groupBy%22%3A%22transaction%22%7D&aggregateField=%7B%22yAxes%22%3A%5B%22count%28span.duration%29%22%5D%7D&field=id&field=span.name&field=span.description&field=span.duration&field=transaction&field=timestamp&mode=samples&node=span-8b45bf1b0c1e592b&project=1&query=span.description%3A%22SELECT%20%5C%22sentry_project%5C%22.%5C%22id%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22slug%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22name%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22forced_color%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22organization_id%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22public%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22date_added%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22status%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22first_event%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22external_id%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22flags%5C%22%2C%20%5C%22sentry_project%5C%22.%5C%22platform%5C%22%20FROM%20%5C%22sentry_project%5C%22%20WHERE%20%5C%22sentry_project%5C%22.%5C%22id%5C%22%20%3D%20%25s%20LIMIT%2021%22%20transaction%3Aspans.consumers.process_segments.process_segment&sort=-span.duration&source=traces&statsPeriod=24h&targetId=9a13383fb2e2c949×tamp=1779161578) typically records a project cache hit as its first op and then queries the project anyway further down. I'm having some difficulty grouping correctly but if you look [here](https://sentry.sentry.io/explore/traces/?aggregateField=%7B%22groupBy%22%3A%22span.op%22%7D&aggregateField=%7B%22yAxes%22%3A%5B%22count%28span.duration%29%22%5D%7D&field=id&field=span.name&field=span.description&field=span.duration&field=transaction&field=timestamp&field=span.op&mode=aggregate&project=1&query=transaction%3Aspans.consumers.process_segments.process_segment&statsPeriod=24h) you can see that `event_manager.dynamic_sampling_observe_latest_release`'s volume is ~90% of the project-query volume linked above. Since we know it always queries once we can conclude a significant resource savings is possible by using the cached value. Optionally, we could pass the `id` and `platform` as values (which would be best IMO) but since this is a drive-by PR its best to preserve things as much as possible.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is our top query for a project row (10x second place). But the data already exists in memory at each call site! Let's re-use the already queried project model.
You can see that the transaction typically records a project cache hit as its first op and then queries the project anyway further down. I'm having some difficulty grouping correctly but if you look here you can see that
event_manager.dynamic_sampling_observe_latest_release's volume is ~90% of the project-query volume linked above. Since we know it always queries once we can conclude a significant resource savings is possible by using the cached value.Optionally, we could pass the
idandplatformas values (which would be best IMO) but since this is a drive-by PR its best to preserve things as much as possible.