-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Feedback for converting eventsource metadata list to a dict #117092
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
Conversation
…acing/EventSource.cs Co-authored-by: Jan Kotas <jkotas@microsoft.com>
…acing/EventSource.cs Co-authored-by: Jan Kotas <jkotas@microsoft.com>
…acing/EventSource.cs Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Tagging subscribers to this area: @tarekgh, @tommcdon, @steveisok, @pjanotti |
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.
Pull Request Overview
This PR merges the formatting and minor refactoring updates from GH99816 into main.
- Switched
m_eventData
from an array to aDictionary<int, EventMetadata>
- Refactored all direct index accesses to use
CollectionsMarshal.GetValueRefOrNullRef
- Updated loops over
m_eventData
to iterate dictionary keys or values, and added necessaryusing
directives
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.cs | Replaced array checks and payload decoding with dictionary lookups |
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs | Converted m_eventData storage to Dictionary<int, EventMetadata> and updated indexing, iteration, and event dispatch logic |
Comments suppressed due to low confidence (2)
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.cs:54
- Switching from an array to a dictionary lookup in this hot path may introduce noticeable overhead. Consider caching the metadata reference or benchmarking this change to ensure performance remains acceptable.
ref EventMetadata metadata = ref CollectionsMarshal.GetValueRefOrNullRef(m_eventData!, (int)eventID);
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs:787
- [nitpick] Iterating dictionary keys may produce a different order than the original array sequence. If event order matters, consider sorting the keys or otherwise preserving the prior order semantics.
foreach (int metaKey in m_eventData.Keys)
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
Outdated
Show resolved
Hide resolved
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.
LGTM, thanks!
Adding the formatting and other minor changes from code review