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 (Only access globals.deviceManager if actually setting something)
#111461
Startup flutter
faster (Only access globals.deviceManager if actually setting something)
#111461
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. |
This seems like a reasonable change, but is something that may accidentally regress if not tested in some way. Perhaps we could cover this with a CI benchmark that measures start up time of the flutter tool? @jensjoha if you'd like I'd be more than happy to walk you though adding one. since you're doing so much work here and elsewhere to improve performance I think it would be great to track it |
I agree that a benchmark would be good. |
I think the best example to work from would be something like the analyzer benchmark: flutter/dev/devicelab/lib/tasks/analysis.dart Lines 23 to 57 in 195a1cc
In this we simply run some command and record the total time. In this case, maybe just
If you land this before any of these PRs, then we can observe the improvements too |
As directed on flutter#111461 (comment)
Add flutter startup benchmark for Linux, Windows and MacOs. Via guide on #111461 (comment)
Benchmarks are running: https://flutter-flutter-perf.skia.org/e/?queries=test%3Dflutter_tool_startup__linux |
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
This PR makes
flutter
(as measured withflutter test
directly in theflutter
directory which has notest
directory, thus just writing "there's notest
directory) startup faster by cachinggit
calls.When starting
flutter
currently the user-specified "device id" is unconditionally set on the device manager.There is nothing technically wrong with that, but when a device id has not been provided by the user, and we don't otherwise need the device manager it is created for no reason.
This wouldn't be too bad, if it wasn't because it could take quite a while to do so, but it can (because it eagerly searches for the android sdk).
This PR makes it conditional on the user having actually specified a device id.
A future PR could make the android sdk search lazy instead.
On my Linux machine - which does have an android sdk - this doesn't change much --- it removes something along the lines of 3-5 ms, but on my Windows machine - which does not have an android sdk - the change is quite significant, see below.
This PR stacks with #111392 and #111459.
Windows (Google issued with whatever security software --- and no android sdk)
I.e. this PR alone:
And stacked with #111392 and #111459:
A more detailed analysis is available internally at go/FlutterStartupTimeAnalysis (which also discussed future PRs).