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

EventPipe env var to disable stack collection #82470

Merged
merged 2 commits into from
Mar 2, 2023

Conversation

davmason
Copy link
Member

Collecting stacks can often be extremely expensive, so we should let customers who don't care about stacks opt out. Longer term I would like to have a better story but this is a much needed stopgap measure.

@davmason davmason added this to the 8.0.0 milestone Feb 22, 2023
@davmason davmason requested a review from a team February 22, 2023 10:12
@davmason davmason self-assigned this Feb 22, 2023
@lateralusX
Copy link
Member

lateralusX commented Feb 22, 2023

How does tools that expects stacks react when events turn up without stacks? Collecting a stack for a specific event is part of its manifest. This property will override that globally, so curious how that would affect tooling not getting what's currently anticipated.

Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

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

LGTM 👍

static
inline
bool
ep_rt_config_value_get_disable_stacks (void)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I'd suggest we name the APIs and fields in positive rather than negative terms so we can avoid all the logic becoming double negatives. Ie: if(ep_session_get_stacks_enabled()) { // do stack stuff }

Copy link
Member

@lambdageek lambdageek left a comment

Choose a reason for hiding this comment

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

Using an environment variable to control this seems like the wrong approach to me.
It should be a diagnostic server command/option.
Otherwise I don't see how this will work for ios/Android/wasm. /cc @lateralusX

@davmason
Copy link
Member Author

Using an environment variable to control this seems like the wrong approach to me. It should be a diagnostic server command/option. Otherwise I don't see how this will work for ios/Android/wasm. /cc @lateralusX

This isn't intended to be the long term solution. I also plan on introducing a way to turn off stack collection when starting a session via the IPC, but we have teams who are impacted by the performance of stack walking that need an immediate way to turn it off.

@davmason
Copy link
Member Author

How does tools that expects stacks react when events turn up without stacks? Collecting a stack for a specific event is part of its manifest. This property will override that globally, so curious how that would affect tooling not getting what's currently anticipated.

A well formed parser should be able to handle missing stacks. Perfview/Traceevent does for sure, it's possible that other parsers may have issues but I would consider it a bug in that parser. We already may not emit a stack for an event, there are various cases where we will bail already - if we don't have a managed thread set up, or if rundown is enabled we will skip it.

@lateralusX
Copy link
Member

Using an environment variable to control this seems like the wrong approach to me. It should be a diagnostic server command/option. Otherwise I don't see how this will work for ios/Android/wasm. /cc @lateralusX

Agree, disable it per EventPipe session over IPC will be the long term, more flexible solution. We already have the ability to pass in key value pair through dotnet-trace that should affect the providers configuration, maybe we could leverage that to turn off stack traces on a finer level of control, even using the event mask for the provider to control it on groups of events.

If there is urgency to put something in place short term for desktop/server side, then current approach is ok and will not conflict with long-term IPC solution that would override the "global" setting. There is currently a handful of env variable in play in EventPipe, but I don't see any urgent need to surface this particular one to mobile until we have an IPC solution in place.

@davmason
Copy link
Member Author

davmason commented Mar 2, 2023

Failures are due to #82868

@hoyosjs do you know why the license/cla is blocked? I don't see a way to force retry

@hoyosjs
Copy link
Member

hoyosjs commented Mar 2, 2023

Fixed @davmason

@davmason davmason merged commit 5a2cbf2 into dotnet:main Mar 2, 2023
@davmason
Copy link
Member Author

davmason commented Mar 2, 2023

/backport to release/7.0

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2023

Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/4319033176

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2023

@davmason backporting to release/7.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Env var to disable stack collection
Using index info to reconstruct a base tree...
M	src/coreclr/inc/clrconfigvalues.h
M	src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h
M	src/mono/mono/eventpipe/ep-rt-mono.h
M	src/native/eventpipe/ep-buffer-manager.c
M	src/native/eventpipe/ep-rt.h
M	src/native/eventpipe/ep-session.c
Falling back to patching base and 3-way merge...
Auto-merging src/native/eventpipe/ep-session.c
Auto-merging src/native/eventpipe/ep-rt.h
CONFLICT (content): Merge conflict in src/native/eventpipe/ep-rt.h
Auto-merging src/native/eventpipe/ep-buffer-manager.c
Auto-merging src/mono/mono/eventpipe/ep-rt-mono.h
Auto-merging src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h
CONFLICT (content): Merge conflict in src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h
Auto-merging src/coreclr/inc/clrconfigvalues.h
CONFLICT (content): Merge conflict in src/coreclr/inc/clrconfigvalues.h
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Env var to disable stack collection
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2023

@davmason an error occurred while backporting to release/7.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

davmason added a commit to davmason/runtime that referenced this pull request Mar 2, 2023
carlossanlop pushed a commit that referenced this pull request Mar 9, 2023
…vironment variable) to 7.0 (#82921)

* EventPipe env var to disable stack collection (#82470)

* Add static to declaration
@ghost ghost locked as resolved and limited conversation to collaborators Apr 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants