Skip to content

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

Merged
merged 14 commits into from
Jun 28, 2025
Merged

Feedback for converting eventsource metadata list to a dict #117092

merged 14 commits into from
Jun 28, 2025

Conversation

rcj1
Copy link
Contributor

@rcj1 rcj1 commented Jun 27, 2025

Adding the formatting and other minor changes from code review

@Copilot Copilot AI review requested due to automatic review settings June 27, 2025 16:53
Copy link
Contributor

Tagging subscribers to this area: @tarekgh, @tommcdon, @steveisok, @pjanotti
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

@Copilot Copilot AI left a 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 a Dictionary<int, EventMetadata>
  • Refactored all direct index accesses to use CollectionsMarshal.GetValueRefOrNullRef
  • Updated loops over m_eventData to iterate dictionary keys or values, and added necessary using 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)

@rcj1 rcj1 requested a review from noahfalk June 27, 2025 17:03
@jkotas jkotas changed the title Merge Gh99816 into main Feedback for converting eventsource metadata list to a dict Jun 27, 2025
Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@rcj1 rcj1 merged commit efba03f into main Jun 28, 2025
136 of 143 checks passed
@rcj1 rcj1 deleted the gh99816 branch June 28, 2025 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants