-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[Linux][EventPipe][UserEvents] Add user events eventpipe support #115265
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
[Linux][EventPipe][UserEvents] Add user events eventpipe support #115265
Conversation
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 introduces Linux user events support for EventPipe by adding a new session type (EP_SESSION_TYPE_USEREVENTS) and integrating tracepoint registration and event filtering for user events.
- Added new overloads and structures (e.g. EventPipeTracepoint, EventPipeEventFilter, ProviderTracepointConfiguration) to support user events.
- Updated session allocation, option validation, and event writing to incorporate handling of user events.
- Fixed minor naming issues and adjusted IPC protocol definitions for consistency.
Reviewed Changes
Copilot reviewed 20 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/native/eventpipe/ep.c | Adds new overloads for provider config initialization and adjusts option checks for USEREVENTS. |
src/native/eventpipe/ep-types.h | Introduces new structures and getters for tracepoint and event filtering support. |
src/native/eventpipe/ep-types-forward.h | Adds new session type EP_SESSION_TYPE_USEREVENTS. |
src/native/eventpipe/ep-session.h & .c | Adds user events-related fields and functions (tracepoint registration, event writing). |
src/native/eventpipe/ep-session-provider.h & .c | Updates provider allocation and filtering to include event filtering and tracepoint configuration. |
src/native/eventpipe/ep-provider.c | Updates provider enable mask computation to factor in event filtering via event id. |
src/native/eventpipe/ds-types.h | Cleans up duplicate definitions for command IDs. |
src/native/eventpipe/ds-server.c, ds-protocol.* | Fixes naming inconsistencies and updates IPC protocol references. |
src/native/eventpipe/ds-ipc* files | Adds and updates support functions for receiving file descriptors over IPC. |
Files not reviewed (2)
- src/native/eventpipe/configure.cmake: Language not supported
- src/native/eventpipe/ep-shared-config.h.in: Language not supported
@noahfalk @beaubelgrave @brianrob This is still a WIP, but has everything from deserializing the IPC messages, to registering the tracepoints, and writes dummy data to the tracepoint. CC: @lateralusX FYI, adding some eventpipe changes |
CC: @agocke |
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.
Basic stuff all looks good. I commented on a few things that happened to catch my eye but I mostly avoided the details assuming that things are still changing. I'll take a look again once its more complete.
1c0b495
to
5c7c64a
Compare
I still need to go over the user_events tracepoint registration/writing commits, and I'm trying to look through our types for a faster event_filter check, maybe umap or simdhash? But the first 6 commits which handle the IPC stream deserialization and initializing the user_events eventpipe session are ready for review |
I'd suggest use whichever is simpler to code up, probably umap. Event filters seem unlikely to have more than 1000 elements and processing it once at session startup isn't particularly perf sensitive. At that scale even O(N^2) vector searching is fine, but assuming there is minimal work to swap vector to map I'd go for it just to eliminate the risk if the filters ever scaled up really big. |
After I finish revising the Tracepoint registration + Tracepoint write and existing feedback, will rebase for a cleaner commit history |
Visual reorder of Diagnostics enum structs Fix a couple naming typos Spaces to tabs consistency
To support the new user_events-based eventpipe session, add a more modular and flexible EventPipeProviderConfiguration deserializer.
The user_events_data file is required to register user_events tracepoints. Require profilers to pass over the corresponding file descriptor with SCM_RIGHTS in order to initialize the user_events EventPipe session.
24504c5
to
d6648a2
Compare
Fix eventpipe_collect_tracing_command_free_tracepoint_sets logic Clarify len variable names Consistently use -1 as invalid file descriptor Update event_pipe to use ep_rt_utf16_to_utf8_string/free
3d15c4a
to
93f7f0a
Compare
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! Greate work!
I have not done a full review of this PR. Just wanted to voice my appreciation for you doing this work! |
Runtime support for dotnet/diagnostics#5454
This PR adds user_events support for native runtime events leveraging EventPipe infrastructure, following the IPC Protocol Specification for CollectTracing5 discussed in dotnet/diagnostics#5454.
A new User_events EventPipe Session type is added to the runtime and enabled through the CollectTracing5 IPC Command. The User_events EventPipe session deviates from the typical IPC Streaming session by writing events directly to Tracepoints configured through the initial IPC Message, instead of using the buffer manager.
In addition, an event filter can be configured for more precise control over which events are enabled for each IPC initialized EventPipe Session.
The changes in this PR are as follows:
Work planned for follow-up PRs
Testing
Performed manual end-to-end testing with:
sudo perf list user_events*
echo 1 > /sys/kernel/tracing/events/user_events/<tracepoints>/enable
sudo cat /sys/kernel/tracing/trace