Repository navigation
perf(profiling): Read Perfetto trace straight into the envelope payload - #6743
Merged
Merged
Conversation
Co-Authored-By: Roman Zavarnitsyn <roman.zavarnitsyn@sentry.io>
Co-Authored-By: Roman Zavarnitsyn <roman.zavarnitsyn@sentry.io>
Contributor
PR risk: mediumFor commit Main concerns: reach, host stability. This label is a hint for reviewers, not an approval. |
📲 Install BuildsAndroid
|
…ingle-allocation # Conflicts: # CHANGELOG.md
romtsn
marked this pull request as ready for review
November 23, 2026 18:32
romtsn
requested review from
0xadam-brown and
romtsn
and removed request for
a team
November 23, 2026 18:32
…ingle-allocation # Conflicts: # CHANGELOG.md
markushi
reviewed
Nov 25, 2026
markushi
approved these changes
Nov 25, 2026
3 tasks done
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.
SentryEnvelopeItem.fromPerfettoProfileChunkused to build the payload in three steps.readBytesFromFilestreamed the trace into a growingByteArrayOutputStream,toByteArray()copied that, and then the result was copied a third time into a new[metadata][trace]array. A trace can be up to 50 MB, so at peak the trace could be in memory about three times, which is a real OOM risk on low-end devices.Now the payload array is sized once (metadata length plus file length), and the trace file is read directly into its slot after the metadata. The checks stay the same: the file must be readable and no larger than
MAX_PROFILE_CHUNK_SIZE, and it's deleted whether the read succeeds or fails. If the file shrinks or grows between the size check and the read, the read fails instead of sending a truncated trace.The new helper is private to
SentryEnvelopeItem, so the public API doesn't change. The other profile paths still usereadBytesFromFile.via roman.
--
View Session [Sentry]