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

Not able to determine time taken by Dart VM initialisation #6817

Open
hrajwade96 opened this issue Nov 22, 2023 · 4 comments
Open

Not able to determine time taken by Dart VM initialisation #6817

hrajwade96 opened this issue Nov 22, 2023 · 4 comments
Labels
cpu profiler P2 important to work on, but not at the top of the work list. screen: performance Issues with the Performance screen

Comments

@hrajwade96
Copy link
Contributor

hrajwade96 commented Nov 22, 2023

I am tracing app startup for Android device (Samsung Galaxy m51), In flutter devtools, I can see Warm-up frame at 4s 52ms 432us.
I am trying to analyse this delay and therefore need to find time taken by Dart VM initialisation as I am suspecting that could be one culprit.
In logs I can see a gap of 3.107s in MainActivity OnResume to main.dart first statement execution.
In Dev tools I can see gap of 4.52s before Warm-up frame and our own code execution.
I also added custom timeline traces in main.dart first line itself, its starting at ~4s
I am trying to verify if both are pointing to same delay.
As per my understanding Dart VM startup is somewhere between this time.

In another run I tried with '--trace-startup --profile'
in the startuptimeline.json i got :
{
"name": "DartVMInitializer",
"cat": "Embedder",
"tid": 4139,
"pid": 4139,
"ts": 14740213596,
"ph": "E",
"args": {}
},

this seems to be an end event but there is no subsequent start event in that file.

In dev tools I am not able to see much between FlutterEngineMainEnter and Warm-up frame.

Flutter doctor :
Flutter doctor results :

[✓] Flutter (Channel stable, 3.13.4, on macOS 14.0 23A344 darwin-arm64, locale en-IN)
• Flutter version 3.13.4 on channel stable at /Users/hrishikeshrajwade/Downloads/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 367f9ea16b (2 months ago), 2023-09-12 23:27:53 -0500
• Engine revision 9064459a8b
• Dart version 3.1.2
• DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/hrishikeshrajwade/Library/Android/sdk
• Platform android-33, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A507
• CocoaPods version 1.11.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 73.0.4
• Dart plugin version 231.8109.91

[✓] VS Code (version 1.71.2)
• VS Code at /Users/hrishikeshrajwade/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.60.0

@hrajwade96
Copy link
Contributor Author

@kenzieschmoll any idea about this

1 similar comment
@hrajwade96
Copy link
Contributor Author

@kenzieschmoll any idea about this

@kenzieschmoll
Copy link
Member

If you go to the CPU profiler tab and click the "Profile App Startup" button, that may help. CC @bkonyi and @dnfield for ideas about the "DartVMInitializer" timeline event.

@kenzieschmoll kenzieschmoll added screen: performance Issues with the Performance screen cpu profiler P2 important to work on, but not at the top of the work list. labels Nov 29, 2023
@bkonyi
Copy link
Contributor

bkonyi commented Nov 29, 2023

There's a good chance that we're not seeing the start of the timeline event because it's started before the VM is initialized. Unless TRACE_EVENT0(...) can record to a systrace like recorder (I'm not sure of its implementation), the begin event will be dropped if it's supposed to be handled by the VM since the timeline recorder isn't initialized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpu profiler P2 important to work on, but not at the top of the work list. screen: performance Issues with the Performance screen
Projects
None yet
Development

No branches or pull requests

3 participants