Skip to content

Conversation

@grendello
Copy link
Contributor

@grendello grendello commented Jun 14, 2021

EventPipe is a dotnet mechanism to implement profiling/tracing of
.NET5+ applications. It replaces the Mono logging profiler which no
longer works.

This commit adds support of packaging the Mono components required for
EventPipe to work in the application APK as well as runtime support for
initializing and enabling the profiler.

Profiler is enabled by setting the debug.mono.profile Android system
property to the appropriate value (e.g. 127.0.0.1:9000,suspend) which
is then exported by the XA runtime as an environment
variable (DOTNET_DiagnosticPorts) which, in turn, is read by the
EventPipe component in order to start profiling.

Details of the process are documented in the
Documentation/guides/tracing.md file.


<PropertyGroup>
<AndroidEnableProfiler Condition=" '$(AndroidEnableProfiler)' == ''">false</AndroidEnableProfiler>
<AndroidEnableHotReload Condition=" '$(AndroidEnableHotReload)' == '' and '$(Configuration)' == 'Debug' ">true</AndroidEnableHotReload>
Copy link
Contributor

@dellis1972 dellis1972 Jun 14, 2021

Choose a reason for hiding this comment

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

now that I think about it do we really need a true value for this? If this is controlled by the IDE then it will be responsible for passing in the value right? I which case we should just always default to false if AndroidEnableHotReload is not already set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is hot reload usable outside the IDE?

Copy link
Contributor

Choose a reason for hiding this comment

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

I dunno something to ask. It is a Dev Loop feature so I would guess it kinda needs an IDE.

Copy link
Member

Choose a reason for hiding this comment

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

I'd also move these settings to Microsoft.Android.Sdk.DefaultProperties.targets.

<UseMonoRuntime Condition=" '$(UseMonoRuntime)' == '' ">true</UseMonoRuntime>

<!-- Mono components -->
<AndroidEnableProfiler Condition=" '$(AndroidEnableProfiler)' == ''">false</AndroidEnableProfiler>
Copy link
Contributor

Choose a reason for hiding this comment

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

The $(AndroidIncludeDebugSymbols) initialization should also be updated to take $(AndroidEnableProfiler) into consideration: https://github.com/xamarin/xamarin-android/blob/7e9f595f23ebd5b53385b16e3890bc90f95f6fef/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets#L302-L323

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean @jonpryor? The profiler is independent on whether or not the build is a debug one, it can be used in both after all

`EventPipe` is a dotnet mechanism to implement profiling/tracing of
.NET5+ applications.  It replaces the Mono logging profiler which no
longer works.

This commit adds support of packaging the Mono components required for
EventPipe to work in the application APK as well as runtime support for
initializing and enabling the profiler.

Profiler is enabled by setting the `debug.mono.profile` Android system
property to the appropriate value (e.g. `127.0.0.1:9000,suspend`) which
is then exported by the XA runtime as an environment
variable (`DOTNET_DiagnosticPorts`) which, in turn, is read by the
EventPipe component in order to start profiling.

Details of the process are documented in the
`Documentation/guides/tracing.md` file.
@grendello grendello marked this pull request as ready for review June 18, 2021 09:11
@grendello grendello changed the title [WIP] EventPipe support in the runtime Add EventPipe tracing support Jun 18, 2021
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM, the test failures look the same as what's failing on main right now.

grendello and others added 2 commits June 21, 2021 17:22
…Microsoft.Android.Sdk.AssemblyResolution.targets

Co-authored-by: Jonathan Peppers <jonathan.peppers@gmail.com>
…Microsoft.Android.Sdk.DefaultProperties.targets

Co-authored-by: Jonathan Peppers <jonathan.peppers@gmail.com>
@grendello grendello merged commit 0f7a0cd into dotnet:main Jun 22, 2021
@grendello grendello deleted the eventpipe-net6 branch June 22, 2021 08:18
jonathanpeppers added a commit that referenced this pull request Jun 22, 2021
* Add EventPipe tracing support

`EventPipe` is a dotnet mechanism to implement profiling/tracing of
.NET5+ applications.  It replaces the Mono logging profiler which no
longer works.

This commit adds support of packaging the Mono components required for
EventPipe to work in the application APK as well as runtime support for
initializing and enabling the profiler.

Profiler is enabled by setting the `debug.mono.profile` Android system
property to the appropriate value (e.g. `127.0.0.1:9000,suspend`) which
is then exported by the XA runtime as an environment
variable (`DOTNET_DiagnosticPorts`) which, in turn, is read by the
EventPipe component in order to start profiling.

Details of the process are documented in the
`Documentation/guides/tracing.md` file.

Co-authored-by: Jonathan Peppers <jonathan.peppers@gmail.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jan 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants