Skip to content

Commit

Permalink
Env var to disable stack collection
Browse files Browse the repository at this point in the history
  • Loading branch information
davmason committed Mar 1, 2023
1 parent 5e3dd8d commit fb01dfb
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_EventPipeRundown, W("EventPipeRundown"), 1, "E
RETAIL_CONFIG_DWORD_INFO(INTERNAL_EventPipeCircularMB, W("EventPipeCircularMB"), 1024, "The EventPipe circular buffer size in megabytes.")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_EventPipeProcNumbers, W("EventPipeProcNumbers"), 0, "Enable/disable capturing processor numbers in EventPipe event headers")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_EventPipeOutputStreaming, W("EventPipeOutputStreaming"), 0, "Enable/disable streaming for trace file set in DOTNET_EventPipeOutputPath. Non-zero values enable streaming.")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_EventPipeDisableStacks, W("EventPipeDisableStacks"), 0, "Set to 1 to disable collecting stacks for EventPipe events.")

#ifdef FEATURE_AUTO_TRACE
RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_AutoTrace_N_Tracers, W("AutoTrace_N_Tracers"), 0, "", CLRConfig::LookupOptions::ParseIntegerAsBase10)
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,15 @@ ep_rt_config_value_get_output_streaming (void)
return CLRConfig::GetConfigValue (CLRConfig::INTERNAL_EventPipeOutputStreaming) != 0;
}

static
inline
bool
ep_rt_config_value_get_disable_stacks (void)
{
STATIC_CONTRACT_NOTHROW;
return CLRConfig::GetConfigValue(CLRConfig::INTERNAL_EventPipeDisableStacks) != 0;
}

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

static
inline
bool
ep_rt_config_value_get_disable_stacks (void)
{
uint32_t value_uint32_t = 0;
gchar *value = g_getenv ("DOTNET_EventPipeDisableStacks");
if (!value)
value = g_getenv ("COMPlus_EventPipeDisableStacks");
if (value)
value_uint32_t = (uint32_t)atoi (value);
g_free (value);
return value_uint32_t;
}

/*
* EventPipeSampleProfiler.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/native/eventpipe/ep-buffer-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ ep_buffer_manager_write_event (
event_thread = thread;

current_stack_contents = ep_stack_contents_init (&stack_contents);
if (stack == NULL && ep_event_get_need_stack (ep_event) && !ep_session_get_rundown_enabled (session)) {
if (stack == NULL && !ep_session_get_disable_stacks(session) && ep_event_get_need_stack (ep_event) && !ep_session_get_rundown_enabled (session)) {
ep_walk_managed_stack_for_current_thread (current_stack_contents);
stack = current_stack_contents;
}
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 @@ -402,6 +402,10 @@ inline
bool
ep_rt_config_value_get_output_streaming (void);

static
bool
ep_rt_config_value_get_disable_stacks (void);

/*
* EventPipeSampleProfiler.
*/
Expand Down
1 change: 1 addition & 0 deletions src/native/eventpipe/ep-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ ep_session_alloc (
instance->session_start_time = ep_system_timestamp_get ();
instance->session_start_timestamp = ep_perf_timestamp_get ();
instance->paused = false;
instance->disable_stacks = ep_rt_config_value_get_disable_stacks();

ep_on_exit:
ep_requires_lock_held ();
Expand Down
3 changes: 3 additions & 0 deletions src/native/eventpipe/ep-session.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ struct _EventPipeSession_Internal {
// we expect to remove it in the future once that limitation is resolved other scenarios are discouraged from using this given that
// we plan to make it go away
bool paused;
// Set via environment variable to prevent stack collection for all events
bool disable_stacks;
};

#if !defined(EP_INLINE_GETTER_SETTER) && !defined(EP_IMPL_SESSION_GETTER_SETTER)
Expand All @@ -75,6 +77,7 @@ EP_DEFINE_GETTER(EventPipeSession *, session, bool, rundown_requested)
EP_DEFINE_GETTER(EventPipeSession *, session, ep_timestamp_t, session_start_time)
EP_DEFINE_GETTER(EventPipeSession *, session, ep_timestamp_t, session_start_timestamp)
EP_DEFINE_GETTER(EventPipeSession *, session, EventPipeFile *, file)
EP_DEFINE_GETTER(EventPipeSession *, session, bool, disable_stacks)

EventPipeSession *
ep_session_alloc (
Expand Down

0 comments on commit fb01dfb

Please sign in to comment.