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

Disable EventSource support in NativeAOT by default #76000

Merged
merged 3 commits into from
Sep 23, 2022

Conversation

MichalStrehovsky
Copy link
Member

@MichalStrehovsky MichalStrehovsky commented Sep 22, 2022

DiagnosticSource is currently not AOT compatible. If a machine-wide DiagnosticSource-related event listener is enabled (such as PerfView, or possibly even a managed VS debugging session) it activates DiagnosticSource code paths within the executable and basically injects a runtime failure into NativeAOT processes due to the AOT-incompatibility of the code.

E.g. trying to do a HttpClient web request with PerfView collecting in the background causes a runtime exception to be thrown.

This uses the documented switch to disable EventSource support (unless the user specified a different value). Indirectly, it disables DiagnosticSource as well.

As a side effect, disabling EventSource drops the size of a NativeAOT-compiled Hello World from 3.48 MB to 2.85 MB 🥳.

Cc @dotnet/ilc-contrib

Contributes to #75945

`DiagnosticSource` is currently not AOT compatible. If a machine-wide DiagnosticSource-related event listener is enabled (such as PerfView, or possibly even a managed VS debugging session) it activates `DiagnosticSource` code paths within the executable and basically injects a runtime failure into NativeAOT processes due to the AOT-incompatibility of the code.

E.g. trying to do a `HttpClient` web request with PerfView collecting in the background causes a runtime exception to be thrown.

This uses the documented switch to disable `EventSource` support (unless the user specified a different value). Indirectly, it disables `DiagnosticSource` as well.

As a side effect, disabling `EventSource` drops the size of a NativeAOT-compiled Hello World from 3.48 MB to 2.85 MB 🥳.
@MichalStrehovsky
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jkotas
Copy link
Member

jkotas commented Sep 22, 2022

Thanks for submitting the PR! You beat me to it, I was just about to do it.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM, assuming the tests are passing.

@MichalStrehovsky
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jkotas
Copy link
Member

jkotas commented Sep 22, 2022

cc @noahfalk

@stephentoub
Copy link
Member

Is it not possible to enable some EventSources without enabling DiagnosticSource?

@MichalStrehovsky
Copy link
Member Author

Is it not possible to enable some EventSources without enabling DiagnosticSource?

We don't have such feature switch.

@stephentoub
Copy link
Member

Is it not possible to enable some EventSources without enabling DiagnosticSource?

We don't have such feature switch.

Shouldn't we add one? Otherwise, what's the production diagnostics story for NativeAOT?

@MichalStrehovsky
Copy link
Member Author

Is it not possible to enable some EventSources without enabling DiagnosticSource?

We don't have such feature switch.

Shouldn't we add one? Otherwise, what's the production diagnostics story for NativeAOT?

We want DiagnosticSource to work in .NET 8 with NativeAOT.

For .NET 7, I doubt that anything more broad than what we're doing here would pass the bar for .NET 7. This is a change I intend to bring for .NET 7 consideration because the failure mode is pretty bad.

@MichalStrehovsky
Copy link
Member Author

Test failures are #76041.

@MichalStrehovsky MichalStrehovsky merged commit e790378 into main Sep 23, 2022
@MichalStrehovsky MichalStrehovsky deleted the MichalStrehovsky-patch-1 branch September 23, 2022 02:08
@MichalStrehovsky
Copy link
Member Author

/backport to release/7.0

@github-actions
Copy link
Contributor

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

MichalStrehovsky added a commit that referenced this pull request Sep 23, 2022
This was disabled by default in #76000. I started filling out the backport template when it hit me that we want to keep it here.

We'll want to backport these in tandem.
MichalStrehovsky added a commit that referenced this pull request Sep 23, 2022
This was disabled by default in #76000. I started filling out the backport template when it hit me that we want to keep it here.

We'll want to backport these in tandem.
github-actions bot pushed a commit that referenced this pull request Sep 23, 2022
This was disabled by default in #76000. I started filling out the backport template when it hit me that we want to keep it here.

We'll want to backport these in tandem.
carlossanlop pushed a commit that referenced this pull request Sep 28, 2022
This was disabled by default in #76000. I started filling out the backport template when it hit me that we want to keep it here.

We'll want to backport these in tandem.

Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
@ghost ghost locked as resolved and limited conversation to collaborators Oct 23, 2022
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.

3 participants