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

Document how to measure iOS startup times #15416

Closed
jonathanpeppers opened this issue Jul 7, 2022 · 18 comments
Closed

Document how to measure iOS startup times #15416

jonathanpeppers opened this issue Jul 7, 2022 · 18 comments
Assignees
Labels
performance If an issue or pull request is related to performance
Milestone

Comments

@jonathanpeppers
Copy link
Member

Just like the amazing doc here:

I think we need one on measuring iOS startup times? And perhaps other Apple platforms?

We have this document from Apple using instruments:

But I think there is some slowdown once you attach instruments to an iOS app (as seen in dotnet/maui#7687).

We did this for the measurements at https://aka.ms/dotnetperfstatus

If we make a new doc, we can link to it from:

@jonathanpeppers jonathanpeppers added the performance If an issue or pull request is related to performance label Jul 7, 2022
@rolfbjarne rolfbjarne added this to the .NET 7 milestone Jul 8, 2022
@jonathanpeppers
Copy link
Member Author

Also probably want MacCatalyst included here, too. But that might be a completely different topic?

@art-denisov
Copy link

I've tried to follow your instructions on the blog

But when I try to run dotnet-trace in a following way:

dotnet-trace collect --diagnostic-port /tmp/maui-app,connect --format speedscope

I've got an error:
Screenshot 2022-09-01 at 15 02 05

Do you have some advice for me? What have I done wrong?

@art-denisov
Copy link

Also, I've tried to do steps like in the guide for android

  1. Start dotnet-dsrouter
    dotnet-dsrouter client-server -tcps 127.0.0.1:9001 -ipcc /tmp/maui-app --forward-port iOS
  2. Start dotnet-trace without a connection
    dotnet-trace collect --diagnostic-port /tmp/maui-app --format speedscope
  3. Run the iOS app on a physical device
    mtouch --launchdev TestMauiPerf.app --wait-for-exit --argument --connection-mode --argument none '--setenv:DOTNET_DiagnosticPorts=/tmp/maui-app'

So, when I run dotnet-trace I've got a message like for an android session:
Screenshot 2022-09-01 at 15 14 47

Then I launched iOS app and it just runs on my iPhone, but dotnet-trace hasn't caught any data and is still waiting for a connection.

How could I profile maui iOS apps?

@art-denisov
Copy link

@jonathanpeppers can you comment on my questions somehow?

@rolfbjarne
Copy link
Member

@art-denisov try following this guide for profiling iOS apps: https://github.com/xamarin/xamarin-macios/wiki/Profiling

@art-denisov
Copy link

art-denisov commented Sep 2, 2022

I have already tried it. But, as I described above, I got an error on the last step.

When I ran the following command
dotnet-trace collect --diagnostic-port /tmp/maui-app,connect --format speedscope

What have I missed?

I should notice that I try to do it on mac with the physical device connected by the cable.

@rolfbjarne
Copy link
Member

@art-denisov two things:

  1. You have to launch the app first, wait for certain output, then execute the dotnet-trace collect ... command.

  2. Your DOTNET_DiagnosticPorts variable is wrong, it should be:

    mtouch --launchdev TestMauiPerf.app --wait-for-exit --argument --connection-mode --argument none '--setenv:DOTNET_DiagnosticPorts=127.0.0.1:9001,suspend,listen'

@rolfbjarne
Copy link
Member

A doc about how to measure startup on iOS is up: https://github.com/xamarin/xamarin-macios/wiki/Profiling-App-Launch

If we make a new doc, we can link to it from:
dotnet/maui/wiki/Profiling-.NET-MAUI-Apps

Done.

@art-denisov
Copy link

@rolfbjarne
I've tried to follow your recommendations and unfortunately, it doesn't work still

I use the command that you correct
mtouch --launchdev TestMauiPerf.app --wait-for-exit --argument --connection-mode --argument none '--setenv:DOTNET_DiagnosticPorts=127.0.0.1:9001,suspend,listen'
and wait for the output

The runtime has been configured to pause during startup and is awaiting a Diagnostics IPC ResumeStartup command from a Diagnostic Port

but it didn't show up. My terminal looked like
Screenshot 2022-09-06 at 17 47 36

@rolfbjarne
Copy link
Member

@art-denisov did the app launch/show up on the device and if so, can you use it/interact with it?

@art-denisov
Copy link

The app launches on the device and hangs on the start splash screen. I can't interact with it. It seems like the app waits for something.

If I remove suspend,listen at the end of the command the launches normally and I can use it.

@rolfbjarne
Copy link
Member

@art-denisov which version of dotnet-dsrouter do you have?

$ dotnet-dsrouter --version
6.0.345601+f73f09031cebfc6256a9029ce9285a52fdad7380

If you have an earlier version, you need to update it like this: dotnet/diagnostics#3134 (comment)

Also, once the app is running (and non-responsive), what happens if you execute the dotnet-trace command?

$ dotnet-trace collect --diagnostic-port /tmp/maui-app,connect --format speedscope
???

@art-denisov
Copy link

I checked the version of dotnet-dsrouter and dotnet-trace. It's equal to the version in your answer
Screenshot 2022-09-07 at 17 08 23

So, I tried to follow your instruction:

  1. Run dotnet-dsrouter
    Screenshot 2022-09-07 at 17 09 54

  2. Launch the app on the physical device
    Screenshot 2022-09-07 at 17 11 12
    As I wrote before, the app has launched successfully and waited on the splash screen.

  3. Run dotnet-trace
    Screenshot 2022-09-07 at 17 14 20
    It didn't collect data, just the error as I marked in my first comment.

@rolfbjarne
Copy link
Member

@art-denisov looks like there's a copy-paste error in the instructions, try using the following dotnet-dsrouter command instead:

dotnet-dsrouter server-client -tcpc 127.0.0.1:9001 -ipcs /tmp/maui-app --forward-port iOS

(and then the other commands stay the same)

@art-denisov
Copy link

So, it helped.
But it still works strangely.

When I run the command
dotnet-trace collect --diagnostic-port /tmp/maui-app,connect --format speedscope
It collects some data but immediately completes the tracing. Although, I haven't pressed or <Ctrl+C>.
Screenshot 2022-09-07 at 17 34 00

The app on the phone becomes fully interactive.

If I try to execute the command again without relaunching the app, I've got the error.
Screenshot 2022-09-07 at 17 43 35

@rolfbjarne
Copy link
Member

That looks like a problem in dotnet-trace. Maybe try not passing --format speedscope, since it looks like that might be related:

dotnet-trace collect --diagnostic-port /tmp/maui-app,connect

@art-denisov
Copy link

It still completes the tracing immediately but without errors.
Screenshot 2022-09-07 at 17 57 39

@rolfbjarne
Copy link
Member

rolfbjarne commented Sep 8, 2022

That's weird...

  • Does the resulting trace file contain anything?
  • Is anything printed in the tab running mlaunch --launchdev ...?

@ghost ghost locked as resolved and limited conversation to collaborators Oct 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
performance If an issue or pull request is related to performance
Projects
None yet
Development

No branches or pull requests

3 participants