Skip to content

perf(sdk-updates): Read the SDK index once per event serialization - #129097

Merged
BYK merged 2 commits into
masterfrom
perf/memoize-sdk-versions-lookup
Nov 2, 2026
Merged

BYK merged 2 commits into
masterfrom
perf/memoize-sdk-versions-lookup

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

IssueEventSerializer computes sdkUpdates for each event, and that computation read the sentry:release-registry-sdk-versions cache key several times per event. The index state read it once to build the versions map. Every Suggestion.to_json() read it again through get_sdk_urls() to fill in sdkUrl. Suggestion.__eq__ calls to_json() on both sides, so each suggestion in parent_suggestions check read it twice more. With an outdated SDK, one serialization made 6 reads, measured by the new test before the fix.

Now SdkIndexState reads the index once, lazily, and derives both the versions map and the URL map from that one read. to_json() takes the URL map from the index state. Equality no longer looks at sdkUrl, which is derived from the SDK name already being compared, so the result is the same. The result is one cache read per event serialization, which is one per request on the event details endpoints. Nothing is cached across requests and TTL semantics are unchanged. Data is as fresh as before: the 5-minute registry task with its 1h cache TTL still controls it. I didn't find an existing request-scoped cache helper. A process-level ttl_cache would have added cross-request staleness and broken tests that seed the cache key, so I scoped the fix to the per-serialization path instead.

get_sdk_versions() also copies settings.SDK_VERSIONS now instead of writing registry versions into it in place. get_sdk_urls() already copied.

Why: 7-day estimates from sampled spans and Datadog, not exact counts. The key is fetched about 49M times a week, about 5 times per event details request at about 5 ms each, so roughly 28 ms per request. The event details endpoints serve about 14.6M (group) plus 4.2M (project) requests a week.

Context: #128818

via BYK.

--

View Junior Session in Sentry

Computing sdkUpdates read sentry:release-registry-sdk-versions from the cache
once for the index state and again for every suggestion's sdkUrl, including
both sides of each suggestion equality check. An outdated SDK caused six
reads per event. SdkIndexState now reads the index once and derives versions
and URLs from it, so data freshness is unchanged.

get_sdk_versions also stops mutating settings.SDK_VERSIONS in place.

Refs #128818

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner October 28, 2026 21:17
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 28, 2026
@BYK
BYK enabled auto-merge (squash) October 28, 2026 21:42
@BYK
BYK merged commit e651bb2 into master Nov 2, 2026
77 checks passed
@BYK
BYK deleted the perf/memoize-sdk-versions-lookup branch November 2, 2026 22:33

This branch was successfully deployed

1 active deployment
Preview — 77b4c9d4 Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants