Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 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,19 @@ 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.

{
bool enable = false;
gchar *value = g_getenv ("COMPlus_ThreadPool_UsePortableThreadPool");
if (value && atoi (value) == 1)
enable = true;
g_free (value);
return enable;
}

/*
* 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