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

[docs] begin documenting how to use EventPipe-based profiled AOT for Mono #72864

Closed
wants to merge 1 commit into from

Conversation

lambdageek
Copy link
Member

Also document how to use diagnostics with WebAssembly

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@lambdageek lambdageek requested a review from mdh1418 July 26, 2022 15:34
@ghost ghost assigned lambdageek Jul 26, 2022
@lambdageek lambdageek added documentation Documentation bug or enhancement, does not impact product or test code area-Tracing-mono labels Jul 26, 2022
Copy link
Member

@lateralusX lateralusX left a comment

Choose a reason for hiding this comment

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

A couple of comments after first read.


Specify `"suspend": true` to suspend the runtime at startup (**NOTE** this will make the browser unresponsive until a diagnostic tool connects and resumes it.) The URL has to use the `ws://` scheme (`wss://` is WIP) the host should be a localhost, the port can be arbitrary, and the path `/diagnostics` is arbtrary, too.

2. Run `dotnet-dsrouter server-websocket -ws http://127.0.0.1:[port]/diagnostics -ipcs /path/to/domain_socket` the `-ws` URL should be the same as the `connect_url` in the .csproj, but with the `http://` scheme. The `-ipcs` option is some arbitrary path.
Copy link
Member

Choose a reason for hiding this comment

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

nit: since its server-websocket maybe put -ipcs argument first and then -ws

btw, should we prepare to handle web socket client as well (not implement anything, just make sure we name things accordingly)? If so, maybe we should use names like -wss and potential -wsc in the future (websocket client), and maybe still use server-server but when using -wss it will use web socket and using -tcps using tcp server?

Copy link
Member Author

Choose a reason for hiding this comment

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

btw, should we prepare to handle web socket client as well (not implement anything, just make sure we name things accordingly)?

I'm not sure that a websocket client mode makes sense. Websockets are asymmetrical - the browser starts the connections to other hosts. There is no mechanism for a browser to listen for connections.

@@ -474,6 +515,39 @@ TraceEvent library, https://www.nuget.org/packages/Microsoft.Diagnostics.Tracing

https://github.com/lateralusX/diagnostics-nettrace-samples includes a couple of custom tools (startup tracing, instrumented method execution, GC heap dump analysis) analyzing nettrace files using TraceEvent library.

## Profiled AOT using `dotnet-pgo`

By collecting a .nettrace file using the diagnostic server and EventPipe, it is possible to create `.mibc` files using the `dotnet-pgo` tool that can be used to tell the Mono AOT compiler which methods in an applcation should be compiled with AOT and which should be interpreted or JITed. A typical use-case is to improve the startup performance of a mobile app, or to control the overall size of an AOTed application.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
By collecting a .nettrace file using the diagnostic server and EventPipe, it is possible to create `.mibc` files using the `dotnet-pgo` tool that can be used to tell the Mono AOT compiler which methods in an applcation should be compiled with AOT and which should be interpreted or JITed. A typical use-case is to improve the startup performance of a mobile app, or to control the overall size of an AOTed application.
By collecting a .nettrace file using the diagnostic server and EventPipe, it is possible to create `.mibc` files using the `dotnet-pgo` tool that can be used to tell the Mono AOT compiler which methods in an application should be compiled with AOT and which should be interpreted or JITed. A typical use-case is to improve the startup performance of a mobile app, or to control the overall size of an AOTed application.

dotnet-pgo create-mibc --trace <file.nettrace>
```

and pass the resulting `.mibc` file to the Mono AOT compiler MSBuild task using the `MibcProfilePath` property,
Copy link
Member

Choose a reason for hiding this comment

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

Didn't we need to pass in a path to the assemblies used producing the .nettrace files to dotnet-pgo, @mdh1418?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea this is incomplete. I need to update this with the actual instructions


Specify `"suspend": true` to suspend the runtime at startup (**NOTE** this will make the browser unresponsive until a diagnostic tool connects and resumes it.) The URL has to use the `ws://` scheme (`wss://` is WIP) the host should be a localhost, the port can be arbitrary, and the path `/diagnostics` is arbtrary, too.

2. Run `dotnet-dsrouter server-websocket -ws http://127.0.0.1:[port]/diagnostics -ipcs /path/to/domain_socket` the `-ws` URL should be the same as the `connect_url` in the .csproj, but with the `http://` scheme. The `-ipcs` option is some arbitrary path.
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to actually use the same connect_url as configured as diagnostic_options? I think that would make things clearer and reduce risk of copy/past errors and forget to change ws(s) to http(s).

Copy link
Member Author

Choose a reason for hiding this comment

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

This all changed too. It's now controlled by the DOTNET_DiagnosticPorts environment variable

@lambdageek
Copy link
Member Author

I'm going to change this to draft for now and rework it to include the changes from the past month of work

@lambdageek lambdageek marked this pull request as draft August 23, 2022 13:16
@ghost ghost closed this Sep 22, 2022
@ghost
Copy link

ghost commented Sep 22, 2022

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 22, 2022
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Tracing-mono documentation Documentation bug or enhancement, does not impact product or test code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants