Skip to content

Commit 5a2cbf2

Browse files
authored
EventPipe env var to disable stack collection (#82470)
1 parent 967a597 commit 5a2cbf2

File tree

8 files changed

+48
-1
lines changed

8 files changed

+48
-1
lines changed

src/coreclr/inc/clrconfigvalues.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_EventPipeRundown, W("EventPipeRundown"), 1, "E
688688
RETAIL_CONFIG_DWORD_INFO(INTERNAL_EventPipeCircularMB, W("EventPipeCircularMB"), 1024, "The EventPipe circular buffer size in megabytes.")
689689
RETAIL_CONFIG_DWORD_INFO(INTERNAL_EventPipeProcNumbers, W("EventPipeProcNumbers"), 0, "Enable/disable capturing processor numbers in EventPipe event headers")
690690
RETAIL_CONFIG_DWORD_INFO(INTERNAL_EventPipeOutputStreaming, W("EventPipeOutputStreaming"), 0, "Enable/disable streaming for trace file set in DOTNET_EventPipeOutputPath. Non-zero values enable streaming.")
691+
RETAIL_CONFIG_DWORD_INFO(INTERNAL_EventPipeEnableStackwalk, W("EventPipeEnableStackwalk"), 1, "Set to 0 to disable collecting stacks for EventPipe events.")
691692

692693
#ifdef FEATURE_AUTO_TRACE
693694
RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_AutoTrace_N_Tracers, W("AutoTrace_N_Tracers"), 0, "", CLRConfig::LookupOptions::ParseIntegerAsBase10)

src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,19 @@ ep_rt_config_value_get_output_streaming (void)
16301630
return false;
16311631
}
16321632

1633+
static
1634+
inline
1635+
bool
1636+
ep_rt_config_value_get_enable_stackwalk (void)
1637+
{
1638+
STATIC_CONTRACT_NOTHROW;
1639+
// shipping criteria: no EVENTPIPE-NATIVEAOT-TODO left in the codebase
1640+
// TODO: EventPipe Configuration values - RhConfig?
1641+
// (CLRConfig::INTERNAL_EventPipeEnableStackwalk)
1642+
//PalDebugBreak();
1643+
return true;
1644+
}
1645+
16331646
/*
16341647
* EventPipeSampleProfiler.
16351648
*/

src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,15 @@ ep_rt_config_value_get_output_streaming (void)
16911691
return CLRConfig::GetConfigValue (CLRConfig::INTERNAL_EventPipeOutputStreaming) != 0;
16921692
}
16931693

1694+
static
1695+
inline
1696+
bool
1697+
ep_rt_config_value_get_enable_stackwalk (void)
1698+
{
1699+
STATIC_CONTRACT_NOTHROW;
1700+
return CLRConfig::GetConfigValue(CLRConfig::INTERNAL_EventPipeEnableStackwalk) != 0;
1701+
}
1702+
16941703
/*
16951704
* EventPipeSampleProfiler.
16961705
*/

src/mono/mono/eventpipe/ep-rt-mono.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,21 @@ ep_rt_config_value_get_rundown (void)
10171017
return value_uint32_t;
10181018
}
10191019

1020+
static
1021+
inline
1022+
bool
1023+
ep_rt_config_value_get_enable_stackwalk (void)
1024+
{
1025+
uint32_t value_uint32_t = 1;
1026+
gchar *value = g_getenv ("DOTNET_EventPipeEnableStackwalk");
1027+
if (!value)
1028+
value = g_getenv ("COMPlus_EventPipeEnableStackwalk");
1029+
if (value)
1030+
value_uint32_t = (uint32_t)atoi (value);
1031+
g_free (value);
1032+
return value_uint32_t != 0;
1033+
}
1034+
10201035
/*
10211036
* EventPipeSampleProfiler.
10221037
*/

src/native/eventpipe/ep-buffer-manager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ ep_buffer_manager_write_event (
970970
event_thread = thread;
971971

972972
current_stack_contents = ep_stack_contents_init (&stack_contents);
973-
if (stack == NULL && ep_event_get_need_stack (ep_event) && !ep_session_get_rundown_enabled (session)) {
973+
if (stack == NULL && ep_session_get_enable_stackwalk (session) && ep_event_get_need_stack (ep_event) && !ep_session_get_rundown_enabled (session)) {
974974
ep_walk_managed_stack_for_current_thread (current_stack_contents);
975975
stack = current_stack_contents;
976976
}

src/native/eventpipe/ep-rt.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,11 @@ inline
402402
bool
403403
ep_rt_config_value_get_output_streaming (void);
404404

405+
static
406+
inline
407+
bool
408+
ep_rt_config_value_get_enable_stackwalk (void);
409+
405410
/*
406411
* EventPipeSampleProfiler.
407412
*/

src/native/eventpipe/ep-session.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ ep_session_alloc (
202202
instance->session_start_time = ep_system_timestamp_get ();
203203
instance->session_start_timestamp = ep_perf_timestamp_get ();
204204
instance->paused = false;
205+
instance->enable_stackwalk = ep_rt_config_value_get_enable_stackwalk ();
205206

206207
ep_on_exit:
207208
ep_requires_lock_held ();

src/native/eventpipe/ep-session.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ struct _EventPipeSession_Internal {
5959
// we expect to remove it in the future once that limitation is resolved other scenarios are discouraged from using this given that
6060
// we plan to make it go away
6161
bool paused;
62+
// Set via environment variable to enable or disable stack collection globally
63+
bool enable_stackwalk;
6264
};
6365

6466
#if !defined(EP_INLINE_GETTER_SETTER) && !defined(EP_IMPL_SESSION_GETTER_SETTER)
@@ -75,6 +77,7 @@ EP_DEFINE_GETTER(EventPipeSession *, session, bool, rundown_requested)
7577
EP_DEFINE_GETTER(EventPipeSession *, session, ep_timestamp_t, session_start_time)
7678
EP_DEFINE_GETTER(EventPipeSession *, session, ep_timestamp_t, session_start_timestamp)
7779
EP_DEFINE_GETTER(EventPipeSession *, session, EventPipeFile *, file)
80+
EP_DEFINE_GETTER(EventPipeSession *, session, bool, enable_stackwalk)
7881

7982
EventPipeSession *
8083
ep_session_alloc (

0 commit comments

Comments
 (0)