Skip to content
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

Backport changes affecting EventPipe from PR 38225 into C library. #46219

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ep-session-provider.h"
#include "fstream.h"
#include "typestring.h"
#include "win32threadpool.h"

#undef EP_ARRAY_SIZE
#define EP_ARRAY_SIZE(expr) (sizeof(expr) / sizeof ((expr) [0]))
Expand Down Expand Up @@ -1524,6 +1525,15 @@ ep_rt_config_value_get_circular_mb (void)
return CLRConfig::GetConfigValue (CLRConfig::INTERNAL_EventPipeCircularMB);
}

static
inline
bool
ep_rt_config_value_get_use_portable_thread_pool (void)
{
STATIC_CONTRACT_NOTHROW;
return ThreadpoolMgr::UsePortableThreadPool ();
}

/*
* EventPipeSampleProfiler.
*/
Expand Down
9 changes: 9 additions & 0 deletions src/mono/mono/eventpipe/ep-rt-mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,15 @@ ep_rt_config_value_get_circular_mb (void)
return circular_mb;
}

static
inline
bool
ep_rt_config_value_get_use_portable_thread_pool (void)
Copy link
Contributor

Choose a reason for hiding this comment

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

Mono supports portable thread pool only, this should just return true

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

{
// Only supports portable thread pool.
return true;
}

/*
* EventPipeSampleProfiler.
*/
Expand Down
12 changes: 10 additions & 2 deletions src/native/eventpipe/ep-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,16 @@ config_register_provider (

ep_requires_lock_held ();

// See if we've already registered this provider.
EventPipeProvider *existing_provider = config_get_provider (config, ep_provider_get_provider_name (provider));
// See if we've already registered this provider. When the portable thread pool is being used, allow there to be multiple
// DotNETRuntime providers, as the portable thread pool temporarily uses an event source on the managed side with the same
// provider name.
// TODO: This change to allow multiple DotNETRuntime providers is temporary to get EventPipe working for
// PortableThreadPoolEventSource. Once a long-term solution is figured out, this change should be reverted. See
// https://github.com/dotnet/runtime/issues/38763 for more information.
EventPipeProvider *existing_provider = NULL;
if (!ep_rt_config_value_get_use_portable_thread_pool () || ep_rt_utf8_string_compare (ep_config_get_public_provider_name_utf8 (), ep_provider_get_provider_name (provider)) != 0)
existing_provider = config_get_provider (config, ep_provider_get_provider_name (provider));

if (existing_provider)
return false;

Expand Down
4 changes: 4 additions & 0 deletions src/native/eventpipe/ep-rt.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ static
uint32_t
ep_rt_config_value_get_circular_mb (void);

static
bool
ep_rt_config_value_get_use_portable_thread_pool (void);

/*
* EventPipeSampleProfiler.
*/
Expand Down