-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Startup flutter faster (use app-jit snapshot)
#111459
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
Startup flutter faster (use app-jit snapshot)
#111459
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I had tried this a few years ago, but I found that the increased compilation time was really quite noticeable. Has performance of app-jit generation improved in recent years?
I definitely don't mind trying this out though
Ahh ok, I remember you tried this but I forgot why it got reverted. Tool compilation should only be an issue either during flutter upgrade, or for the first time after a user checks out a new commit. Is this not reasonable? |
|
Maybe the answer is we should also benchmark tool compilation? |
|
I don't really think that makes sense to track, unless we want to also track the time it takes to download all of the binaries. It only needs to be tolerable for folks that regularly contribute to the tool |
I didn't mean adding a skiaperf benchmark, but at least compiling it both ways n times and documenting on this PR |
|
I did that (on my Linux machine): Kernel and app-jit is done basically as-is (i.e. Runtimes for snapshotting as measured via
Which is the data behind my claim of
This is also why I'm not suggesting compiling to exe (or aot-snapshot) even though that is faster still (in regards to startup at least). |
|
I think the time increase is OK with me. WDUT @christopherfujino ? |
|
Awesome, this looks great to me! |
|
Lets wait until we get the startup benchmarks running: #111748 |
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Benchmarks are running: https://flutter-flutter-perf.skia.org/e/?queries=test%3Dflutter_tool_startup__linux |
Previously: #30102. It was reverted due to a crash in the VM, and it looks like we didn't follow up =(. Presumably in the intervening years, the crasher has been fixed. |
|
No. This failed to. I fixed it in #111879. |
|
Oh, okay, that particular error I didn't see. Lets hope that was fixed :) |
This PR makes
flutter(as measured withflutter testdirectly in theflutterdirectory which has notestdirectory, thus just writing "there's notestdirectory) startup faster by cachinggitcalls.Currently when running
flutterfor the first time or after being on a new git hash, it is compiled to a kernel/dill file. Subsequent calls then just run this compiled file, and thus avoids having to compileflutter_toolsagain and again. This is good.We also have the option to compile to to an
app-jitsnapshot though, which is better in the sense that it loads faster.This PR does exactly that.
Note that this stacks with #111392.
The startup changes as measured on my machines is this:
Linux
I.e. this PR alone:
And stacked with #111392:
Windows (Google issued with whatever security software)
I.e. this PR alone:
And stacked with #111392:
The cost is the compilation taking ~7% longer (less than a second longer).
This seems like a good trade-off to me.
We can technically make it load even faster by using an aot-snapshot, but then the compilation time will increase from something like 10 seconds to something like 30 seconds, and I'm not sure that's a good trade-off.
A more detailed analysis is available internally at go/FlutterStartupTimeAnalysis (which also discussed future PRs).