-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.Diagnostics.Activity Perf Improvement Part 2 #40544
Changes from 1 commit
d11af05
526817d
0af8fa9
5d0262c
dd4b901
b9a4865
0fdba3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,10 +76,20 @@ public partial class Activity : IDisposable | |
|
||
private byte _w3CIdFlags; | ||
|
||
/* | ||
* Note: | ||
* DynamicDependency is used here to prevent the linker from removing the struct GetEnumerator on the internal types. | ||
* Some customers use this GetEnumerator dynamically to avoid allocations. | ||
* See: https://github.com/dotnet/runtime/pull/40362 | ||
*/ | ||
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(TagsLinkedList))] | ||
private TagsLinkedList? _tags; | ||
private LinkedList<KeyValuePair<string, string?>>? _baggage; | ||
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(LinkedList<ActivityLink>))] | ||
private LinkedList<ActivityLink>? _links; | ||
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(LinkedList<ActivityEvent>))] | ||
private LinkedList<ActivityEvent>? _events; | ||
|
||
private LinkedList<KeyValuePair<string, string?>>? _baggage; | ||
private ConcurrentDictionary<string, object>? _customProperties; | ||
private string? _displayName; | ||
|
||
|
@@ -255,9 +265,6 @@ public string? RootId | |
/// </summary> | ||
public IEnumerable<KeyValuePair<string, object?>> TagObjects | ||
{ | ||
#if ALLOW_PARTIALLY_TRUSTED_CALLERS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tarekgh I removed the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sense. If you run the tests locally should catch any issue with the security attributes when running against NetFX. |
||
[System.Security.SecuritySafeCriticalAttribute] | ||
#endif | ||
get => _tags ?? s_emptyTagObjects; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking more at this code, you could also change the Enumerator implementations like the following:
And the
public Enumerator<T> GetEnumerator()
method would be preserved, since now it is being called. This would be more preferrable, since if we were linking an application, preserving ALL public methods on these types is more than necessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I updated the code. Should have just done that initially, would have saved myself a lot of time 🤣 Learned a bit about the linker though so not totally wasted 👍