Skip to content

EventPipe rundown happening at the end of a session #86103

Open
@vaind

Description

@vaind

I'm trying to implement continuous profiler with Diagnostics IPC StartEventPipeSession(). The idea is to start a profiler when the app launches and only do sample-profiling of select parts of the application. O

Originally, I've tried doing this by creating a new EventPipeSession each time I needed to profile some time span but the startup is pretty heavy (about 100 ms to start when the Microsoft-DotNETCore-SampleProfiler provider is included in the list). Therefore, I've switched to starting the session at the beginning and subscribing to the SampleProfilerTraceEventParser.ThreadSample only for the time needed. This way, the overall overhead is reasonable (below 5 % from my testing) and the long session startup time doesn't affect actual operations, only the app startup (and can be made in the background).

Now to the issue at hand

As the samples are captured, I'm trying to assign modules and methods. These are, however, only provided by the rundown provider when the session is being stopped. In my use-case, this would mean when the application is shut down. The relevant code is:

// Do rundown before fully stopping the session unless rundown wasn't requested
if (ep_session_get_rundown_requested (session) && _ep_can_start_threads) {
ep_session_enable_rundown (session); // Set Rundown provider.
EventPipeThread *const thread = ep_thread_get_or_create ();
if (thread != NULL) {
ep_thread_set_as_rundown_thread (thread, session);
{
config_enable_disable (ep_config_get (), session, provider_callback_data_queue, true);
{
ep_session_execute_rundown (session, _ep_rundown_execution_checkpoints);
}
config_enable_disable(ep_config_get (), session, provider_callback_data_queue, false);
}
ep_thread_set_as_rundown_thread (thread, NULL);
} else {
EP_ASSERT (!"Failed to get or create the EventPipeThread for rundown events.");
}
}

I wonder what the reason for this is and whether there is a way to trigger rundown right at the beginning of the session and then rely on runtime provider during the application lifetime to get updates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Tracing-coreclrenhancementProduct code improvement that does NOT require public API changes/additions

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions