-
-
Notifications
You must be signed in to change notification settings - Fork 221
Open
Labels
.NETPull requests that update .net codePull requests that update .net codeGood First IssueGood for newcomersGood for newcomersImprovementOpenTelemetryPerformance
Description
perf: intermediate string allocations
I know this is just a re-format of existing code.
But I noticed an extra string allocations just used as intermediate data for converting from SpanId
to ActivitySpanId
, and from SentryId
to ActivityTraceId
:
- allocating from
SpanId
/SentryId
tostring
viaToString()
- converted allocation-free to a
ReadOnlySpan<char>
- where
ActivitySpanId.CreateFromString
andActivityTraceId.CreateFromString
both internally create a new string that is passed to theActivitySpanId
/ActivityTraceId
constructors
If we would - instead of converting to a heap-allocated string
and calling CreateFromString
,
would instead either
- format to a stack-allocated
Span<char>
and callCreateFromString
- format to a stack-allocated
ReadOnlySpan<byte>
and callCreateFromUtf8String
- format to a stack-allocated
ReadOnlySpan<byte>
and callCreateFromBytes
we should be able to get rid of half of the heap allocations there.
This is a smaller gain, where we could get, in the SentryId
case
- from
176 B
(GUID to String with Length 32 and 24 B Class overhead times two) - to
88 B
(cutting above in half)
Do you think this is worth a future improvement?
If so, then I will create a new issue from this comment, labeled Good First Issue
with a low priority.
Otherwise, we just resolve this comment.
Originally posted by @Flash0ver in #4283 (comment)
Metadata
Metadata
Assignees
Labels
.NETPull requests that update .net codePull requests that update .net codeGood First IssueGood for newcomersGood for newcomersImprovementOpenTelemetryPerformance
Type
Projects
Status
No status