[perf] Avoid boxing TagList in Activity.AddException - #134645
Merged
Merged
Conversation
Avoid boxing `TagList` plus an enumerator when `Activity.AddException()` is used by adding a span-based fast path.
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @steveisok, @dotnet/area-system-diagnostics-tracing |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused optimization preserves tag ordering and behavior, retains cross-target compatibility, and is supported by allocation benchmarks and existing tests.
Review effort: Balanced
Findings: None
What changed in this PR
Optimizes Activity.AddException by copying TagList entries directly from a span, avoiding two boxing allocations on modern .NET.
Changes:
- Adds a span-based
TagsLinkedListconstructor. - Uses the fast path while preserving the existing fallback for other targets.
| File | Description |
|---|---|
ActivityEvent.cs |
Selects the span-based tag-copy path on .NET. |
Activity.cs |
Adds direct linked-list construction from a tag span. |
Member
|
/ba-g the failure is unrelated |
This was referenced Sep 25, 2026
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.
Avoid boxing
TagListplus an enumerator whenActivity.AddException()is used by adding a span-based fast path.Benchmarks
vs. main: -3.5% time, -8.0% allocated (-320 B)
Benchmark code